form Calculate intensitys of labeled segments comment Where are your wav/TextGrid/Intensity files? text openpath 请在此输入存储声音及相关文件的地址 comment Which tier of the TextGrid object would you like to analyse? integer Tier 1 comment How many intensity point numbers would you like to extract? integer pointnum 30 comment Where do you want to save the results? text textfile output.csv endform if left$(openpath$,1)<>"\" openpath$=openpath$+"\" endif Create Strings as file list... fileList 'openpath$'*.TextGrid numberOfFiles=Get number of strings filedelete 'textfile$' fileappend "'textfile$'" label,duration,intensity1-30,'newline$' for ifile from 1 to numberOfFiles select Strings fileList fileName$=Get string... 'ifile' simpleName$=fileName$-".TextGrid" wavName$=simpleName$+".wav" intensityName$=simpleName$+".Intensity" Read from file... 'openpath$''intensityName$' select Intensity 'simpleName$' Down to IntensityTier 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 fileappend "'textfile$'" 'label$','duration', select IntensityTier 'simpleName$' stepnum=pointnum-1 tempstep=duration/stepnum for ii from 0 to stepnum tempTime=start+tempstep*ii tempValue=Get value at time... 'tempTime' tempValue='tempValue:0' fileappend "'textfile$'" 'tempValue', endfor fileappend "'textfile$'" 'newline$' # append the label and the duration to the end of the text file, separated with a tab: #resultline$ = "'label$' 'duration''newline$'" #fileappend "'textfile$'" 'resultline$' endif endfor select Intensity 'simpleName$' plus IntensityTier 'simpleName$' Remove select Sound 'simpleName$' plus TextGrid 'simpleName$' Remove endfor exit over!