form output filename
sentence output result.txt
endform
sound$ = Read from file: "sound/dhl_part.wav"
textgrid$ = Read from file: "sound/dhl_part.TextGrid"
selectObject: "Sound dhl_part"
To Intensity: 100, 0.0, 1
selectObject: "TextGrid dhl_part"
num_intervals = Get number of intervals... 2
writeInfoLine: "phone",tab$,"word",tab$,"dB"
writeFileLine: output$, "phone",tab$,"word",tab$,"dB"
for i from 1 to num_intervals
phone$ = Get label of interval: 2, i
if phone$ == "ae" or phone$ == "ei"
... or phone$ == "eh" or phone$ == "iy"
startTime = Get start point: 2, i
endTime = Get end point: 2, i
midTime = startTime + (endTime - startTime)/2
phone_duration = (endTime - startTime)*1000
word_index = Get interval at time: 1, midTime
word$ = Get label of interval: 1, word_index
word_start = Get starting point: 1, word_index
word_end = Get end point: 1, word_index
word_duration = (word_end - word_start)*1000
appendInfo: phone$,tab$,word$,tab$
appendFile: output$, phone$,tab$,word$,tab$
selectObject: "Intensity dhl_part"
dB = Get mean: startTime, endTime, "dB"
appendInfoLine: fixed$(dB,2)
appendFileLine: output$, fixed$(dB,2)
selectObject: "TextGrid dhl_part"
endif
endfor