An alternative to a form would be to specify the values directly in the script, and change them manually when we run it, like this (note the differences involving $ and quotes): sound_file$ = "myname" Also, we don’t use quotes for text strings, because Praat is expecting text. Note that the string variable name doesn’t have $ at the end, but when we refer to it later (e.g., in line 20) we will use the $. The next three lines indicate three variables that we will define and give values to, specifying the type of variable (“sentence” for strings, “positive” for positive numbers), the names of the variables, and their default values. The first line indicates that this is a form, and specifies what text is to appear in the window. When the script is run, the commands on lines 10-14 will cause a window to open and prompt the user for the name of the sound file, the two formant tracking parameters: form Measure formant values for segments in a textgrid FORMSįorms are a convenient way of giving information to the script. Lines 36-40 show some simple arithmetic with numeric variables. To see some of them, open the manual and search for “numeric” or “string”. The Praat manual (Help… Praat Intro) contains a lot of information about things you can do with variables. In this way, the function of single quotes is the opposite of the function of double quotes. The single quotes indicate that sound_file$ is the name of the variable, not the name of the Sound object. If you have already set the value of the string variable sound_file$ to “myrecording”, then this (line 20) is equivalent: select Sound 'sound_file$' Some functions expect strings to be entered directly, i.e., if you have a Sound object called myrecording in your object list, you can select it like this: select Sound myrecording Lines 51 and 53 both give a value to a string variable, one by directly giving a value (in double quotes), and the other by using a function that reads a TextGrid label: left$ = "#"Īfter a string variable has been defined, it can be used interchangeably with its value, i.e., these two lines are equivalent, if left$ has already been defined as #: newstring$ = left$ In the praat scripting language, variable names always start with lowercase letters, and string variable names end with the dollar sign ($). Line 25 creates a numeric variable named intervals and sets its value to the number of intervals in tier 1 of the TextGrid (which is a number). Line 30 creates a string variable named phone$ and sets its value to the label of a TextGrid interval (which is a text string). Two important types of variables in Praat scripts are string variables (for text) and numeric variables (for numbers).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |