################################################################################################# # boundary-aligner.praat (Version 1) # Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Lets you make the 2nd & 4th point tier boudnaries synchronized with the interval boundaries in the 1st tier # Assumes that you have two subdirectories "086.TextGrid-segmented-labeled3" and "087.TextGrid-segmented-labeled4" # Will write modified TextGrid files (with .lab4) into the subfolder "087.TextGrid-segmented-labeled4" ################################################################################################## # Specify files and folders form Select files word textGridFolder_(should_be_a_subfolder) 086.TextGrid-segmented-labeled3 word textGridExt lab3 word textGridDoneFolder_(should_be_a_subfolder) 087.TextGrid-segmented-labeled4 word outputExt lab4 real diffOfTolerance 0.05 real intraIntervalPointTolerance 0.1 endform Create Strings as file list... fileList 'textGridFolder$'\*.'textGridExt$' Sort numFiles = Get number of strings #pause 'numFiles' textgrids were identified. Continue? for iFile to numFiles select Strings fileList # Get the name for each file fullFileName$ = Get string... iFile # Extract the prefix part of the filename prefixName$ = fullFileName$ - textGridExt$ # Read in the file Read from file... 'textGridFolder$'\'fullFileName$' Rename... textGrid Insert point tier... 2 phonology2 Insert point tier... 5 break-index2 numIntervals = Get number of intervals... 1 numPointsPhono = Get number of points... 3 numPointsBI = Get number of points... 6 startTimeOfInterval = 0 for iPointWord to numIntervals endTimeOfInterval = Get end point... 1 iPointWord for iPointPhono to numPointsPhono timeOfPointPhono = Get time of point... 3 iPointPhono pointTextPhono$ = Get label of point... 3 iPointPhono interTierDiffPhono = abs(endTimeOfInterval - timeOfPointPhono) if (interTierDiffPhono < diffOfTolerance) or (interTierDiffPhono = 0) Insert point... 2 endTimeOfInterval 'pointTextPhono$' # elsif (interTierDiffPhono > intraIntervalPointTolerance) and (interTierDiffPhono < 0) # ...and (timeOfPointPhono > startTimeOfInterval) and (timeOfPointPhono < endTimeOfInterval) # Insert point... 2 timeOfPointPhono 'pointTextPhono$' endif endfor for iPointBI to numPointsBI timeOfPointBI = Get time of point... 6 iPointBI pointTextBI$ = Get label of point... 6 iPointBI interTierDiffBI = abs(endTimeOfInterval - timeOfPointBI) if (interTierDiffBI < diffOfTolerance) or (interTierDiffBI = 0) Insert point... 5 endTimeOfInterval 'pointTextBI$' # elsif (interTierDiffBI > intraIntervalPointTolerance) and (interTierDiffBI < 0) # ...and (timeOfPointBI > startTimeOfInterval) and (timeOfPointBI < endTimeOfInterval) # Insert point... 5 timeOfPointBI 'pointTextBI$' endif endfor startTimeOfInterval = endTimeOfInterval endfor Edit editor TextGrid textGrid pause Check the modified textgrid. Continue and save? Close # Save the modified TextGrid file in a different folder with .done suffix attached select TextGrid textGrid Remove tier... 6 Remove tier... 3 Edit pause Verify before saving Write to text file... 'textGridDoneFolder$'\'prefixName$''outputExt$' Remove endfor