############################################################## # waveform-cutter-by-the-sentence.praat (Written by Kyuchul Yoon kyoon@ling.osu.edu ) # The script read a long sound file and associated textgrids and chops the long sound file # by the textgrid. ############################################################## form Specify files and folders word longSound ytn-487.wav word textgridFolder temp word textgridExt TextGrid.lab word wavFolder temp-out endform Create Strings as file list... fileList 'textgridFolder$'\*.'textgridExt$' Sort Sort numFiles = Get number of strings pause 'numFiles' identified. Continue? Open long sound file... 'longSound$' Rename... longSound for i to numFiles select Strings fileList fileName$ = Get string... i Read from file... 'textgridFolder$'\'fileName$' Rename... textgrid filePrefix$ = fileName$ - ".TextGrid.lab" startTextGrid = Get starting time endTextGrid = Get finishing time select LongSound longSound Extract part... startTextGrid endTextGrid yes Rename... extractedSound select TextGrid textgrid Shift to zero # plus Sound extractedSound # Edit # pause Confirm? select Sound extractedSound Write to WAV file... 'wavFolder$'\'filePrefix$'.wav select TextGrid textgrid Write to text file... 'wavFolder$'\'fileName$' select Sound extractedSound plus TextGrid textgrid Remove endfor select Strings fileList plus LongSound longSound Remove ########### END OF SCRIPT #############