################################################################################################ ## 批量等比例提取标注文件中前3个共振峰(F1、F2、F3)各10个点的数据。F1、F2、F3的数据分别保存 ## ## 为3个txt文件。此脚本适合于复合元音(二合元音、三合元音)的共振峰提取。 ## ## Written by Qibin Ran. (ranqibin@126.com) ## ## 2019-02-26. ## ################################################################################################ form 等比例提取10个共振峰数据点脚本(适合于做复合元音) comment Where are your wav/TextGridfiles? text openpath C:\Users\ran\Desktop\许可\er\qita 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 10 comment Name of F1、F2、F3 result do you want to save with: text textfile1 F1s.txt text textfile2 F2s.txt text textfile3 F3s.txt endform if left$(openpath$,1)<>"\" openpath$=openpath$+"\" endif Create Strings as file list... fileList 'openpath$'*.TextGrid numberOfFiles=Get number of strings fileappend "'openpath$''textfile1$'" speaker'tab$'vowels'tab$'1'tab$'2'tab$'3'tab$'4'tab$'5'tab$'6'tab$'7'tab$'8'tab$'9'tab$'10'newline$' fileappend "'openpath$''textfile2$'" speaker'tab$'vowels'tab$'1'tab$'2'tab$'3'tab$'4'tab$'5'tab$'6'tab$'7'tab$'8'tab$'9'tab$'10'newline$' fileappend "'openpath$''textfile3$'" speaker'tab$'vowels'tab$'1'tab$'2'tab$'3'tab$'4'tab$'5'tab$'6'tab$'7'tab$'8'tab$'9'tab$'10'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 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 fileappend "'openpath$''textfile1$'" 'simpleName$''tab$''label$''tab$' fileappend "'openpath$''textfile2$'" 'simpleName$''tab$''label$''tab$' fileappend "'openpath$''textfile3$'" 'simpleName$''tab$''label$''tab$' 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 fileappend "'openpath$''textfile1$'" 'f_one:0''tab$' fileappend "'openpath$''textfile2$'" 'f_two:0''tab$' fileappend "'openpath$''textfile3$'" 'f_three:0''tab$' endfor fileappend "'openpath$''textfile1$'" 'newline$' fileappend "'openpath$''textfile2$'" 'newline$' fileappend "'openpath$''textfile3$'" 'newline$' endif endfor select all minus Strings fileList Remove endfor select all Remove exit OK!指定文件夹中的共振峰数据已经提取!