

We still don't know the start and stop time, but we'll make some blank variables that we'll fill in in a second: Let's convert this command to code, and save the result to a variable called "part".

Open it and see its arguments, and we see that the important thing we need to know is the time range (in seconds) of the section we want to extract. I strongly encourage you to try to write this yourself before continuing, you'll get a lot more out of it.īut now here's my version: We want to extract from the sound object, so select it and find a command in the right that will extract part of the sound. Let's extract the sound in the second interval from this tier (the vowel "e"), and make it its own sound object. Select "Sound be" and "TextGrid be" and click View & Edit, and note that the second tier has split this syllable into segments. An example using object selection: Extracting part of a sound I'll explain why I think so after we do this next example. For one, those numbers are going to be different every time you use Praat, so we absolutely cannot hard-code them (object 7 will most likely be different the next time you run the script), but in truth there are some great advantages to using the numbers, and I generally prefer them. At first glance, the numbers version may seem to be the lamer option. Which version you should use depends on your situation. Change which version of the command is commented and uncommented, and run it again. Now to make sure both commands work, click on a different object like "Sound ba", comment out the command you don't want to test (put a hashtag in front of one of the selectObject commands), and run the code. In a blank scripting window, type in the two following ways we can select the object "Sound a", adjusting the numbers to work with what you currently have open. The numbering starts at 1 when you open Praat, and will keep going up as you create more objects or open more files. Look to the left of each object, and note that they have been assigned a unique number. There are basically two ways we can select files in Praat: by using the object's name or by using its number in the object window.
#LARGE AMOUNT OF SOUND FILES ON PRAAT HOW TO#
Hopefully you now see plainly why we need to learn how to select objects in Praat via script: we won't get very far without it. This should generate an error saying that the given command is not available, which is true, because that command is only available when a text grid is selected, and right now a sound is selected (other times this error simply means you've spelled the command wrong). Open a Praat scripting window, type this in, and run it: What we want to note here is that we have different commands available to us when different object types are selected. Now select a sound and its corresponding TextGrid together (ctrl), and look at the available commands. Now click on a text grid and look at the commands. Though we already went through this, click on a sound file and look at the available commands on the right. TextGrid files in sampleData/ (if you haven't downloaded the accompanying files, go to the Downloads page from the top right menu).
