############################################################################### # measureIntervalDuration.praat (Written by Kyuchul Yoon, kyoon@kyungnam.ac.kr) # Pops each sound file in a folder, asking the user to select a region. # The script then measures the duration of the highlighted region, stores the # information in a log file, and creates a textgrid file containing the # time stamp information about the highlighted region. ############################################################################### form Specify parameters word inputFolder_(containing_the_sound_files) wavFolder word fileExtension_(with_dot) .wav word logFileName_(for_storing_duration_measurements) logOfDuration.txt comment A textgrid will be created for each sound file. comment It will have the information about the selected region. endform # Print header information of the log file. fileappend 'logFileName$' fileName'tab$'start'tab$'end'tab$'duration'newline$' # Make a list of all files in the folder. Create Strings as file list... fileListObj 'inputFolder$'/*'fileExtension$' numFiles = Get number of strings pause 'numFiles' sound files identified. Continue? # Loop through each file. for iFile to numFiles select Strings fileListObj fileName$ = Get string... iFile prefix$ = fileName$ - fileExtension$ textgridName$ = prefix$ + ".TextGrid" Read from file... 'inputFolder$'/'fileName$' Rename... soundObj # Create a textgrid file with one tier to store information # about where you highlighted. totalDuration = Get total duration To TextGrid... duration Rename... textgridObj # In the editor window, select and measure. select Sound soundObj Edit pause Select a region to measure duration! editor Sound soundObj start = Get start of selection end = Get end of selection duration = end - start endeditor # Write the information to the log file. fileappend 'logFileName$' 'fileName$''tab$''start''tab$''end''tab$''duration' ...'newline$' # Write that same info to the textgrid file. select TextGrid textgridObj Insert boundary... 1 start Insert boundary... 1 end Set interval text... 1 2 You highlighted here! Write to text file... 'inputFolder$'/'textgridName$' select Sound soundObj plus TextGrid textgridObj Remove endfor select Strings fileListObj Remove ############## END OF SCRIPT #################