YannickJadoul / Parselmouth

Praat in Python, the Pythonic way
https://parselmouth.readthedocs.io/
GNU General Public License v3.0
1.05k stars 114 forks source link

Example for cross_correlate function #4

Open olivierfriard opened 6 years ago

olivierfriard commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

(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 commented 6 years ago

Hi,

thank you. I will make some tests.

On Tue, May 29, 2018 at 6:53 PM, Yannick Jadoul notifications@github.com wrote:

(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)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/YannickJadoul/Parselmouth/issues/4#issuecomment-392850954, or mute the thread https://github.com/notifications/unsubscribe-auth/AGOgYmnYvFHPEAxe6o6jWbDqOz6f4NE7ks5t3X0UgaJpZM4URp6E .

-- University of Torino Life Sciences and Systems Biology department Via dell'Accademia Albertina, 13 10123 TORINO (Italy) tel: +39 011 6704542 http://www.di.unito.it/~friard/ http://orcid.org/0000-0002-0374-9872

YannickJadoul commented 6 years ago

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