Appendix 2: Praat Script to Load Multiple Files

Chapters: 1.0 | 2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 2.5 | 2.6 | 2.7 | 2.8 | 2.9 | 2.10 | 2.11 | 2.12 | Appendix 1 | Appendix 2

#OpenToBI

# This script prompts for a list of file name, and opens each .wav
# file corresponding .TextGrid files from a specified directory.

tobidir$ = "."
examples$ = "tobi_examples"

clearinfo

form Open .wav and text grid
text file_list
endform

while length(file_list$) > 0
list_length = length(file_list$)
firstspace = index(file_list$, " ")
if firstspace = 0
file_name$ = file_list$
file_list$ = ""
else
file_name$ = left$(file_list$,firstspace-1)
file_list$ = mid$(file_list$,firstspace+1,list_length-firstspace)
endif

sound_file$ = tobidir$+"/"+examples$+"/"+file_name$+".wav"
if fileReadable(sound_file$)
Read from file... 'sound_file$'
else
printline 'sound_file$' is not readable
endif

text_file$ = tobidir$+"/"+examples$+"/"+file_name$+".TextGrid"
if fileReadable(text_file$)
Read from file... 'text_file$'
else
printline 'text_file$' is not readable
endif
endwhile