############################################## # split-audio-files.praat # Written by Kyuchul Yoon (kyoon@ling.osu.edu # Splits big audio files by the textgrid # NOTE: Put this script into the folder that contains the long sound file # and its associated TextGrids. # The script will ONLY read TextGrid files whose extension # are specified in the dialog box # The script will ALSO produce another set of TextGrid files # whose time stamps have been adjusted # to the small audio files. (N.B.The original TextGrid files # are asynchronous with the new audio files) # When opening the new audio files with TextGrid files, use the # "newly created" TextGrids. ############################################## # Specify files and folders form word longSoundFile_(without_extension) 302000 word textGridFileExtension TextGrid.done.complete word outputFileExtension wav word outputTextGridFileExtension lab2 endform # Open the long sound file Open long sound file... 'longSoundFile$'.wav Rename... lsound # Get the names of all the input textgrids Create Strings as file list... fileList *.'textGridFileExtension$' Sort # Get the number of the files to be used in the loop numFiles = Get number of strings pause 'numFiles' textgrids were identified. Continue? for iFile to numFiles if iFile = 5 pause This is how long it takes to process FIVE textgrids. ... Continue with the rests? endif select Strings fileList # Get the name for each file fullFileName$ = Get string... iFile # Extract the prefix part of the filename prefixName$ = fullFileName$ - textGridFileExtension$ # Read in the file Read from file... 'fullFileName$' Rename... textGrid # Get the duration of the file startTime = Get starting time finishTime = Get finishing time # Extract the subsection and write it as .wav file select LongSound lsound Extract part... startTime finishTime yes Write to WAV file... 'prefixName$'wav Remove # Clean the textgrid select TextGrid textGrid Shift to zero Write to text file... 'prefixName$''outputTextGridFileExtension$' Remove endfor # Get rid of the Strings object from the Object Editor select Strings fileList plus LongSound lsound Remove #### END OF SCRIPT ####