Discussion:
F0 script that would preserve --undefined-- on listing
pedroamaranteandrade
2012-07-19 12:18:30 UTC
Permalink
Dear all,

I am relatively new to praat scripting and I am struggling with a few things.

1o. - I cannot produce a F0 listing using script that preserve the window length of 0.03. It gives me a listing with no --undefined-- values. I need to compare F0 - F1, therefore need with the same time(s)

2a. - How can I extract F0 and F1 producing a .txt file with both at the same time(s) steps.

I am using the following script for the first part:

echo 'defaultDirectory$'
Create Strings as file list... fileList 'defaultDirectory$'
nb_files = Get number of strings

for person from 1 to nb_files
select Strings fileList
file_name$ = Get string... person
name$ = "'file_name$'" - ".wav"
Read from file... 'defaultDirectory$'\'file_name$'

select Sound 'name$'
Extract one channel... 1
To Pitch... 0.03 45 300
Down to PitchTier
Down to TableOfReal... Hertz
To ContingencyTable
Save as text file... 'defaultDirectory$'\'file_name$'+ ".txt"
select all
minus Strings fileList
Remove
endfor

Thank you very much for your help.

Best regards,

Pedro



------------------------------------

To Post a message, send it to: praat-users-***@public.gmane.org

To Unsubscribe, send a blank message to: praat-users-unsubscribe-***@public.gmane.org

To consult archives : http://egroups.com/list/praat-users/
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://uk.groups.yahoo.com/group/praat-users/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://uk.groups.yahoo.com/group/praat-users/join
(Yahoo! ID required)

<*> To change settings via email:
praat-users-digest-hHKSG33Tihj7tPOJXBBAsVpr/1R2p/***@public.gmane.org
praat-users-fullfeatured-hHKSG33Tihj7tPOJXBBAsVpr/1R2p/***@public.gmane.org

<*> To unsubscribe from this group, send an email to:
praat-users-unsubscribe-hHKSG33Tihj7tPOJXBBAsVpr/1R2p/***@public.gmane.org

<*> Your use of Yahoo! Groups is subject to:
http://uk.docs.yahoo.com/info/terms.html
Paul Boersma
2012-07-19 14:04:13 UTC
Permalink
Post by pedroamaranteandrade
- I cannot produce a F0 listing using script that preserve the window length of 0.03. It gives me a listing with no --undefined-- values. I need to compare F0 - F1, therefore need with the same time(s)
look at the "script for listing time-F0-intensity" in the scripting examples in the manual. The idea is to use a very small time step, e.g. 0.001 seconds, and then to query both the Pitch object and the Formant object at the times of interest. You will get precise interpolated values.
Post by pedroamaranteandrade
- How can I extract F0 and F1 producing a .txt file with both at the same time(s) steps.
the same example script produces a table in the Info window. From the Info window you can save it to a text file (this could also be done from the script directly).
_____

Paul Boersma
University of Amsterdam
Linguistics
Spuistraat 210, room 303
1012VT Amsterdam, The Netherlands
http://www.fon.hum.uva.nl/paul/



------------------------------------

To Post a message, send it to: praat-users-***@public.gmane.org

To Unsubscribe, send a blank message to: praat-users-unsubscribe-***@public.gmane.org

To consult archives : http://egroups.com/list/praat-users/
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://uk.groups.yahoo.com/group/praat-users/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://uk.groups.yahoo.com/group/praat-users/join
(Yahoo! ID required)

<*> To change settings via email:
praat-users-digest-hHKSG33Tihj7tPOJXBBAsVpr/1R2p/***@public.gmane.org
praat-users-fullfeatured-hHKSG33Tihj7tPOJXBBAsVpr/1R2p/***@public.gmane.org

<*> To unsubscribe from this group, send an email to:
praat-users-unsubscribe-hHKSG33Tihj7tPOJXBBAsVpr/1R2p/***@public.gmane.org

<*> Your use of Yahoo! Groups is subject to:
http://uk.docs.yahoo.com/info/terms.html
José Joaquín Atria
2012-07-19 13:58:42 UTC
Permalink
Not really sure what you are trying to do with your script, but if you are
generating a PitchTier from your Pitch object you'll definitely not have
any undefined values. If you View a PitchTier object you'll be able to tell
why.

You could use a script like this, which will print f0 values from a
selected Pitch object into a specified file, and add f1 values from a
selected Formant object if the f0 value is not undefined. I'm sure if you
play around with this you'll manage to coax it into the desired output.
This is just to give you an idea.

filename$ = "myfile.txt"

pitch = selected("Pitch")
formant = selected("Formant")

header$ = "Time (s)" + tab$ + "f0 (Hz)" + tab$ + "f1 (Hz)" + newline$
header$ > 'filename$'

select pitch
n = Get number of frames
for i to n
select pitch
t = Get time from frame number... i
p = Get value in frame... i Hertz
if p != undefined
select formant
f1 = Get value at time... 1 t Hertz Linear
else
f1 = undefined
endif
line$ = "'t:2'" + tab$ + "'p:2'" + tab$ + "'f1:2'" + newline$
line$ >> 'filename$'
endfor

Also, just noticed the new Praat script editor now supports more than one
undo level. Nice!

José Joaquín Atria

www.pinguinorodriguez.cl



On Thu, Jul 19, 2012 at 1:18 PM, pedroamaranteandrade <
Post by pedroamaranteandrade
**
Dear all,
I am relatively new to praat scripting and I am struggling with a few things.
1o. - I cannot produce a F0 listing using script that preserve the window
length of 0.03. It gives me a listing with no --undefined-- values. I need
to compare F0 - F1, therefore need with the same time(s)
2a. - How can I extract F0 and F1 producing a .txt file with both at the
same time(s) steps.
echo 'defaultDirectory$'
Create Strings as file list... fileList 'defaultDirectory$'
nb_files = Get number of strings
for person from 1 to nb_files
select Strings fileList
file_name$ = Get string... person
name$ = "'file_name$'" - ".wav"
Read from file... 'defaultDirectory$'\'file_name$'
select Sound 'name$'
Extract one channel... 1
To Pitch... 0.03 45 300
Down to PitchTier
Down to TableOfReal... Hertz
To ContingencyTable
Save as text file... 'defaultDirectory$'\'file_name$'+ ".txt"
select all
minus Strings fileList
Remove
endfor
Thank you very much for your help.
Best regards,
Pedro
[Non-text portions of this message have been removed]



------------------------------------

To Post a message, send it to: praat-users-***@public.gmane.org

To Unsubscribe, send a blank message to: praat-users-unsubscribe-B11MqFFcr06IwRZHo2/***@public.gmane.orgm

To consult archives : http://egroups.com/list/praat-users/
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://uk.groups.yahoo.com/group/praat-users/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://uk.groups.yahoo.com/group/praat-users/join
(Yahoo! ID required)

<*> To change settings via email:
praat-users-digest-hHKSG33Tihj7tPOJXBBAsVpr/1R2p/***@public.gmane.org
praat-users-fullfeatured-hHKSG33Tihj7tPOJXBBAsVpr/1R2p/***@public.gmane.org

<*> To unsubscribe from this group, send an email to:
praat-users-unsubscribe-hHKSG33Tihj7tPOJXBBAsVpr/1R2p/***@public.gmane.org

<*> Your use of Yahoo! Groups is subject to:
http://uk.docs.yahoo.com/info/terms.html

Loading...