Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for cross_correlate function #4

Open
olivierfriard opened this issue May 29, 2018 · 4 comments
Open

Example for cross_correlate function #4

olivierfriard opened this issue May 29, 2018 · 4 comments

Comments

@olivierfriard
Copy link

Hello,

I am doing some tests to migrate from praat script to parselmouth.
May you give some example for using the croos_correlate function?

My praat script is (part of):

             Read from file... 'directory$'/'sound1$'
             Rename... 1

             Read from file... 'directory$'/'sound2$'
             Rename... 2

             select Sound 1
             plus Sound 2

             Cross-correlate... -0.20 0.20 yes
             ccvalue = Get maximum... 0 0 Sinc70

I wrote this in Python:

import parselmouth as pm
s1 = pm.Sound("sound1.wav")
s2 = pm.Sound("sound2.wav")
cc = s1.cross_correlate(s2)

Everything is going well but I do not know how to extract the cc value...
Thank you
Olivier

@YannickJadoul
Copy link
Owner

YannickJadoul commented May 29, 2018

Unfortunately, I don't think that "Get maximum" function has been ported to the Python API yet. As far as I remember, there were some problems/design issues with units and/or interpolation to add this to the Sampled base class. But I should probably have a look at porting this in a future version.

However, until this issue can get solved, I would suggest using parselmouth.praat.call(cc, "Get maximum", 0, 0, "Sinc70"), which shóuld work and give you the same answer?

@YannickJadoul
Copy link
Owner

(I would advise against the other option, i.e. cc.values.max(), because this will only get you the maximum sample without interpolating, so this would be like choosing None as interpolation)

@olivierfriard
Copy link
Author

olivierfriard commented May 30, 2018 via email

@YannickJadoul
Copy link
Owner

Thanks; do let me know when it doesn't work as intended.
By the way: I still need to put an example together and add it to ReadTheDocs, but if you have larger existing Praat scripts, you can also use parselmouth.praat.run and parselmouth.praat.run_file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants