######################################### ### Band energy querying to label, based on script ### written by Mary Beckman ### E-mail: kyoon@ling.osu.edu ### 9-2-2001 3:21AM ######################################### tempOut$ = "tempOut" filedelete 'tempOut$' form Select a file and parameters for band energy ratio change word soundFile_(without_extension) ASP_01_shata_ISO word outputFile bandEnergyRatioChange8.result positive dividingFrequency_(Hz) 5500 positive criterionRatio 0.05 positive maxFrequency_(Hz) 11025 word windowShape Hamming positive timeStep_(in_sec.e.g._every_5_ms) 0.005 endform Read from file... 'soundFile$'.wav Read from file... 'soundFile$'.TextGrid fileappend 'outputFile$' 'soundFile$' 'noiseBegin' 'noiseEnd' 'dividingFrequency' 'newline$' numFric = 0 numAsp =0 numVowel =0 # Examine the label file to see what points have been set select TextGrid 'soundFile$' numLabels = Get number of points... 1 for i from 1 to 'numLabels' label$ = Get label of point... 1 'i' if label$ = "fricative" numFric = 'i' noiseBegin = Get time of point... 1 'numFric' elsif label$ = "aspiration" numAsp = 'i' timeAsp = Get time of point... 1 'i' elsif label$ = "vowel" numVowel = 'i' noiseEnd = Get time of point... 1 'numVowel' endif endfor # Determine start and end of noise segment in sound editor if not set already if 'numFric' = 0 select Sound 'soundFile$' Edit editor Sound 'soundFile$' pause Click START of noise segment noiseBegin = Get cursor Close endeditor # and write a label there select TextGrid 'soundFile$' Insert point... 1 'noiseBegin' fricative Write to text file... 'soundFile$'.TextGrid endif # Determine end of noise segment in sound editor if not set already if 'numVowel' = 0 select Sound 'soundFile$' Edit editor Sound 'soundFile$' pause Click approximate END of noise segment for zooming tempEnd = Get cursor Select... -0.05+'tempEnd' 0.05+'tempEnd' Zoom... -0.05+'tempEnd' 0.05+'tempEnd' pause Click nearest zero crossing of vowel onset Move cursor to nearest zero crossing noiseEnd = Get cursor endeditor # and write a label there select TextGrid 'soundFile$' Insert point... 1 'noiseEnd' vowel Write to text file... 'soundFile$'.TextGrid endif # Check to see if Aspiration is set already, and if it is, delete it if 'numAsp' > 0 select TextGrid 'soundFile$' Edit editor TextGrid 'soundFile$' Move cursor to... 'timeAsp' Remove Close endeditor endif # Extract successive windowed selections, make spectra, calculate band energy ratio specNum = 0 repeat select Sound 'soundFile$' Edit editor Sound 'soundFile$' specBegin = noiseBegin + timeStep * specNum specEnd = specBegin + timeStep Select... 'specBegin' 'specEnd' Extract windowed selection... slice 'windowShape$' 1 yes Close endeditor # Band energy querying across dividing frequency To Spectrum lowBandEnergy = Get band energy... 0 'dividingFrequency' highBandEnergy = Get band energy... 'dividingFrequency' 'maxFrequency' ratio = highBandEnergy / lowBandEnergy fileappend 'outputFile$' 'specBegin:4' 'tab$' 'ratio:4' 'newline$' fileappend 'tempOut$' 'specBegin:4' 'tab$' 'ratio:4' 'newline$' select Sound slice Remove select Spectrum slice Remove specNum = specNum + 1 # Stop if windowed selection crosses over end of noise segment until (specBegin > noiseEnd - timeStep) # Read in the values from the temporary output file and determine point # where criterion ratio has been reached Read Matrix from raw text file... 'tempOut$' sliceNum = 1 repeat sliceNum = sliceNum + 1 sliceTime = Get value in cell... 'sliceNum' 1 sliceRatio = Get value in cell... 'sliceNum' 2 until (sliceRatio <= criterionRatio) # Write a label there select TextGrid 'soundFile$' Insert point... 1 'sliceTime' aspiration Write to text file... 'soundFile$'.TextGrid select Sound 'soundFile$' plus TextGrid 'soundFile$' Edit pause Go ahead and clean all objects? # Clean up select Sound 'soundFile$' Remove select TextGrid 'soundFile$' Remove select Matrix 'tempOut$' Remove ### END OF SCRIPT ###