If it doesn’t exist, Praat will create it for you. Much like appendInfoLine:, you can use appendFileLine: in order to write your output for a file rather than the Praat info window.įirst, specify your file name. This code will read in all the TextGrids into you Praat Objects window, as shown in Figure 9 below. Speakers = Create Strings as file list: "list", directory$ + "*.TextGrid" # where your textgrids liveĭirectory$ = "/Users/lisalipani/desktop/sample_recordings/" Then, you can use a for loop to read in all the files. TextGrid extension Praat will get it’s file name). This is accomplished in line 9 of the code below ( speakers = Create Strings as file list: "list", directory$ + "*.TextGrid") by using the wildcard, *, which just means any character any number of times (in this case, as long as a file has the. To read in a large number of files, I ask Praat to find all the files in a certain directory that have a. The output of this code is given below in Figure 8. One common mistake is forgetting to end if statements and for loops, so don’t forget to use endif after all your if/elsif/else statements, and endfor at the end of the code you want to repeat. Start = Get starting point: phoneTier, each_intervalĮnd = Get end point: phoneTier, each_intervalĪppendInfoLine: "The phone is " + phone$ + " and the type of sound is " + type$ + "." Phone$ = Get label of interval: phoneTier, each_interval phoneTierįor each_interval from 1 to number_of_intervals Number_of_intervals = Get number of intervals. See more about string functions in Praat in the manual. We actually don’t care about where it matches, but since it will return a number, the if statement will evaluate it as true. The function index_regex() finds where the second argument (the regular expression) matches the first argument (the string). We’ll also define a blank regular expression that will match the blank spaces by matching with nothing between the start of the string (^) and the end of the string ($). All vowel sounds in ARPAbet start with either “A”, “E”, “I”, “O”, or “U”, so we can use the regular expression to match any of these characters. For example, the regular expression would match “a” or “b”, or “c”. You also need to know that brackets () represent optionality. For example, the regular expression “a” would match “a”, “ab”, “abc”, “ba”, “cba”, but the regular expression “^a$” would only match “a”. For this example, you need to know that the caret (^) is a special character that anchors the match to the begining of the string, and that the dollar sign ($) is also a special character that anchors the match to the end of the string. A regular expression is a way of defining a search pattern. You can learn more about this in the “Regular Expressions” section of the Praat manual. To accomplish this, you also need to know that you can substitute an argument for a variable, and also that you can match a variable to a thing called a regular expression. For example, say you wanted to categorize phones by if they are stops, vowels, or other consonants. The else statement provides code to run if neither the if nor elsif statement is true. The elsif statement provides another condition (and other block of code) to run if the elsif statement is true. In addition to if statements, there are also elsif (short for else if), and else statements. This code will print the duration of the second segment of the phone tier (i.e. the first tier) to the Praat info window, as shown in Figure 4 below. Start = Get starting point: phoneTier, labelIntervalĮnd = Get end point: phoneTier, labelInterval Unzip the zip file, and load TextGrid WS006-Stephanie into Praat. To follow along, go to Joey’s website and download “Sample Audio”. NB: Do not start a variable with a capital letter or a number! Praat will return an error. text$), while a variable that is a number does not contain a dollar sign (e.g. A variable that contains a ‘string’ (a sequence of characters) is notated with a dollar sign after the variable (e.g. There are two types of variables in Praat. This example also introduces you to appendInfoLine which provides output by appending to the Praat info window. Then, Praat will get the label of the interval, find the start and end point of the interval (and thus, we can calculate duration). This script requires you to have already opened your TextGrid with Praat.įirst, we’ll tell Praat where our tiers are and rename our TextGrid so that if you have to change your tier numbers or TextGrid name later, you only have to do it once at the top of your script. You could also get the duration of a segment using a script.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |