########################### ### Formant measurement ### written by Kyuchul Yoon 2-8-2002 ### kyoon@ling.osu.edu ########################### form Input directory name without final slash word dirName lees\convers1\f1\Formant word outFile fmt-le-c1f1.txt endform filedelete 'outFile$' # parameters to Burg formant extraction timeStep = 0.005 maxNumFormants = 5 windLength= 0.025 preEmphFrom = 50 # print headers fileappend 'outFile$' ... filename'tab$' ... convType'tab$' ... subject'tab$' ... fricType'tab$' ... repNum'tab$' ... prosLoc'tab$' for a to 6 for b to 3 fileappend 'outFile$' ... frame'a'_F'b''tab$' endfor endfor fileappend 'outFile$' 'newline$' # read in all files in the directory 'dirName$' Create Strings as file list... list 'dirName$'\*.wav numFiles = Get number of strings for iFile to numFiles select Strings list fullFileName$ = Get string... iFile # extract token categories from filename conTypeI = index(dirName$, "convers") conType$ = mid$(dirName$, conTypeI, 8) fricType$ = left$(fullFileName$, 2) subjName$ = mid$(fullFileName$, 4, 2) repNum$ = mid$(fullFileName$, 7, 1) prosLoc$ = mid$(fullFileName$, 9, 3) sexType$ = mid$(fullFileName$, 4, 1) ####### Maximum formant needs to be adjusted by sex -- if sexType$ = "f" maxFormant = 5500 else maxFormant = 5000 endif fileName$ = fullFileName$ - ".wav" Read from file... 'dirName$'\'fileName$'.TextGrid # locate vowel onset & offset vowelBegin = Get time of point... 1 3 Read from file... 'dirName$'\'fileName$'.wav ####### Burg algorithm : Applies a Gaussian-like window and computes LPC coefficients ####### Actual window length is twice the windLength$ ####### # extract formants 1 ~ 3 for the first seven frames every 5 ms To Formant (burg)... timeStep maxNumFormants maxFormant windLength preEmphFrom fileappend 'outFile$' 'fileName$''tab$' ... 'conType$''tab$' ... 'subjName$''tab$' ... 'fricType$''tab$' ... 'repNum$''tab$' ... 'prosLoc$''tab$' for i from 1 to 6 timeFrame = vowelBegin + (i-1) * timeStep for k from 1 to 3 formantVal = Get value at time... k timeFrame Hertz Linear fileappend 'outFile$' ... 'formantVal:0''tab$' endfor endfor fileappend 'outFile$' 'newline$' select Sound 'fileName$' plus TextGrid 'fileName$' plus Formant 'fileName$' Remove endfor select Strings list Remove