##################################################################################### # Specific syllable splitter in interval tier : Written by Kyuchul Yoon ( kyoon@ling.osu.edu ) # Splits specified syllables from an interval tier eojeol into separate intervals # # Directory structure for this script should be like the following # root\ : Script should be here # 302000.txt\TextGridDone # 302002.txt\TextGridDone # 302004.txt\TextGridDone # .... # The filename of the output files are .syl.split2 ##################################################################################### form Select files word subFolderToProcess 302000.txt\TextGridDone word fileToProcess 302000-01.TextGrid.done word outputFileName 302000-01.TextGrid.done.NEW integer numSylToSplit 3 endform # For debugging purpose #subFolderToProcess$ = "302000.txt\TextGridDone" #fileToProcess$ = "302000-01.TextGrid.done" #outputFileName$ = "302000.TextGrid.done.NEW" Read from file... 'subFolderToProcess$'\'fileToProcess$' Rename... grid Edit editor TextGrid grid pause Click the eojeol in interval tier to split ( to finish) eojeolLabel$ = Get label of interval while (eojeolLabel$ <> "") startPointInterval = Get starting point of interval endPointInterval = Get end point of interval midPointInterval = startPointInterval + (endPointInterval - startPointInterval)/2 eojeolLabel$ = Get label of interval numTotalChar = length(eojeolLabel$) for iEojeol to numSylToSplit indexOfHyphen = index(eojeolLabel$, "-") if (indexOfHyphen = 0) exit Wrong eojeol! Shorter than the number of syllables to split else # Calculate the number of the rest of the characters starting from the location of "-" subNumTotalChar = numTotalChar - indexOfHyphen eojeolLabel$ = right$(eojeolLabel$, subNumTotalChar) numTotalChar = length(eojeolLabel$) endif endfor newEojeolLabel$ = Get label of interval newNumTotalChar = length(newEojeolLabel$) numLeftSplitEojeol = newNumTotalChar - (subNumTotalChar + 1) leftSplitEojeol$ = left$(newEojeolLabel$, numLeftSplitEojeol) endeditor select TextGrid grid tempNum = Get interval at time... 1 startPointInterval rightEojeolIntervalNum = tempNum + 1 Insert boundary... 1 midPointInterval Set interval text... 1 rightEojeolIntervalNum 'eojeolLabel$' leftEojeolIntervalNum = rightEojeolIntervalNum -1 Set interval text... 1 leftEojeolIntervalNum 'leftSplitEojeol$' Write to text file... 'subFolderToProcess$'\'outputFileName$' pause Click the eojeol in interval tier to split select TextGrid grid editor TextGrid grid eojeolLabel$ = Get label of interval endwhile endeditor #Remove pause File updated and written to 'outputFileName$' #### END OF SCRIPT ####