Praat scripting tutorial

Boolean variables and data type

This one's going to be short and sweet. Another data type we need to know about is the boolean type. That's just a fancy way of saying true or false (yes or no / binary / 0 or 1). In Praat, 0 means false and 1 means true.



# This is a boolean variable
# with a value of false.
# In Praat's language it's 
# just like a number, so 
# no quotes, no dollar sign
wearingPants = 0

We will often use this when we create logical conditions in our scripts. For example, we might want something like "if interval label is blank, do nothing". The types of conditional tests we run there will evaluate to true or false. So we'll be asking Praat a question, like "Does this file exist?", and it will respond by saying "0" or "1" (presumably in a robot voice ... with a Dutch accent).

The check boxes in Praat's dialog windows are also graphical representations of boolean values. If it's checked, then its value is 1, if it's not checked, its value is 0. But we're getting ahead of ourselves...

Next page: Praat commands