############################################################################# # prosodic-diphone-extractor.praat ( Written by Kyuchul Yoon kyoon@ling.osu.edu ) # This script extracts from each of the textgrids a diphone list with prosodic information. # < [ { (CVC) (CVC) } ] > ==> IP-initial AP-initial PW-initial syllable-initial syllable-final PW-final AP-final IP-final # # and - indicate pause and diphone boundary respectively. # For example, from a textgrids (302000-01.TextGrid), the output diphones could be <#-p, , ... # syllable separator is " - ", and phone separator is " " ############################################################################## form Specify files and folders comment TextGrid INPUT word inFolder 03.lab.TextGrid.after.LTS.scheme word inFileExt_(with_dot) .TextGrid natural tierToExtract 2 natural tierPhonology 4 comment newline-separated TEXT file of DIPHONES word outFolder_(to_be_created) 03.lab.TextGrid.after.LTS.scheme.diphone.text word outFileExt_(with_dot) .prosodic.diphones comment TextGrid with a new TIER of DIPHONES natural tierToDuplicate 2 natural newTierPosition 5 word newTierName prosodic.diphones word textgridOutFolder_(to_be_created) 03.lab.TextGrid.after.LTS.scheme.diphone.textgrid word textgridOutFileExt_(with_dot) .TextGrid.prosodic.diphone endform # Make a list of files Create Strings as file list... fileList 'inFolder$'\*'inFileExt$' Sort numFiles = Get number of strings pause 'numFiles' files identified. Continue? # Create subdirectories system mkdir 'outFolder$' system mkdir 'textgridOutFolder$' # Loop through each file for iFile to numFiles select Strings fileList # Filenames fileName$ = Get string... iFile filePrefix$ = fileName$ - inFileExt$ outFileName$ = filePrefix$ + outFileExt$ textgridOutFileName$ = filePrefix$ + textgridOutFileExt$ # Read a textgrid file Read from file... 'inFolder$'\'fileName$' Rename... textgrid numIntervals = Get number of intervals... tierToExtract # Creat a new diphones interval by duplicating the second tier 'word.after.LTS' Duplicate tier... tierToDuplicate newTierPosition # and initialize all the texts to none dupNumIntervals = Get number of intervals... newTierPosition for iDup from 2 to (dupNumIntervals-1) Set interval text... newTierPosition iDup endfor ############################## # COUNT # OF DIPHONES EXTRACTED # Initialize the counter to zero ############################## numDiphones = 0 # Initialize the index for counting all sub-intervals to one. Excluding the first interval # This will be used way later in the script when adding diphones to the newly created diphones tier countSubIntervals = 1 for iInterval from 2 to (numIntervals-1) ################################ # GET TONE LABELS of the current interval ################################ # Initialize string variables select TextGrid textgrid prosLabOfStartTimeOfInterval$ = "none" prosLabOfEndTimeOfInterval$ = "none" startTimeOfInterval = Get starting point... tierToExtract iInterval endTimeOfInterval = Get end point... tierToExtract iInterval # Get the point number that corresponds in time to the start and end time of interval numPoints = Get number of points... tierPhonology # Loop through each point in point tier to determine point number of the two for iPoint to numPoints timeOfPoint = Get time of point... tierPhonology iPoint if startTimeOfInterval = timeOfPoint startPointNum = iPoint prosLabOfStartTimeOfInterval$ = Get label of point... tierPhonology startPointNum elsif endTimeOfInterval = timeOfPoint endPointNum = iPoint prosLabOfEndTimeOfInterval$ = Get label of point... tierPhonology endPointNum endif endfor # If there's no AP or IP boundaries, assign PWi or PWf labels if prosLabOfStartTimeOfInterval$ = "none" prosLabOfStartTimeOfInterval$ = "PWi" elsif prosLabOfEndTimeOfInterval$ = "none" prosLabOfEndTimeOfInterval$ = "PWf" endif # Exceptional case if it's the first interval, whose start is IP-initial, arbitrarily called "IP%" if iInterval = 2 prosLabOfStartTimeOfInterval$ = "IP%" endif ################################################# # CONVERT TONE LABELS INTO BOUNDARY SYMBOLS < [ { } ] > ################################################# tempStartLab$ = right$(prosLabOfStartTimeOfInterval$, 1) tempEndLab$ = right$(prosLabOfEndTimeOfInterval$, 1) # For the string in prosLabOfStartTimeOfInterval$ if tempStartLab$ = "%" startSymbol$ = "<" elsif tempStartLab$ = "a" startSymbol$ = "[" else tempStartLab$ = "i" startSymbol$ = "{" endif # For the string in prosLabOfEndTimeOfInterval$ if tempEndLab$ = "%" endSymbol$ = ">" elsif tempEndLab$ = "a" endSymbol$ = "]" else tempEndLab$ = "f" endSymbol$ = "}" endif ##################################################### # COUNT THE # OF SYLLABLES for current interval. Filed separator is " - ". ##################################################### intervalText$ = Get label of interval... tierToExtract iInterval tempString$ = intervalText$ lenTempString = length(tempString$) indexOfSep = index(tempString$, " - ") sylCount = 1 while indexOfSep <> 0 tempString$ = right$(tempString$, (lenTempString-(indexOfSep+2))) sylCount = sylCount + 1 indexOfSep = index(tempString$, " - ") lenTempString = length(tempString$) endwhile ####################################################### # EXTRACT EACH SYLLABLE from current interval and CREATE DIPHONES ####################################################### for iSyl to sylCount ##################### # SYLLABLE EXTRACTION if sylCount <> 1 lenIntervalText = length(intervalText$) indexOfFieldSep = index(intervalText$, " - ") if indexOfFieldSep <> 0 sylExtracted$ = left$(intervalText$, (indexOfFieldSep-1)) remainIntervalText$ = right$(intervalText$, (lenIntervalText-(indexOfFieldSep+2))) intervalText$ = remainIntervalText$ else sylExtracted$ = intervalText$ endif else sylCount = 1 # If there's only one syllable-long text in the current interval sylExtracted$ = intervalText$ endif #################### # Extract prosodic diphones #################### ###################################### # COUNT THE # OF PHONES for current syllable # To be used to create sub-intervals for current interval ###################################### phoneCount = 1 tempSylExtracted$ = sylExtracted$ lenTempSylExtracted = length(tempSylExtracted$) indexOfSpace = index(tempSylExtracted$, " ") while indexOfSpace <> 0 remainSyl$ = right$(tempSylExtracted$, (lenTempSylExtracted-indexOfSpace)) phoneCount = phoneCount + 1 tempSylExtracted$ = remainSyl$ lenTempSylExtracted = length(tempSylExtracted$) indexOfSpace = index(tempSylExtracted$, " ") endwhile #################################################### # EXTRACT EACH PHONE from current syllable and CREATE DIPHONES #################################################### for iPhone to phoneCount ################### # PHONE EXTRACTION ################### lenSylExtracted = length(sylExtracted$) indexOfSpace = index(sylExtracted$, " ") if indexOfSpace <> 0 phoneExtracted$ = left$(sylExtracted$, (indexOfSpace-1)) remainPhones$ = right$(sylExtracted$, (lenSylExtracted-indexOfSpace)) sylExtracted$ = remainPhones$ else phoneExtracted$ = sylExtracted$ endif ################################################ # For the FIRST SYLLABLE of MULTI-SYLLABLE INTERVAL TEXT # For example, sylCount) ################### # IP-INITIAL EDGE phone if startSymbol$ = "<" # For the first phone in a multi-phone syllable if (iPhone = 1 and iPhone <> phoneCount) diphone$ = startSymbol$ + "#-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ # Increase the number of diphones by one numDiphones = numDiphones + 1 # Store the final diphone string variable to an array string variable arrayDiphone'numDiphones'$ = diphone$ # For the first and last phone in a single-phone syllable, **mostly same as the above** elsif (iPhone = 1 and iPhone = phoneCount) diphone$ = startSymbol$ + "#-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the second phone in a two-phone syllable elsif (iPhone = 2 and iPhone = phoneCount) diphone$ = startSymbol$ + prevPhone$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the second phone in a three-phone syllable, ** mostly same as the above ** elsif (iPhone = 2 and iPhone <> phoneCount) diphone$ = startSymbol$ + prevPhone$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the last phone in a three-phone syllable elsif iPhone = phoneCount diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + ")" fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif ############################## # AP-INITIAL / PW-INITIAL EDGE phone else # Deal with AP-f + AP-i or PW-f + PW-i sequences if startSymbol$ = "[" bSign1$ = "[" bSign2$ = "]" elsif startSymbol$ = "{" bSign1$ = "{" bSign2$ = "}" endif # For the first phone in a multi-phone syllable if (iPhone = 1 and iPhone <> phoneCount) diphone$ = prevPhone$ + "-" diphone$ = diphone$ + bSign2$ diphone$ = diphone$ + bSign1$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the first and last phone in a single-phone syllable elsif (iPhone = 1 and iPhone = phoneCount) diphone$ = prevPhone$ + "-" diphone$ = diphone$ + bSign2$ diphone$ = diphone$ + bSign1$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the second phone in a two-phone syllable elsif (iPhone = 2 and iPhone = phoneCount) diphone$ = bSign1$ + prevPhone$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the second phone in a three-phone syllable elsif (iPhone = 2 and iPhone <> phoneCount) diphone$ = bSign1$ + prevPhone$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the last phone in a three-phone syllable elsif iPhone = phoneCount diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + ")" fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif endif ################################################# # For the FIRST SYLLABLE of SINGLE-SYLLABLE INTERVAL TEXT # For example, phoneCount) diphone$ = startSymbol$ + "#-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the first phone in a single-phone syllable elsif (iPhone = 1 and iPhone = phoneCount) diphone$ = startSymbol$ + "#-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ ########################################### # If the right edge is other than ) 'syllable boundary' then put it if endSymbol$ = ">" diphone$ = prevPhone$ + "-" diphone$ = diphone$ + "#" diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif # For the second phone in a two-phone syllable elsif (iPhone = 2 and iPhone = phoneCount) diphone$ = startSymbol$ + prevPhone$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the second phone in a three-phone syllable elsif (iPhone = 2 and iPhone <> phoneCount) diphone$ = startSymbol$ + prevPhone$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the last phone in a three-phone syllable elsif iPhone = phoneCount ########################################### # If the right edge is other than ) 'syllable boundary' then put it if (endSymbol$ = ">" or endSymbol$ = "]" or endSymbol$ = "}") diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ else diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + ")" fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif endif ############################## # AP-INITIAL / PW-INITIAL EDGE phone else # Deal with AP-f + AP-i or PW-f + PW-i sequences if startSymbol$ = "[" bSign1$ = "[" bSign2$ = "]" elsif startSymbol$ = "{" bSign1$ = "{" bSign2$ = "}" endif # For the first phone in a multi-phone syllable if (iPhone = 1 and iPhone <> phoneCount) diphone$ = prevPhone$ + "-" diphone$ = diphone$ + bSign2$ diphone$ = diphone$ + bSign1$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the first and last phone in a single-phone syllable elsif (iPhone = 1 and iPhone = phoneCount) diphone$ = prevPhone$ + "-" diphone$ = diphone$ + bSign2$ diphone$ = diphone$ + bSign1$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ ########################################### # If the right edge is other than ) 'syllable boundary' then put it if endSymbol$ = ">" diphone$ = prevPhone$ + "-" diphone$ = diphone$ + "#" diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif # For the second phone in a two-phone syllable elsif (iPhone = 2 and iPhone = phoneCount) ########################################### # If the right edge is other than ) 'syllable boundary' then put it if endSymbol$ = ">" diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ diphone$ = phoneExtracted$ + "-" diphone$ = diphone$ + "#" diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ elsif (endSymbol$ = "]" or endSymbol$ = "}") diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ else diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + ")" fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif # For the second phone in a three-phone syllable elsif (iPhone = 2 and iPhone <> phoneCount) diphone$ = bSign1$ + prevPhone$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the last phone in a three-phone syllable elsif iPhone = phoneCount ########################################### # If the right edge is other than ) 'syllable boundary' then put it if endSymbol$ = ">" diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ diphone$ = phoneExtracted$ + "-" diphone$ = diphone$ + "#" diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ elsif (endSymbol$ = "]" or endSymbol$ = "}") diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ else diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + ")" fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif endif endif ################################################ # For the LAST SYLLABLE of MULTI-SYLLABLE INTERVAL TEXT # For example, ... ################################################ elsif (iSyl <> 1 and iSyl = sylCount) # For the first phone in a multi-phone syllable if (iPhone = 1 and iPhone <> phoneCount) diphone$ = prevPhone$ + "-)(-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the first and last phone in a single-phone syllable elsif (iPhone = 1 and iPhone = phoneCount) diphone$ = prevPhone$ + "-)(-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ ########################################## # If the right edge is ">", add an additional diphone with -# if endSymbol$ = ">" diphone$ = phoneExtracted$ + "-" diphone$ = diphone$ + "#" diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif prevPhone$ = phoneExtracted$ # For the second phone in a two-phone syllable elsif (iPhone = 2 and iPhone = phoneCount) diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ ########################################## # If the right edge is ">", add an additional diphone with -# if endSymbol$ = ">" diphone$ = phoneExtracted$ + "-" diphone$ = diphone$ + "#" diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif prevPhone$ = phoneExtracted$ # For the second phone in a three-phone syllable elsif (iPhone = 2 and iPhone <> phoneCount) diphone$ = "(" + prevPhone$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the last phone in a three-phone syllable elsif iPhone = phoneCount diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ ########################################## # If the right edge is ">", add an additional diphone with -# if endSymbol$ = ">" diphone$ = phoneExtracted$ + "-" diphone$ = diphone$ + "#" diphone$ = diphone$ + endSymbol$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif prevPhone$ = phoneExtracted$ endif ######################################### # For the SYLLABLES IN BETWEEN the first and the last # For example, ######################################### else # For the first phone in a multi-phone syllable if (iPhone = 1 and iPhone <> phoneCount) diphone$ = prevPhone$ + "-)(-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the first and last phone in a single-phone syllable elsif (iPhone = 1 and iPhone = phoneCount) diphone$ = prevPhone$ + "-)(-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the second phone in a two-phone syllable elsif (iPhone = 2 and iPhone = phoneCount) diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + ")" fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the second phone in a three-phone syllable elsif (iPhone = 2 and iPhone <> phoneCount) diphone$ = "(" + prevPhone$ diphone$ = diphone$ + "-" diphone$ = diphone$ + phoneExtracted$ fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ # For the last phone in a three-phone syllable elsif iPhone = phoneCount diphone$ = prevPhone$ + "-" diphone$ = diphone$ + phoneExtracted$ diphone$ = diphone$ + ")" fileappend 'outFolder$'\'outFileName$' 'diphone$''tab$' prevPhone$ = phoneExtracted$ numDiphones = numDiphones + 1 arrayDiphone'numDiphones'$ = diphone$ endif endif endfor endfor ############################################# # ADD DIPHONES TO DIPHONES TIER # with numDiphones and arrayDiphone'numDiphones'$ variables ############################################# select TextGrid textgrid # Number of sub-intervals to insert to the current interval numSubIntervals = numDiphones # The number of boundaries to insert to an interval is obtained by (numSubIntervals - 1) numBoundaries = numSubIntervals - 1 # Compute the amount of interval for each sub-interval interSubInterval = (endTimeOfInterval - startTimeOfInterval) / numSubIntervals # Duplicate the variable "startTimeOfInterval" to a temp variable to be used in the following loop pointOfInsertion = startTimeOfInterval # Insert sub-intervals for current interval for iBoundary to numBoundaries pointOfInsertion = pointOfInsertion + interSubInterval Insert boundary... newTierPosition pointOfInsertion countSubIntervals = countSubIntervals + 1 arrayDummy$ = arrayDiphone'iBoundary'$ Set interval text... newTierPosition countSubIntervals 'arrayDummy$' endfor # Set one more interval text because iBoundary is fewer than numSubIntervals (or numDiphones) by one additionalBoundary = numBoundaries + 1 arrayDummy$ = arrayDiphone'additionalBoundary'$ countSubIntervals = countSubIntervals + 1 Set interval text... newTierPosition countSubIntervals 'arrayDummy$' #pause About to insert diphones #Edit #pause #editor TextGrid textgrid #pause To be closed #Close #endeditor # Add a new line for the text output of diphones fileappend 'outFolder$'\'outFileName$' 'newline$' ############################################## # COUNT # OF DIPHONES EXTRACTED # Initialize the variable to zero before moving on to the next interval ############################################## numDiphones = 0 endfor select TextGrid textgrid Edit editor TextGrid textgrid pause Check the text file before continuing to next file! Close endeditor # Write to a textgrid file Write to text file... 'textgridOutFolder$'\'textgridOutFileName$' Remove endfor select Strings fileList Remove #################### END OF SCRIPT ######################