

#Praat formant extration code code
If you do have errors, check to make sure you’ve typed (or copy and pasted) the code correctly, and make sure that both the Sound file and TextGrid are loaded into Praat and are highlighted. Nothing seemingly happens because it’s so simple, but assuming you don’t have any errors, then it should run fine. This will run the entire script all at once. Then, go to your scripting window and click Run > Run (or command+R in Macs). To run this script, go to where the two files are in the Objects Window and select both of them. They’re saved in these variable names so we can call upon them later on in the script when we need to. The end result of these two lines of code is that Praat now has the names of the two files you highlighted. The second line does the exact same thing, but it looks saves the name of the TextGrid instead. My Sound file is called “Joey”, so now the variable thisSound$ contains the string “ Joey”. The dollar sign at the end of that variable name means that the variable contains text rather than a number (in computer circles, text is often called “strings,” as in a string of characters). This name is then stored in a variable called thisSound$. What the first line does is it tells Praat to look at whatever Sound file is selected and extract its name. First off, it doesn’t even know what files to work with! We can tell it to work with the Sound and TextGrid files that are already loaded by putting in these lines of code into your Praat script: thisSound$ = selected$( "Sound") Extracting the names of Praat objectsīefore we can do any of that, Praat needs to figure out a few things. Now we “just” need to translate that into Praat’s scripting language. Save those formants into some file so I can use it later (in R or something).Extract formant measurements at that midpoint.Go through each phoneme in your TextGrid.To accomplish this task, there are the steps I’ll take: The goal is to turn this phoneme-level transcription and accompanying audio into a spreadsheet of formants. Let’s pause for a second and think about what the script is going to do. Once you’ve done that create a script by going to Praat > New Praat Script.Ī blank window should open up for you to write your script in. Note that if you want to extract formants, you should load it in as a Sound file and not as a LongSound. There are ways to load files in automatically through scripting-which is useful if you need to process many files-but we’ll keep it simple for now. To get started, open Praat and load your Sound file and TextGrid. I’m going to assume you’ve used DARLA or FAVE to process your files so they should look like mine does. The important part to note is that I have the word-level transcription in the second tier, and a phoneme-level transcription-in ARPABET-in the first tier. I did the word-level transcription by hand (including boundaries) and then I sent it off to DARLA for forced alignment. Sample dataįor this tutorial, I’ll work with a recording of myself reading a couple dozen words with the /u/ vowel that I created for something a few months ago. I explain what to do, but I barely skim the surface when it comes to why you need to do it that way (for example, I gloss over basic computer coding concepts like for loops and variables). Note, this post was written in small chunks over Christmas break with my in-laws in town and I haven’t had time to proofread it carefully.
#Praat formant extration code how to
Instead of giving you a fish to feed you for a night, I’ll teach you how to fish.

Instead of providing you a Praat script, I’m going to show how to write your own. I’ve been meaning to create some Praat scripting tutorials so this was a good excuse to get something going. Just this week I’ve had three people ask for a Praat script that extracts formant measurements. You can find the handout here, which is slightly modified from this blog post. Note: I gave a workshop that covered the contents of this workshop. A Tutorial on Extracting Formants in Praat
