## This script is adapted from Catherine Crosswhite's webpage and modified by Taehong Cho. ## It extracts ## (1) the beginning and the end of the interval ## (2) the duration of all intervals marked in tier 1 with non-null lables. Durations, in milliseconds ## (3) the peak intensity during each labelled interval (max_dB) ## (4) the minimum intensity during each labelled interval (min_dB) ## (5) the mean intensity during each labelled interval (mean_dB) ## they will be written to a log file called "duration_intensity-log.txt", which you will be able to find in the same directory ## holding your sound files after you run the script. One can of course change the name of the log file. ## To run this script, you will have to have a bunch of sound files with accompanying text grids in the same directory. ## The locations of things to be measured must be marked in tier 1 of the textgrid. ## Anything with a non-null label in that tier will be logged. ## But you can also specify a label by changing <>"" to = [label name] in the part {if interval_label$ <> ""}. ###End of description ## Specify the directory containing your sound files in the next line: directory$ = "U:\" ## Specify the directory containing your sound files in the next line: directory$ = "U:\PROJECT\Korean_cluster\Brain_Language\target_files\" filedelete 'directory$'duration_intensity-log.txt header_row$ = "Filename" + tab$ + "phoneme" + tab$ + "Begin" + tab$ + "End" + tab$ + "Duration (ms.)" + tab$ + "max_dB" + tab$ + "min_dB" + "mean_dB" + tab$ + newline$ header_row$ > 'directory$'duration_intensity-log.txt ## Now we make a list of all the text grids in the directory we're using, and put the number of ## filenames into the variable "number_of_files": Create Strings as file list... list 'directory$'*.wav number_files = Get number of strings for j from 1 to number_files select Strings list current_token$ = Get string... 'j' Read from file... 'directory$''current_token$' object_name$ = selected$ ("Sound") select Sound 'object_name$' To Intensity... 50 0 Read from file... 'directory$''object_name$'.TextGrid select TextGrid 'object_name$' number_of_intervals = Get number of intervals... 1 for b from 1 to number_of_intervals select TextGrid 'object_name$' interval_label$ = Get label of interval... 1 'b' if interval_label$ <> "" begin_vowel = Get starting point... 1 'b' end_vowel = Get end point... 1 'b' duration = (end_vowel - begin_vowel) * 1000 select Intensity 'object_name$' max_dB = Get maximum... begin_vowel end_vowel Parabolic min_dB = Get minimum... begin_vowel end_vowel Parabolic mean_dB = Get mean... begin_vowel end_vowel fileappend "'directory$'duration_intensity-log.txt" 'object_name$''tab$''interval_label$''tab$''begin_vowel:5''tab$''end_vowel:5''tab$''duration:2''tab$''max_dB:2''tab$''min_dB:2''tab$''mean_dB:2''tab$''newline$' endif endfor # By this point, we have gone through all the intervals for the current # textgrid, and written all the appropriate values to our log file. We are now ready to go on to # the next file, so we can get rid of any objects we no longer need, and end our for loop select all minus Strings list Remove endfor # And at the end, a little bit of clean up and a message to let you know that it's all done. select all Remove clearinfo print All files have been processed. What next? ## written by Katherine Crosswhite & modified by Taehong Cho