# script extracts frequencies of specified formant at beginning, 1st, 2nd, 3rd quarter, and end of vowel # and F1 and F2 from the middle of the vowel clearinfo # form Get formant frequencies comment Paste the path to the directory where the files are. comment Make sure to paste in front of the back slash. sentence Directory \ comment Leave this value alone. positive Voicing_threshold 0.45 comment Offsets from absolute beginning and end of the file. comment To avoid artifacts, use values of 0.005 real Offset_from_first_marker 0.0 real Offset_from_second_marker 0.0 comment Enter 1 for F1, 2 for F2, or 3 for F3 positive Formant 1 comment Interval across which the formant values are to be averaged positive Mean_interval 0.01 comment Base name of the file you want to store the data in. word Out_base_name file endform # Create name of output file and delete it if it already exists. output_file$=directory$ + out_base_name$ + ".out" printline 'output_file$' filedelete 'output_file$' # Write column heads and front of file fileappend "'output_file$'" File Name 'tab$' Formant 'tab$' Syllable_# 'tab$' Label 'tab$' Begin 'tab$' Midpoint 'tab$' End 'tab$' Duration 'tab$' Begin_F 'tab$' First_Q 'tab$' Midpont 'tab$' Third_Q 'tab$' End_F 'tab$' F1 'tab$' F2 'newline$' fileappend "'output_file$'" 'newline$' printline 'output_file$' Create Strings as file list... list 'directory$'*.wav number_files = Get number of strings for i from 1 to number_files select Strings list current_file$=Get string... 'i' base_name$=current_file$ - ".wav" textgrid_name$=base_name$ + ".TextGrid" # select the sound and measure its formants Read from file... 'directory$''current_file$' sound1$=selected$("Sound") select Sound 'sound1$' To Formant (burg)... 0.005 5 5500 0.025 50 formant1$=selected$("Formant") # get number of intervals Read from file... 'directory$''textgrid_name$' textgrid1$=selected$("TextGrid") select TextGrid 'textgrid1$' n = Get number of intervals... 1 printline 'n' syllable = 1 for j from 1 to n # get an interval's label select TextGrid 'textgrid1$' label$ = Get label of interval... 1 j # check whether an interval is labeled if label$ <> "" # if so, assign times at beginning and end of a labeled interval to variables, calculate duration, and print out values to info window tmin = Get starting point... 1 j begin = tmin + offset_from_first_marker begin_win = begin + mean_interval tmax = Get end point... 1 j end = tmax - offset_from_second_marker end_win = end - mean_interval duration = tmax - tmin print 'label$' 'tmin:3' 'tmax:3' 'duration:3' 'newline$' # calculate locations to get values from first_quarter = tmin + (duration / 4) firstq_beg = first_quarter - mean_interval / 2 firstq_end = first_quarter + mean_interval / 2 midpoint = tmin + (duration / 2) mid_beg = midpoint - mean_interval / 2 mid_end = midpoint + mean_interval / 2 third_quarter = tmin + (3 * duration / 4) thirdq_beg = third_quarter - mean_interval / 2 thirdq_end = third_quarter + mean_interval / 2 syllable += 1 # select the Formant object for the sound and assign values of desired formant at beginning, middle, and end of labeled interval to variables select Formant 'formant1$' formant_begin = Get mean... 'formant' 'begin' 'begin_win' Hertz formant_1stq = Get mean... 'formant' 'firstq_beg' 'firstq_end' Hertz formant_mid = Get mean... 'formant' 'mid_beg' 'mid_end' Hertz formant_3rdq = Get mean... 'formant' 'thirdq_beg' 'thirdq_end' Hertz formant_end = Get mean... 'formant' 'end_win' 'end' Hertz first_formant = Get mean... 1 'mid_beg' 'mid_end' Hertz second_formant = Get mean... 2 'mid_beg' 'mid_end' Hertz # print values to info window and output file printline 'base_name$' 'tab$' 'formant' 'tab$' 'syllable' 'tab$' 'label$' 'tab$' 'begin:3' 'tab$' 'midpoint:3' 'tab$' 'end:3' 'tab$' 'duration:3' 'tab$' 'formant_begin:0' 'tab$' 'formant_1stq:0' 'tab$' 'formant_mid:0' 'tab$' 'formant_3rdq:0' 'tab$' 'formant_end:0' 'tab$' 'first_formant:0' 'tab$' 'second_formant:0' fileappend "'output_file$'" 'base_name$' 'tab$' 'formant' 'tab$' 'syllable' 'tab$' 'label$' 'tab$' 'begin:3' 'tab$' 'midpoint:3' 'tab$' 'end:3' 'tab$' 'duration:3' 'tab$' 'formant_begin:0' 'tab$' 'formant_1stq:0' 'tab$' 'formant_mid:0' 'tab$' 'formant_3rdq:0' 'tab$' 'formant_end:0' 'tab$' 'first_formant:0' 'tab$' 'second_formant:0' 'newline$' endif endfor fileappend "'output_file$'" 'newline$' endfor