##################################################################################### # TextGrid preparation script: Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Help from Mary Beckman ( mbeckman@ling.osu.edu ) with inserting break index tier, etc. # Script should be in the parent directory where 30[23]00[024].txt/ folders belong. # Two subdirectories should be csplit-rom/ and TextGrids/. # The script assumes that you already have the romanized files for hangul sentences. # The romanized files should contain romanized eojeols that are "carriage-return"-separated. # The script will read in all the .rom files one by one from csplit-rom/ directory # and write default TextGrid files into TextGrids/ directory. # The filename of the output TextGrid files are ...rom.TextGrid ##################################################################################### # Eojeols in word tier will be placed in the right side of the TextGrid depending on the factorOfDistance # so that moving boundaries (Shift + Dragging) may be easy later on in another script # If factorOfDistance is 2, eojeols will be in the right half of TextGrid. If 3, in the right two thirds. If 5, in the right four fifths. # The variable factorOfDistance added for different screen resolutions. If your screen is smaller than 1024x768, 4 or bigger is good ##################################################################################### # Specify files and folders form Select files word longSoundFolder_(should_be_a_subfolder) 302000.txt word longSoundFile_(without_extension) 302000 word romFilesSubFolder csplit-rom word fileExtensionOfRom_(without_dot) rom word textGridSubFolder TextGrid integer factorOfDistance 4 endform Open long sound file... 'longSoundFolder$'\'longSoundFile$'.wav # Default end time end = 0 # Get .rom files for loop Create Strings as file list... fileList 'longSoundFolder$'\'romFilesSubFolder$'\*.'fileExtensionOfRom$' numFiles = Get number of strings for iFile to numFiles select Strings fileList # Get the name for .rom file romFile$ = Get string... iFile select LongSound 'longSoundFile$' View editor LongSound 'longSoundFile$' roughUttDur = end + 40 Select... end roughUttDur Zoom to selection # Get start and end time of the section that you want to create TextGrid # for by prompting pause Pick the beginning of utterance start = Get cursor pause Pick the end of utterance end = Get cursor endeditor # Extract that part from the long sound Extract part... 'start' 'end' yes # Calculate the length of the extracted segment lengthSubPart = end - start Rename... subpart # Create a TextGrid for that subpart sound, remove the subpart sound To TextGrid... "word phonology phonetics break-index misc" phonology phonetics break-index # Sound "subpart" was just for creating a TextGrid file select Sound subpart Remove # Get the number of strings (newline-separated eojeols) and create interval tiers Read Strings from raw text file... 'longSoundFolder$'\'romFilesSubFolder$'\'romFile$' Rename... rom numEojeols = Get number of strings # Insert an interval tier select TextGrid subpart 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 subpart 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 Insert point... 4 breakTime 2 endfor # For phonology tier for i from 2 to numEojeols pointTime = Get end point... 1 i Insert point... 2 pointTime LHa endfor # Save the TextGrid file select TextGrid subpart Write to text file... 'longSoundFolder$'\'textGridSubFolder$'\'romFile$'.TextGrid # Select both the long sound and the TextGrid and present for verification select LongSound 'longSoundFile$' plus TextGrid subpart Edit # Waits for user verification pause Click OK if TextGrid looks fine # Remove current TextGrid and move on select TextGrid subpart Remove # Close the long sound file editor window select LongSound 'longSoundFile$' editor LongSound 'longSoundFile$' Close endeditor # clean up select Strings rom Remove # end of loop endfor select Strings fileList plus LongSound 'longSoundFile$' Remove ####### END OF SCRIPT #######