################################################################################################### # diphone.list-extracted.from.which.TextGrids.praat ( Written by Kyuchul Yoon kyoon@ling.osu.edu ) # This script lists the component diphones and their origins in terms of TextGrid files. # Given a textgrid with a diphones tier, it will extract its component diphones, and # query the origins of the diphones based on the file (also given) containing all the # actual existing diphones and their textgrid origins. # Given an unseen textgrid with a diphones tier, the output file will say whether the diphones # can be found (and where if found) or not (with a warning!) ################################################################################################### form Specify files and folders word inFile 302000-01.TextGrid.prosodic.diphone word inFileExt_(with_dot) .TextGrid.prosodic.diphone word inFolder lab.TextGrid.after.LTS.scheme.diphone.textgrid natural diphoneTier 5 word diphoneFolder_(with_marked.diphones) 10.lab.TextGrid.PRAAT.EMU.diphone-labeling word diphoneExt_(with_dot) .TextGrid.prosodic.diphone natural markedDiphoneTier 6 word outFolder_(to_be_created) diphone.TextGrid-location word outFileExt_(with_dot) .diphone.textgrid-location endform # Create the output folder system mkdir 'outFolder$' # Get the output file name filePrefix$ = inFile$ - inFileExt$ outFile$ = filePrefix$ + outFileExt$ # Make a list of all marked.diphones TextGrid files Create Strings as file list... diphoneTextgridList 'diphoneFolder$'\*'diphoneExt$' Sort Sort numDiphoneTextgrids = Get number of strings pause 'numDiphoneTextgrids' diphone textgrids identified. Continue? # Read the input file Read from file... 'inFolder$'\'inFile$' Rename... textgrid numDiphoneTierIntervals = Get number of intervals... diphoneTier ###################### # FOR EACH DIPHONE # Loop through each interval for iInterval from 2 to (numDiphoneTierIntervals-1) select TextGrid textgrid intervalText$ = Get label of interval... diphoneTier iInterval fileappend 'outFolder$'\'outFile$' 'intervalText$''tab$' # Get the first file name and set the textgrid flag iDiphoneTextgrid = 1 textgridFlag = 1 ####################################### # MARKED.DIPHONES TEXTGRIDS SEARCHING ####################################### # Loop through each marked.diphones file to find the current diphone while (textgridFlag = 1 and iDiphoneTextgrid <= numDiphoneTextgrids) select Strings diphoneTextgridList diphoneFileName$ = Get string... iDiphoneTextgrid Read from file... 'diphoneFolder$'\'diphoneFileName$' Rename... textgridMD numMarkedDiphoneTierIntervals = Get number of intervals... markedDiphoneTier # Get the first interval label and set the interval flag iIntervalMD = 1 intervalFlag = 1 ################################# # MARKED.DIPHONES TIER SEARCHING ################################# # Loop through each marked.diphones (MD) tier interval while (intervalFlag = 1 and iIntervalMD <= numMarkedDiphoneTierIntervals) select TextGrid textgridMD intervalTextMD$ = Get label of interval... markedDiphoneTier iIntervalMD # Check whether the two interval texts are the same # and set the flags so that you can skip the rest of the intervals and textgrids if intervalText$ = intervalTextMD$ intervalFlag = 2 textgridFlag = 2 endif iIntervalMD = iIntervalMD + 1 endwhile ################ # FOUND IT !! # If the interval flag is changed, output the result if intervalFlag = 2 fileappend 'outFolder$'\'outFile$' 'diphoneFileName$''newline$' endif select TextGrid textgridMD Remove endwhile ##################### # NOT FOUND IT !! # If the textgrid flag is not changed, output the warning if textgridFlag = 1 fileappend 'outFolder$'\'outFile$' N/A'newline$' endif endfor select TextGrid textgrid plus diphoneTextgridList Remove ############## END OF SCRIPT #################