Script for analysing pitch with a TextGrid

"I want the mean pitch of every interval that has a non-empty label on tier 5."

if numberOfSelected ("Sound") <> 1 or numberOfSelected ("TextGrid") <> 1
    exit Please select a Sound and a TextGrid first.
endif
sound = selected ("Sound")
textgrid = selected ("TextGrid")
echo Result:
select sound
To Pitch... 0.0 75 600
pitch = selected ("Pitch")
select textgrid
n = Get number of intervals... 5
for i to n
    tekst$ = Get label of interval... 5 i
    if tekst$ <> ""
       t1 = Get starting point... 5 i
       t2 = Get end point... 5 i
       select pitch
       f0 = Get mean... t1 t2 Hertz
       printline 't1:3' 't2:3' 'f0:0' 'tekst$'
       select textgrid
    endif
endfor
select sound
plus textgrid

Links to this page


© ppgb, November 12, 2005