############################################################ # tone-checker-extended-&-replacer.praat # Written by Kyuchul Yoon (kyoon@ling.osu.edu) # The script reads in textgrids one by one and checks each tone label # If it finds tone labels containing ? (unspecified), it prints the filename and location of ? # This version gets rid of the labToCheck$ from the tone label ############################################################ # Get the user input form Select files and parameters word fileToProcess_(only_extensions) lab word subFolderToProcess 2.K-ToBI-TextGrid-KCY-corrected.only\ToBeCorrected word labToCheck ? natural phonologyTier 2 natural phoneticsTier 3 word outFolder 2.K-ToBI-TextGrid-KCY-corrected.only endform # Read all filenames Create Strings as file list... fileList 'subFolderToProcess$'\*.'fileToProcess$' numFiles = Get number of strings pause 'numFiles' files identified. Continue? # Process each file for i to numFiles select Strings fileList strFileName$ = Get string... i Read from file... 'subFolderToProcess$'\'strFileName$' Rename... textgrid numPoints = Get number of points... phonologyTier for j to numPoints labPoint$ = Get label of point... phonologyTier j locOfLabelToCheck = index(labPoint$, labToCheck$) lenOfLabPoint = length(labPoint$) if locOfLabelToCheck <> 0 beforeString$ = left$(labPoint$, (locOfLabelToCheck-1)) afterString$ = right$(labPoint$, (lenOfLabPoint-locOfLabelToCheck)) newLab$ = beforeString$ + afterString$ Set point text... phonologyTier j 'newLab$' endif endfor numPoints2 = Get number of points... phoneticsTier for k to numPoints2 labPoint2$ = Get label of point... phoneticsTier k locOfLabelToCheck2 = index(labPoint2$, labToCheck$) lenOfLabPoint2 = length(labPoint2$) if locOfLabelToCheck2 <> 0 beforeString2$ = left$(labPoint2$, (locOfLabelToCheck2-1)) afterString2$ = right$(labPoint2$, (lenOfLabPoint2-locOfLabelToCheck2)) newLab2$ = beforeString2$ + afterString2$ Set point text... phoneticsTier k 'newLab2$' endif endfor select TextGrid textgrid Write to text file... 'outFolder$'\'strFileName$' Remove endfor select Strings fileList Remove ############ END OF SCRIPT ###############