################################################################################################# # actual-TextGrid-creator7.praat (Version 7) # Will insert default label points to phonetics tier depending on the number of syllables and the type of first segments of each # syllable in a default AP. # Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Lets you create the actual TextGrid file by moving around the boundaries created # in the 075.TextGrid-segmented2 folder # Assumes that you have two subdirectories "075.TextGrid-segmented2" and "08.TextGrid-segmented-labeled" # Will write modified TextGrid files (with .lab) into the subfolder "08.TextGrid-segmented-labeled" # Version 7 will be sensitive to the first segment of each token inserting either H or L depending on the specification ################################################################################################## # Specify files and folders form Select files word longSoundFolder_(should_be_a_subfolder) 01.recording-original word longSoundFile_(without_extension) ejk-151 word textGridFolder_(should_be_a_subfolder) 075.TextGrid-segmented2 word textGridName ejk-141.TextGrid.seg2 word textGridDoneFolder_(should_be_a_subfolder) 08.TextGrid-segmented-labeled endform Open long sound file... 'longSoundFolder$'\'longSoundFile$'.wav Read from file... 'textGridFolder$'\'textGridName$' Remove tier... 10 Remove tier... 9 Remove tier... 8 Remove tier... 7 Remove tier... 6 Rename... textGrid outFilePrefix$ = textGridName$ - ".seg2" ##################### Insert default label points to phonetics tier ##################### # Get the number of points in the phonetics tier numOfPoints = Get number of points... 2 # Get starting time of the phonetics tier prevTimeOfPoint = Get starting time # For each point in the phonetics tier for i to numOfPoints # Get the time of each point in phonetics tier curTimeOfPoint = Get time of point... 2 i # Get the interval number (phonology tier) intervalAtCurTime = Get interval at time... 1 curTimeOfPoint intervalAtPrevTime = Get interval at time... 1 prevTimeOfPoint # Count the number of intervals (phonology tier) between two successive points (phonetics tier) numOfRepetition = intervalAtCurTime - intervalAtPrevTime # Initialize the number of syllables to zero numOfSyl = 0 ######### Identify the first letter of the token ######## textOfInterval$ = Get label of interval... 1 intervalAtPrevTime firstLetter$ = left$(textOfInterval$, 1) # For each interval between two successive points (phonetics tier) for k from 0 to (numOfRepetition-1) iPoint = intervalAtPrevTime + k # Get the interval text (including POS) posLabOfInterval$ = Get label of interval... 1 iPoint # Identify the location of / locOfSlash = index(posLabOfInterval$, "/") # and take the text before the slash if locOfSlash > 0 labOfInterval$ = left$(posLabOfInterval$, (locOfSlash-1)) else labOfInterval$ = posLabOfInterval$ endif countOfSyl = 1 # Count the number of syllables within each interval by counting the number of hyphens while (index(labOfInterval$, "-")) totLen = length(labOfInterval$) countOfSyl = countOfSyl + 1 iHyphen = index(labOfInterval$, "-") numSylToExtract = totLen - iHyphen labOfInterval$ = right$(labOfInterval$, numSylToExtract) endwhile # Get the number of total syllables numOfSyl = numOfSyl + countOfSyl endfor # Get the interval length for the two successive points (phonetics tier) intervalLen = curTimeOfPoint - prevTimeOfPoint # If there's only one syllable if numOfSyl = 1 amountOfIncrease = intervalLen/2 pointOne = prevTimeOfPoint + amountOfIncrease Insert point... 3 pointOne Ha elsif numOfSyl = 2 amountOfIncrease = intervalLen/3 pointOne = prevTimeOfPoint + amountOfIncrease pointTwo = prevTimeOfPoint + amountOfIncrease*2 ######## Depending on the firstLetter$ ######## if (firstLetter$ = "s" or firstLetter$ = "c" or firstLetter$ = "p" or firstLetter$ = "t" or firstLetter$ = "k" ... or firstLetter$ = "ss" or firstLetter$ = "jj" or firstLetter$ = "h") Insert point... 3 pointOne H else Insert point... 3 pointOne L endif Insert point... 3 pointTwo Ha elsif numOfSyl = 3 amountOfIncrease = intervalLen/4 pointOne = prevTimeOfPoint + amountOfIncrease pointTwo = prevTimeOfPoint + amountOfIncrease*2 pointThree = prevTimeOfPoint + amountOfIncrease*3 ######## Depending on the firstLetter$ ######## if (firstLetter$ = "s" or firstLetter$ = "c" or firstLetter$ = "p" or firstLetter$ = "t" or firstLetter$ = "k" ... or firstLetter$ = "ss" or firstLetter$ = "jj" or firstLetter$ = "h") Insert point... 3 pointOne H else Insert point... 3 pointOne L endif Insert point... 3 pointTwo +H Insert point... 3 pointThree Ha # If there are four or more syllables else amountOfIncrease = intervalLen/5 pointOne = prevTimeOfPoint + amountOfIncrease pointTwo = prevTimeOfPoint + amountOfIncrease*2 pointThree = prevTimeOfPoint + amountOfIncrease*3 pointFour = prevTimeOfPoint + amountOfIncrease*4 ######## Depending on the firstLetter$ ######## if (firstLetter$ = "s" or firstLetter$ = "c" or firstLetter$ = "p" or firstLetter$ = "t" or firstLetter$ = "k" ... or firstLetter$ = "ss" or firstLetter$ = "jj" or firstLetter$ = "h") Insert point... 3 pointOne H else Insert point... 3 pointOne L endif Insert point... 3 pointTwo +H Insert point... 3 pointThree L+ Insert point... 3 pointFour Ha endif # Set the time of the current point to previous prevTimeOfPoint = curTimeOfPoint endfor ##################### End of inserting to phonetics tier ########################### # Select the long sound file and a TextGrid for editing select LongSound 'longSoundFile$' plus TextGrid textGrid Edit #editor TextGrid textGrid # Select... 0 2.6 #endeditor # Give users a note before writing to another folder #pause Click when done pause TextGrid to be written as .lab in 08.TextGrid-segmented-labeled # Save the modified TextGrid file in a different folder with .done suffix attached select TextGrid textGrid Write to text file... 'textGridDoneFolder$'\'outFilePrefix$'.lab Remove # Read in the TextGrid file just saved and present it for verification Read from file... 'textGridDoneFolder$'\'outFilePrefix$'.lab plus LongSound 'longSoundFile$' Edit pause Verify the TextGrid that you just wrote select LongSound 'longSoundFile$' Remove