################################################################ # TextGrid-former-w-LTS-scheme-out.praat ( Written by Kyuchul Yoon kyoon@ling.osu.edu ) # This script forms TextGrids from raw text files composed of LTS scheme output (v. 1.35 krlex.scm) # Reads each raw text file and inserts each line one by one into the new word interval tier of textgrids ################################################################ form Specify files and folders word inFolder_(with_raw_texts) pre.TextGrid word inFileExt_(with_dot) .LTS.out word refTextGridFolder_(new_interval_to_be_inserted) lab.TextGrid.after.LTS.aligned.corrected word refTextGridExt_(with_dot) .TextGrid natural tierToDuplicate 2 word newTierName word.after.LTS natural positionForNewTier 2 word outFolder_(TextGrids_to_be_created_here) lab.TextGrid.after.LTS.scheme endform system mkdir 'outFolder$' # Make a list of all .TextGrid filenames Create Strings as file list... fileList 'inFolder$'\*'inFileExt$' Sort Sort numFiles = Get number of strings pause 'numFiles' identified. Continue? # Loop through each file for iFile to numFiles select Strings fileList fileName$ = Get string... iFile filePrefix$ = fileName$ - inFileExt$ outFile$ = filePrefix$ + refTextGridExt$ Read Strings from raw text file... 'inFolder$'\'fileName$' Rename... rawText numLines = Get number of strings # Read the reference TextGrid that will be inserted with new after.LTS interval texts Read from file... 'refTextGridFolder$'\'filePrefix$''refTextGridExt$' Rename... rawTextGrid Duplicate tier... tierToDuplicate positionForNewTier 'newTierName$' numIntervals = Get number of intervals... 1 if numLines <> (numIntervals-2) # pause numLines and numIntervals do not match!! fileappend mismatch.file.list 'fileName$''newline$' endif # For each line of the file for iLine from 2 to (numIntervals-1) select Strings rawText lineText$ = Get string... (iLine-1) select TextGrid rawTextGrid Set interval text... positionForNewTier iLine 'lineText$' endfor Edit pause Check before saving! Write to text file... 'outFolder$'\'outFile$' plus Strings rawText Remove endfor select Strings fileList Remove ############# END OF SCRIPT ##############