form Working with directories comment The directory of sound files word dirSound /Users/leihe/Documents/tevoid/wavAndTextgrid/ comment The directory of tables word dirTable /Users/leihe/Documents/tevoid/corpus_10_stable/new/ comment The directory to save the created textgrids word dirTextGrid /Users/leihe/Documents/tevoid/corpus_10_stable/txtgrid_stable/ endform wavFileList = Create Strings as file list: "wavFileList", "'dirSound$'*.wav" select wavFileList nFiles = Get number of strings for iFile to nFiles select wavFileList wavFileName$ = Get string: iFile sound = Read from file: "'dirSound$''wavFileName$'" baseName$ = wavFileName$ - ".wav" table = Read Table from whitespace-separated file: "'dirTable$''baseName$'.stable.txt" ### CORE OF PROGRAM - START ### select sound samplingPeriod = Get sampling period totalDuration = Get total duration textgrid = Create TextGrid: 0, totalDuration, "'baseName$'stability", "" select table numRows = Get number of rows nBoundaries = numRows - 1 for iBoundary to nBoundaries select table boundarySampleNumber = Get value: iBoundary, "end" label$ = Get value: iBoundary, "label" select textgrid Insert boundary: 1, boundarySampleNumber * samplingPeriod Set interval text: 1, iBoundary, "'label$'" endfor select table labelEnd$ = Get value: numRows, "label" select textgrid Set interval text: 1, numRows, "'labelEnd$'" ### CORE OF PROGRAM - END ### select textgrid Save as text file: "'dirTextGrid$''baseName$'_stability.TextGrid" select textgrid plus sound plus table Remove endfor select wavFileList Remove