################################################################ # TextGrid-former-w-after-LTS-texts.praat ( Written by Kyuchul Yoon kyoon@ling.osu.edu # This script forms TextGrids from raw text files composed of LTS output # Reads each raw text file and inserts each line one by one into the word interval tier of textgrids # reference textgrids will be used as place-holders for the raw text strings ################################################################ form Specify files and folders word inFolder_(with_raw_texts) lab.rawtext.after.LTS word inFileExt_(with_dot) .TextGrid word refTextGridFolder_(new_interval_to_be_inserted) lab.TextGrid.before.LTS word refTextGridExt_(with_dot) .TextGrid.done word outFolder_(TextGrids_to_be_created_here) lab.TextGrid.after.LTS endform # 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$ 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... 1 1 after.LTS numIntervals = Get number of intervals... 1 if (numLines-1) <> (numIntervals-2) pause numLines and numIntervals do not match!! endif # For each line of the file for iLine from 2 to numLines select Strings rawText lineText$ = Get string... iLine select TextGrid rawTextGrid Set interval text... 1 iLine 'lineText$' endfor # Edit # pause Check before saving! Remove tier... 2 Write to text file... 'outFolder$'\'fileName$' plus Strings rawText Remove endfor select Strings fileList Remove ############# END OF SCRIPT ##############