####### Gregory Anderson, GMU Arch Lab - This script reads wave files in ####### pairs and creates a text file with duration, max dB, and 45-bin ####### LTAS spectrum data. It's actually a many-times modified version of a script ####### I downloaded from somewhere else on the web. form Directories and Parameters sentence Subject S sentence Sound_file_extension .wav positive Total_bins 45 endform bin_size = 13500/total_bins ########### Create text file for spectrum data - be sure to put in your own ########### directory information here. I left mine in so you could see how it ########### works for a Mac resultfile$ = "/Volumes/SpeechData/TextFiles/" + subject$ + "Uber.txt" ########### Here, you make a listing of all the sound files in a directory. sound_directory$ = "/Volumes/SpeechData/AudioFiles/" + subject$ + "/" Create Strings as file list... list 'sound_directory$'*'sound_file_extension$' numberOfFiles = Get number of strings ########### Check if the result file exists: if fileReadable (resultfile$) pause The result file 'resultfile$' already exists! Do you want to overwrite it? filedelete 'resultfile$' endif ########### Go through all the sound files, one by one: for ifile to numberOfFiles filename$ = Get string... ifile Read from file... 'sound_directory$''filename$' ########### Get Duration and Intensity Values soundname$ = selected$ ("Sound", 1) select Sound 'soundname$' To Intensity... 500 0.008 no endtime = Get finishing time n=Get number of frames for i to n intensity = Get value in frame... i if intensity > 50 starttime = Get time from frame... i n = i endif endfor dBmin = Get minimum... 'starttime' 'endtime' Parabolic dBmax = Get maximum... 0 0 Parabolic dBmed = Get quantile... 0 0 0.5 adjduration = 'endtime' - 'starttime' dBrange = 'dBmax' - 'dBmin' ########### Save result to text file: resultline$ = "'endtime' 'dBmax' " fileappend "'resultfile$'" 'resultline$' ########### Get Spectrum Values and add to text file soundname$ = selected$ ("Sound", 1) select Sound 'soundname$' To Ltas... bin_size To Matrix select Matrix 'soundname$' for i to total_bins columnvalue = Get value in cell... 1 'i' resultline$ = "'columnvalue' " fileappend "'resultfile$'" 'resultline$' endfor ########### Remove the temporary objects from the object list select Sound 'soundname$' plus Intensity 'soundname$' plus Matrix 'soundname$' Remove ############# Read 2nd File "ket" select Strings list ifile = ifile+1 filename$ = Get string... ifile Read from file... 'sound_directory$''filename$' ########### Get Duration and Intensity Values soundname$ = selected$ ("Sound", 1) select Sound 'soundname$' To Intensity... 500 0.008 no endtime = Get finishing time n=Get number of frames for i to n intensity = Get value in frame... i if intensity > 50 starttime = Get time from frame... i n = i endif endfor dBmin = Get minimum... 'starttime' 'endtime' Parabolic dBmax = Get maximum... 0 0 Parabolic dBmed = Get quantile... 0 0 0.5 adjduration = 'endtime' - 'starttime' dBrange = 'dBmax' - 'dBmin' ########### Save result to text file: resultline$ = "'endtime' 'dBmax' " fileappend "'resultfile$'" 'resultline$' ############# repeated for every sound file that was opened: soundname$ = selected$ ("Sound", 1) To Ltas... bin_size To Matrix select Matrix 'soundname$' for j to total_bins columnvalue = Get value in cell... 1 'j' resultline$ = "'columnvalue' " fileappend "'resultfile$'" 'resultline$' endfor ########### Save CR resultline$ = "'newline$'" fileappend "'resultfile$'" 'resultline$' ########### Remove the temporary objects from the object list select Sound 'soundname$' plus Intensity 'soundname$' plus Ltas 'soundname$' plus Matrix 'soundname$' Remove select Strings list ########### and go on with the next sound file! endfor Remove