## This script opens all the files in some directory. ## It makes a TextGrid for each of the sound files, then throws the sound file and the ## TextGrid into the editor so you can make marks. # First we will make a list of all the sound (.wav) files in the directory. Create Strings as file list... file-list *.wav # Now we will set up a "for" loop -- the loop will iterate once for every file in the list we just made. # First we will query our list to see how many filenames are in it, and store that number using the # variable "number_of_files". That variable will then be used in setting up the for loop. number_of_files = Get number of strings print number of files: 'number_of_files' 'newline$' for x from 1 to number_of_files # Now we will set up a string variable called "current_file$" and use it to store the first # filename from the list. select Strings file-list current_file$ = Get string... x printline DEBUG: 'current_file$' # Now that we have the filename, we read in that file: Read from file... 'current_file$' # Now I am setting up a variable called "object_name$" that will have the name of the # sound object. This is basically equivalent to subtracting the ".wav" or ".aiff" from # the filename. This will be useful if I want to refer to the sound object later in the script. object_name$ = selected$ ("Sound") # Now I make a text grid for the current sound file. # Note: 5 tiers will be created for labelling. The number and title of the tiers can be # changed by changing what falls within the " ". To TextGrid... "QV Q-release V transF notes" # Since we have just created a TextGrid, it is automatically selected (i.e., active). We need # both the textgrid and the sound object to be selected together, so I am going to add the # sound object to the selection. This is where removing the ".wav" extension comes in handy: plus Sound 'object_name$' # Now we want to throw those two objects -- the Sound object and the Textgrid object -- into the editor: Edit # Now, we will tell the script to pause. This will allow the user to step in and enter the appropriate # marks using the mouse and keyboard. Note that the user does not need to save the textgrid -- this is # built into the script later. Just click on "continue" when you have made the marks that you want. pause Mark your segments! # Now we will save the TextGrid object, so that the user doesn't have to do it for each file. # Note that the textgrid will have the same filename as the # sound file that it goes with, except that it will have the extension ".TextGrid" -- this is another # instance where removing the ".wav" comes in handy: select TextGrid 'object_name$' Write to text file... 'object_name$'.TextGrid # We are now ready to end the for loop, and go on to the next file. However, to conserve # memory, we will first remove the objects that we are through with. I like to do this by # selecting all the objects in the list, then de-selecting any we will still be using, such as # our list of filenames. # select all # minus Strings file-list # Remove # This specifies the end of the loop: endfor # The next three lines just do some clean up, and display a message in the Info window # letting you know when you've reached the end of the list. select Strings file-list Remove print All files processed -- woohoo! 'newline$' ## written by Katherine Crosswhite ## crosswhi@ling.rochester.edu ## edited by Marion, and Sonya, and Chris!