FAQ: Scripts

Question: how do I do something to all the files in a directory?

Answer: look at Create Strings as file list....

Question: why doesn't the editor window react to my commands?

Your commands are probably something like:

Read from file: "hello.wav"
View & Edit
Zoom: 0.3, 0.5

Answer: Praat doesn't know it has to send the Zoom command to the editor window called 14. Sound hello. There could be several Sound editor windows on your screen. According to Scripting 7.1. Scripting an editor from a shell script, you will have to say this explicitly:

Read from file: "hello.wav"
View & Edit
editor: "Sound hello"
Zoom: 0.3, 0.5

Problem: a line like "Number = 1" does not work.

Solution: names of variables should start with a lower-case letter.

Question: why do names of variables have to start with a lower-case letter? I would like to do things like "F0 = Get mean pitch".

Answer (using the shorthand script syntax): Praat scripts combine button commands with things that only occur in scripts. Button commands always start with a capital letter, e.g. "Play". Script commands always start with lower case, e.g. "echo Hello". A minimal pair is "select", which simulates a mouse click in the object list, versus "Select...", which sets the selection in editor windows. Variable names that start with a capital letter would be rather ambiguous in assignments, as in "x = Get", where "Get" would be a variable, versus "x = Get mean", where "Get mean" is a button command. To prevent this, Praat enforces a rigorous lower-case/upper-case distinction.

Question: how do I convert a number into a string?

Answer: a$ = string$ (a)

Question: how do I convert a string into a number?

Answer: a = number (a$)

Links to this page

© ppgb, January 20, 2014