# This script takes the set of TextGrid files in a folder and get the durations of named intervals for each TextGrid files. # It writes all the interval measure of each file per line in a tab-delimited text file. # This script is based on the script originally written by Mietta Lennes, and revised by Shigeto Kawahara. # version 4/7/2009 # ask the user for the tier number form Calculate durations of labeled segments sentence Directory /Users/shigetokawahara/Documents/phonology/parentheticals/2009/data/Speaker G1 K/choped/ comment Which tier of the TextGrid object would you like to analyse? integer Tier 1 comment Where do you want to save the results? text textfile durations.txt endform clearinfo #get the number of TextGrid files for looping Create Strings as file list... list 'directory$'/*.TextGrid select Strings list ns = Get number of strings for i to ns select Strings list gridname$ = Get string... i Read from file... 'directory$'/'gridname$' endfor #get the name of each file for i to ns select Strings list gridname$ = Get string... i name$ = gridname$ - ".TextGrid" Read from file... 'directory$'/'gridname$' select TextGrid 'name$' # check how many intervals there are in the selected tier: numberOfIntervals = Get number of intervals... tier # loop through all the intervals for interval from 1 to numberOfIntervals label$ = Get label of interval... tier interval # if the interval has some text as a label, then calculate the duration. if label$ <> "" start = Get starting point... tier interval end = Get end point... tier interval duration = end - start # append the label and the duration to the end of the text file, separated with a tab: resultline$ = "'name$''tab$''label$''tab$''duration''tab$'" fileappend "'textfile$'" 'resultline$' endif endfor #start a new line fileappend durations.txt 'newline$' endfor select all minus Strings list Remove