form Track formant of labeled segments comment Where are your wav/TextGrid files? text openpath 请在此输入声音文件与标注文件存储的地址 comment Which tier of the TextGrid object would you like to analyse? integer Tier 1 comment Enter speaker gender (m or f only) sentence Gender f comment How many formant numbers would you like to extract? integer pointnum 11 comment Name of result do you want to save with: text excelfile Formantoutput.xls endform if left$(openpath$,1)<>"\" openpath$=openpath$+"\" endif Create Strings as file list... fileList 'openpath$'*.TextGrid numberOfFiles=Get number of strings filedelete 'Formantoutput$' fileappend "'openpath$'Formantoutput.xls" dialect'tab$'label'tab$'F1'tab$'F2'tab$'F3'tab$'F0'tab$'duration'newline$' for ifile from 1 to numberOfFiles select Strings fileList fileName$=Get string... 'ifile' simpleName$=fileName$-".TextGrid" wavName$=simpleName$+".wav" Read from file... 'openpath$''wavName$' if gender$ = "f" To Formant (burg)... 0.0025 5 5500 0.025 50 else To Formant (burg)... 0.0025 5 5000 0.025 50 endif select Sound 'simpleName$' To Pitch... 0.01 75 600 Read from file... 'openpath$''wavName$' Read from file... 'openpath$''fileName$' numberOfIntervals = Get number of intervals... tier for interval from 1 to numberOfIntervals select TextGrid 'simpleName$' label$ = Get label of interval... tier interval # if the interval has some text as a label, then calculate the duration. if label$ <> "" start = Get starting point... tier interval end = Get end point... tier interval duration = end - start select Formant 'simpleName$' stepnum=pointnum-1 tempstep=duration/stepnum for ii from 0 to stepnum tempTime=start+tempstep*ii select Formant 'simpleName$' f_one = Get value at time... 1 'tempTime' Hertz Linear f_two = Get value at time... 2 'tempTime' Hertz Linear f_three = Get value at time... 3 'tempTime' Hertz Linear select Pitch 'simpleName$' f_zero = Get value at time... 'tempTime' Hertz Linear duration = (end - start) * 1000 fileappend "'openpath$'Formantoutput.xls" 'simpleName$''tab$''label$''tab$''f_one:0''tab$''f_two:0''tab$''f_three:0''tab$''f_zero:0''tab$''duration:3''newline$' endfor endif endfor endfor select all Remove exit OK!