# # Word chomper: This script marks the boundaries between individual # utterances based on the intensity (dB level) at each time. # Author: Joseph Toscano # updated 11-Jan-2008: bug fix from Neil Bardhan. # # Define directory and prepare automatic processing of all files directory$ = "/" clearinfo Create Strings as file list... list 'directory$'*.wav number_of_files = Get number of strings # Preferences: form arguments positive dblevel 50 positive tiernum 1 positive spacing_between_words(s) 0.3 endform clearinfo move_cursor = spacing_between_words / 3 # Open loop for x from 1 to number_of_files select Strings list Sort current_file$ = Get string... x Read from file... 'directory$''current_file$' sound$ = current_file$ - ".wav" # First, we should select the sound and create a textgrid. select Sound 'sound$' To TextGrid... wordseg wordseg select Sound 'sound$' # Store start and finish times. start=Get starting time finish=Get finishing time # Edit the sound. select Sound 'sound$' plus TextGrid 'sound$' Edit # In order to analyze the intensity, we must be viewing at most 10 seconds of time. So, we must # move the window in 10 second increments until we reach the end. # Get into the editor editor TextGrid 'sound$' # The bet_words variable counts the number of consecutive jumps we make between words. bet_words = 1 Select... 0 0 Add interval on tier 1 Move cursor to... 0.1 Show analyses... yes no yes no no 10 # Segment the words. i = 0 repeat Zoom... i i+10 repeat int = Get intensity if int <> undefined and int < dblevel if bet_words = 3 bet_words = bet_words + 1 Add interval on tier 1 else bet_words = bet_words + 1 endif else bet_words = 0 endif Move cursor by... 'move_cursor' cursor = Get cursor if cursor >= finish cursor = i + 10 endif until cursor >= i+10 i = i + 10 cursor = Get cursor until cursor >= finish endeditor select TextGrid 'sound$' numpoints = Get number of points... 1 select Sound 'sound$' Edit for i from 1 to numpoints select TextGrid 'sound$' start = Get time of point... 1 i finish_time = Get finishing time if i = numpoints finish = finish_time else finish = Get time of point... 1 'i'+1 endif editor Sound 'sound$' Select... 'start' 'finish' Extract selection endeditor select Sound untitled Write to WAV file... 'directory$''sound$'-'i'.wav select Sound untitled Remove endfor # close loop endfor