I am trying to write a script for Praat and am having difficulty doing it.
What I want is to have a result for a certain word in a sentence (and a sound), ex.: As you're not using your car at the moment, can I borrow it?
I want a pitch list for the word "moment". If I select the word "moment" and select pitch listing under the menu of pitch then it gives me the time and f0 for every 0.01 second (open both sound and TextGrid).
I have been searching and trying to script this but haven't succeeded yet.
Could you help me with this?
I have modified the upper question.
sentence: As you're not using your car at the moment, can I borrow it? (I have a mp3 file, text grid with 2 tiers for this sentence, tier 1 is the word and tier 2 is phone)
The following is my script. I want to have the f0 max and min for the last syllable part of the word "moment" but only succeeded in having the f0 max and min for the whole interval 10("moment" in tier 1).
I also have a phone tier for the word "moment" (in tier 2), which is the following:
phone tier for the word "moment" is M OW M AH N T
=> and I want [M AH N T] 's f0 max and f0 min excluding [M OW] which is the first syllable part.
the following is the script I have so far.
form Get F0 Min-Max
sentence Directory ./
word Base_file_name
comment The name of result file
text textfile F0_list.txt
endform
# Create a header row for the result file:
header$ = "Filename TextGridLabel startTime endTime minTime f0min maxTime f0max'newline$'"
fileappend "'textfile$'" 'header$'
#Read all files in a folder
Create Strings as file list... mp3list 'directory$'/'base_file_name$'*.mp3
Create Strings as file list... gridlist 'directory$'/'base_file_name$'*.TextGrid
n = Get number of strings
for i to n
clearinfo
#We first extract pitch tiers
select Strings mp3list
filename$ = Get string... i
Read from file... 'directory$'/'filename$'
soundname$ = selected$ ("Sound")
To Pitch... 0.01 75 600
output$ = "'soundname$'.Pitch"
# Write to binary file... 'output$'
# Read grid files and extract the selected intervals in them
select Strings gridlist
gridname$ = Get string... i
Read from file... 'directory$'/'gridname$'
int=Get number of intervals... 1
# Calculates F0 max, and F0 min (I need interval 10 to be analyzed for the word "moment" so have the 1 10 for the label)
select TextGrid 'soundname$'
label$ = Get label of interval... 1 10
if label$ <> ""
startTime = Get starting point... 1 10
endTime = Get end point... 1 10
select Pitch 'soundname$'
f0max = Get maximum... startTime endTime Hertz Parabolic
maxTime = Get time of maximum... startTime endTime Hertz Parabolic
f0min = Get minimum... startTime endTime Hertz Parabolic
minTime = Get time of minimum... startTime endTime Hertz Parabolic
resultline$ =
"'soundname$''tab$''label$''tab$''syllableTime''tab$''endTime''tab$''minTime''tab$''f0min''tab$''maxTime''tab$''f0max'"
fileappend "'textfile$'" 'resultline$'
endif
fileappend "'textfile$'" 'newline$'
endfor
# clean up
select all
Remove
Could you help me with this? thank you so much.
Could you add a new tier to separate out just the part you are interested in? Are there any other sentences in your data?
then, take the measurement of the intervals you just created.