

- #SCRIPT PRAAT TEXTGRID TO CSV MANUAL#
- #SCRIPT PRAAT TEXTGRID TO CSV SOFTWARE#
- #SCRIPT PRAAT TEXTGRID TO CSV SERIES#
#SCRIPT PRAAT TEXTGRID TO CSV SOFTWARE#
Going back to our example, we can imagine that our experimental software generated a bunch of names like "1-e-23.wav". Recall our example before of wanting to manipulate a bunch of sound files. This one's a big task, but it covers pretty much all of the concepts we've been talking about, and is really practical. You can use these creatively to parse and analayze strings. Don't stress too much about things you don't understand (but get curious!).
#SCRIPT PRAAT TEXTGRID TO CSV MANUAL#
Now go to the Praat manual and read the page on string functions. length() returns a number, so we saved it to a numeric variable (extLen).

right$() returns a string, so we save it to a string variable (ext$). Check out how this is reflected in the variables we used to save the return value (ext$ and extLen). That's because, you guessed it, right$ will return a string, and length will return a number. Can you spot it? right$() has a dollar sign after its name, and length() doesn't. There is an important difference between the length() function, and the one we used to get the rightmost letters. We'll get the length of the extension by using the length() function: aiff files? That file extension has 4 letters, and we would have to run through our script and change all of the (right) threes. What if we want to reuse this script and the files are. I don't like how we hard-coded the number three into the call to right$(). Run them and observe the error message, then find the errors and fix them. The following calls to right$() have mistakes in them. As stated in its definition in the manual, it returns a string, so when we save its return value, we must save it to a string variable with a trailing dollar sign. Hopefully you have noted this already, but its first argument is a string, and its second argument is a number. It has two arguments: the string to act on (fil$), and the number of characters we want (3). Here, the function is the right$: function.
#SCRIPT PRAAT TEXTGRID TO CSV SERIES#
Remember that a "function" in computer languages is basically a series of commands that will give you back a value: you "call" it, possibly giving it "arguments" (elements to act on), and it will "return" a value. Let's look at what this means and carefully understand what's happening. Let's get the right three characters of the string "01-e-23.wav", and save it to a variable called ext$: Note that in Praat's new syntax, this could also be written as right$: a$, n Gives a string consisting of the last n characters of a$. Here's the definition of the right$() function from the Praat manual: Using Praat's built-in string functions I could, for example, get the right 3 characters in a file name and see if they are "wav" by using the right$() function. My folder also contains a bunch of files that are not sound files I'm interested in, so I know there's going to be a part of my script that checks if the file ends in "wav" before asking Praat to open it. It's generated a bunch of files, and I want to open up each sound file and do something to it in my script. Let's say I ran an experiment using some software like PsychoPy or E-Prime. You could use these, for example, to dynamically create file names, or to separate a complex string like "01-e-23.wav" into smaller parts. String functionsīeyond simply combining strings, Praat has a bunch of really useful functions that we can use to parse and manipulate strings. It can be a real pain at first, but getting comfortable with manipulating strings programmatically (regardless of programming language) is a very powerful skill set that will serve you for the rest of your life as a researcher. We want to get good at dealing with strings. Manipulating and searching for words: More advanced string operations Send me an email encouraging me to fix it. This was written a long time ago and needs to be revised.
