################################################################################################# # actual-TextGrid-creator3.praat # Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Lets you create the actual TextGrid file by moving around the boundaries created # in the default TextGrid files with the script "default-TextGrid-creator.praat" # Assumes that you have three subdirectories "01.recording-original", "07.TextGrid-segmented" and "08.TextGrid-segmentedl-labeled" # Will write modified TextGrid files into the subfolder "08..." # After the user modifies the default TextGrid files, the script will prompt the user to # verify his/her modification and write to new files. # Version 4: Puts another set of tiers (ones with POS and # word boundary info) to the existing tiers ################################################################################################## # Specify files and folders form Select files word longSoundFolder_(should_be_a_subfolder) 01.recording-original word longSoundFile_(without_extension) ejk word textGridFolder_(should_be_a_subfolder) 07.TextGrid-segmented word textGridName ejk-001.TextGrid.seg word textGridDoneFolder_(should_be_a_subfolder) 08.TextGrid-segmented-labeled word romFilesSubFolder 05.csplit-rom word romFile_(without_extension) ejk-001 integer factorOfDistance 5 endform Open long sound file... 'longSoundFolder$'\'longSoundFile$'.wav Read from file... 'textGridFolder$'\'textGridName$' Rename... textGrid lengthSubPart = Get duration start = Get starting time end = Get finishing time # Insert a set of new labeling tiers Insert interval tier... 1 word2 Insert point tier... 2 phonology2 Insert point tier... 3 phonetics2 Insert point tier... 4 break-index2 Insert interval tier... 5 misc2 # Get the number of strings (newline-separated eojeols) and create interval tiers Read Strings from raw text file... 'romFilesSubFolder$'\'romFile$'.rom Rename... rom numEojeols = Get number of strings # Insert an interval tier select TextGrid textGrid for i from 1 to (numEojeols+1) # Place eojeols back by the factorOfDistance so moving points may be easy pseudoStart = start + lengthSubPart/factorOfDistance pseudoLengthSubPart = lengthSubPart * (1 - 1/factorOfDistance) nthBoundary = pseudoStart + (pseudoLengthSubPart/(numEojeols+2))*i Insert boundary... 1 'nthBoundary' endfor # and set texts for each interval numIntervals = Get number of intervals... 1 # The first and last interval will be Set interval text... 1 1 Set interval text... 1 numIntervals # Set the rest of the intervals for i from 2 to numIntervals-1 select Strings rom eojeolFromRom$ = Get string... 'i'-1 select TextGrid textGrid Set interval text... 1 'i' 'eojeolFromRom$' endfor # Create as many tiers as you want: For break index numEojeols = numEojeols + 1 breakTime = Get end point... 1 1 Insert point... 4 breakTime # Loop through the eojeols in the word tier inserting a break index with BI value "2" after each one for i from 2 to numEojeols breakTime = Get end point... 1 i intText$ = Get label of interval... 1 i rightIntText$ = right$(intText$,1) if rightIntText$ = "#" Insert point... 4 breakTime 2 endif endfor # For phonology tier for i from 2 to (numEojeols - 1) pointTime = Get end point... 1 i intText$ = Get label of interval... 1 i rightIntText$ = right$(intText$,1) if rightIntText$ = "#" Insert point... 2 pointTime LHa endif endfor # The last boundary gets L% boundary tone pointTime = Get end point... 1 numEojeols Insert point... 2 pointTime L% # Save the TextGrid file select TextGrid textGrid # If an old file exists, delete it first and then write # filedelete 'textGridDoneFolder$'\'romFile$'.TextGrid.seg.lab Write to text file... 'textGridDoneFolder$'\'romFile$'.TextGrid.seg.lab # Select the long sound file and a TextGrid for editing select LongSound 'longSoundFile$' plus TextGrid textGrid Edit # Give users a note before writing to another folder pause Click when done pause TextGrid to be written as .done in TextGridDone folder # Save the modified TextGrid file in a different folder with .done suffix attached select TextGrid textGrid Write to text file... 'textGridDoneFolder$'\'textGridName$'.lab Remove # Read in the TextGrid file just saved and present it for verification Read from file... 'textGridDoneFolder$'\'textGridName$'.lab plus LongSound 'longSoundFile$' Edit pause Verify the TextGrid that you just wrote select LongSound 'longSoundFile$' Remove select Strings rom Remove