|
Just as you can use menu commands (usually in a Query submenu) to query numbers, you can query texts as well.
For instance, when you select a Textgrid, the Query submenu will contain the command Get label of interval..., which takes two numeric arguments, namely Tier number and Interval number:
When you click OK, and interval 3 of tier 1 happens to contain the text hello
, the following appears in the Info window:
In a script, you will want to put the result of the query in a string variable instead of in the Info window, because you want to manipulate it further:
text$ = Get label of interval: 1, 3
writeInfoLine: “The text in interval 3 of tier 1 is: ”, text$
The script first stores the text of the interval, i.e. hello
, into the variable text$, then writes it, preceded by some informative text, into the Info window:
Hey, yet another way to implement “Hello world” with the Praat scripting language!
A string query stores in a string variable the whole text that would appear in the Info window. For instance, the script
power$ = Get power: 0.0, 0.0
writeInfoLine: power$
could give you the following result:
A numeric query stores in a numeric variable only the first number that it can find in the text that would appear in the Info window. For instance, the script
power = Get power: 0.0, 0.0
writeInfoLine: power
could give you the following result:
© ppgb 20221202