# Utterance chomper. Adapted from... # # 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. # # Modified 10/1/2008 to chomp phrase-level utterances using pitch rather than decibles # Heidi B. Kent San Jose State University; heidi.kent@gmail.com # Preferences: form arguments # HB Change to pitch rather than decible values. positive pitchlevel 100 # positive dblevel 50 # /HB positive tiernum 1 # HB comment Leave filename blank to segment selected sound word File # /HB word Output_Directory # HB adjust blank space (no pitch or low pitch) positive spacing_between_words(s) 0.35 # positive spacing_between_words(s) 0.3 # /HB endform move_cursor = spacing_between_words / 3 # HB Let user simply use currently selected sound rather than file. if file$ <> "" Read from file... 'file$' endif # /HB current_sound$ = selected$("Sound") # First, we should select the sound and create a textgrid. select Sound 'current_sound$' To TextGrid... wordseg wordseg select Sound 'current_sound$' # Store start and finish times. start=Get starting time finish=Get finishing time # Edit the sound. select Sound 'current_sound$' plus TextGrid 'current_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 'current_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 # HB changed to add Show pitch (second yes) Show analyses... yes yes yes no no 10 # /HB # Segment the words. i = 0 repeat Zoom... i i+10 repeat # HB use pitch not intensity int = Get pitch # int = Get intensity # HB also allow int to be undefined (no one talking) # if int <> undefined and int < dblevel if int = undefined or int < pitchlevel # /HB 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 'current_sound$' numpoints = Get number of points... 1 select Sound 'current_sound$' Edit for i from 1 to numpoints select TextGrid 'current_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 'current_sound$' Select... 'start' 'finish' Extract selection endeditor select Sound untitled Write to WAV file... 'output_Directory$''current_sound$'-'i'.wav select Sound untitled Rename... ''current_sound$'-'i' # HB Leave files up where I can see them. # Remove # /HB endfor