Document Version: 1.1.1
Last Update: January 3, 2012
Important!
This document will be continually updated and improved. Download the latest version at:
Praat is a wonderful software package written and maintained by Paul Boersma and David Weenink of the University of Amsterdam. Available for free, with open source code, there is simply no better package for linguists to use in analyzing speech.
Unfortunately, much of the existing documentation for the software is just that, software documentation, and is not designed to help linguists (who may not necessarily consider themselves to be "phoneticians" or have a strong phonetics background) get the measurements and make the changes that they need and desire for their research.
As such, rather than introducing each menu item and function as such, I've instead chosen to describe how to do some of the tasks that linguists want to do without assuming a strong phonetics or programming background. Then, eventually, we'll discuss some of the more complicated measures and tricks one can perform with Praat.
Of course, no one workshop can discuss the myriad of features present in Praat, nor cover all of the quirks of the package, but this workshop will hopefully leave you feeling more at home in Praat, and give you an opportunity to go forth and explore further on your own.
This guide will assume that you are using a relatively recent build of Praat (5.2+), and there's no reason not to download the latest version whenever released. All screenshots will be from Praat 5.2.27 running on Mac OS X, but your copy on your platform should not di er signi cantly. Unless otherwise speci ed, work ows for making measurements and manipulations do not di er signi cantly across platforms.
Although this guide aims to be painfully comprehensive, there are many other resources available for helping with Praat. The rst step for dealing with any issue is Praat's built in help guide, accessible from the upper right corner of most windows in the program. You'll be best served by starting with "Intro" and moving from there.
There are also a variety of tutorials for Praat available online, and the Yahoo! Groups "Praat-users" group, whose archives can be searched at the below link:
http://uk.groups.yahoo.com/group/praat-users/
Praat can be downloaded from http://www.praat.org, and its installation will vary depending on your platform.
Once you've opened Praat, a variety of windows will open automatically, and there are many other windows which will pop up when using the software. It's best to discuss these now so we can refer to them by name later when discussing the path to certain commands.
The Praat Objects window (Figure 1) is where you'll start most work ows, using this menu to open, create and save les, as well as to open the various editors and queries which you'll need to work with sound les.
The Editor window (Figure 2) is where you'll spend most of your time, and can be accessed by selecting a sound and choosing "View & Edit". When examining a sound le, the editor window will show the sound's waveform on the top and a spectrogram on the bottom, and the cursor will allow you to take selections and measurements. The menus along the top will allow you to show and hide di erent bits of information (formants, pitch, intensity), as well as to make more detailed queries. When working with other types of Praat objects (e.g. spectra), the editor window will allow you to query those objects as well.
When you make a query, either in the editor window or from the objects window, the Info Window will pop up with your results. You can also print to this window when scripting in Praat (see Section 11). Note that information printed here will not necessarily be saved, and running a new query will overwrite it by default.
The Praat Picture window (shown towards the end of the document in Figure 10) is used to create and display publication-quality images, and is open by default when you start the program. For detailed information about using the Pictures window and why it exists at all, see Section 8.
Knowing the names of all these commands allow us to more easily describe the commands to use when working with Praat. For instance, if this guide says that you get the duration of a sound by using Objects →Query →Query Time Domain →Get Total Duration, that means, roughly, "Go to the Objects window, Choose "Query", then from that submenu choose "Query Time Domain", then "Get Total Duration"".
To record sound using Praat, you'll want to plug in your microphone, sound card, or external ADC (Analog-Digital Conversion) box to your computer before starting Praat, and then...
Objects →New →Record Mono
This will pull up a recording menu which allows you to choose a sampling frequency (the default, 44100 Hz, is ne for most purposes), a microphone or other sound source, and whether to record a mono or stereo sound. Press Record to record, and Stop to stop, being careful that the sound level bar stays within the "green" range to avoid clipping. Once you've made a recording, name it and choose Save to list, and it will now show up in the Praat objects window where it's ready for editing.
If you don't see a green bar (indicating that Praat hears you) while you are recording, try changing the Input source on the left side of the SoundRecorder window. If this doesn't help, go to the computer's sound control panel to ensure the proper microphone is selected, and that the input volume is not turned way down.
Praat only records in one minute long chunks out of the box. To record longer sounds, you can either change the bu er size in Praat →Preferences →Sound Recording Preferences or you can use Audacity (free, available from http://audacity.sourceforge.net/) to record the session and then import the sounds into Praat (see Section 5) afterwards for analysis and manipulation.
If you already have a sound le recorded that you'd like to open (recorded in .ai , .wav or . ac format), there are two ways to open it in Praat. If you're using Praat on OS X, you can drag supported les onto the Praat icon in the dock. However, if that doesn't work, or if you're on a di erent platform:
Objects →Open →Read from File...
Then use the next dialog to nd the les you're interested in on your hard disk. Once you've loaded the les, they'll appear in your objects window for further use. Note that other les created by Praat can be opened in the same way.
Tip: Praat can't open .wma, .mp3 or .m4a audio les. To convert these easily to .wav les en masse, download iTunes, set it to import les in .wav or .ai format in Preferences, and use iTunes →Advanced →Create .wav version.
Praat has historically had trouble working on sound les more than 20 minutes long, and if you're using a 32-bit version or have little available memory, you may experience frequent out-of-memory errors working with large les unless you use the Objects →Open →Open long sound le... option. However, sounds read in as Long Sound objects cannot be used for all measurements. It's recommended to cut your les into chunks shorter than an hour, either using Audacity or by editing the Long Sound object as described in Section 7.2.
Praat does not save anything by default, and until you save les explicitly, opened or edited versions of the les will exist eetingly in the objects window. For emphasis, unless you save les explicitly, they will disappear completely and unrecoverably when Praat is closed.
To save a le, select the le in the Objects window, then...
Objects →Save →Save as _____ le
For sound les, you'll likely choose Save as WAV le, but for the other types of les (textgrids, formant objects, pitch objects, etc), you'll save them as text les.
As this can be very tedious, you might consider downloading and installing a Praat script (see Section 11) which saves all the objects in the objects window at once.
Once a sound has been recorded or opened, you'll spend much of your time interacting with the sound by means of the Editor window. To open a sound in the editor window, select the sound and then...
Objects →View & Edit
You're immediately presented with an editor window (like that in Figure 2), showing the waveform of the sound, and if the sound is su ciently short, a broadband spectrogram showing the spectral energy of the sound over time. In addition, you might also be presented with a series of red dots (representing formants), blue lines (representing the speaker's pitch), and a yellow line (representing intensity). These can be enabled and disabled in the Editor →View →Show Analyses menu.
Clicking within this window will place the cursor on the waveform and spectrogram. If you click within the editor window, the cursor will spawn two dotted lines. A vertical bar shows the time within the sound where you clicked (labeled at the top in seconds) and, if you clicked within the spectrogram, a horizontal bar shows the frequency at the cursor (labeled on the left in red). If the pitch or intensity tracks are displayed where the cursor is placed, values at the time the cursor represents are given on the left side of the editor window.
In addition, you can click and drag (or use the Select menu) to select portions of the sound. The time of the start and nish of the selection will be displayed in red, and the duration of the selection (in seconds) will be displayed in the top of the bar.
To play a sound in the editor window, use the three gray bars at the bottom of the editor
window. The bottom-most bar (Total Duration) will play the entire sound. The middle bar
(Visible Part) will play only the visible portion of the sound. The di erent sections of the top
bar (split by the cursor or selection), when clicked, will play the corresponding pieces of
the visible portions of the sound le. Hitting Obviously, to view some analyses and to get a closer look at your data, you'll need to use the ve
buttons in the bottom left corner of the window. As you can imagine, all shows the entire le, in and
out zoom in and out, sel zooms to make the current selection ll the window, and bak zooms
back to the previous zoom level. For longer sound les, in order to view analyses like the
spectrogram and formants, you'll need to zoom in to show only a pre-de ned amount of
time.1
The Group setting in the bottom right corner of the window will ensure that if two sounds are open
in Editor windows at once, they'll share the same zoom characteristics. This is best used to compare
two versions of the same le, say, an original versus one with an acoustic modi cation
made.
All of the measures discussed in this section will use the Editor window, and you will spend much of
your time working with Praat here, so any time spent gaining familiarity will be repaid in
spades.
Although zooming in and out will get you most of the way there, it's often useful to isolate a section
of a sound (usually a single word or vowel) into a di erent Sound object. To do this, select a portion
of a sound, say, a vowel, and then:
Editor →File →Extract Selected Sound (time from 0)
This will create a new sound in the Objects window, containing just the selected part of the original
sound. The (preserve times) option (in the same Editor →File menu) just keeps the timecode on the
extracted sound the same as in context (so, if the vowel starts at 0.245 s, the extracted sound le will
start at 0.245 s).
This can also be done from the objects window using Objects →Convert →Extract part...
Although the basic 0-5000 Hz broadband spectrogram will su ce for many uses, it's useful to be able
to change those settings. To make changes to the spectrogram settings...
Editor →Spectrum →Spectrogram Settings
This will pull up the Spectrogram settings window (like that in Figure 3)
The most important settings here are the window length and view range.
View range controls how much of the spectrum is visible. For speech, you'll likely be interested
in the range from 0 to 5000 or 6000 Hz, but if you're examining fricatives, you might
want to look as high as 15,000 Hz. If you're looking at music, you may focus on the area
from 100 to 2000 Hz. Either way, this is how you set which part of the spectrum you care
about.
If your sound les have a relatively small or large dynamic range (the di erence in volume between
the loudest and quietest parts), or if your spectrograms seems too light or too dark, you may want to
adjust the dynamic range setting here, but 50 dB is usually safe.
Window length (given in seconds) controls how large of a chunk of the sound Praat will
examine when trying to nd the frequencies present at a given moment in the signal.
Looking at a larger window of the sound will give more accurate information about the
frequencies present, but will also reduce the accuracy of the temporal information given.
Varying the window length allows you to choose between Broadband and Narrowband
spectrograms.
Praat defaults to showing a Broadband spectrogram, which is excellent for viewing the temporal
structure of the sound and for seeing vowel formants, but sometimes, you'll want to look at
harmonics and F0 instead. To do this, you'll ask Praat to provide you with a narrowband spectrogram.
To do this:
Now, harmonics should clearly be visible in the spectrogram. To return to a broadband
spectrogram:
And you'll be back to the default broadband spectrogram.
As you might expect, measuring duration is quite easy. Once the sound le is open in the Editor
window:
If you'd like the duration of an entire le, just select the le in the Objects window and:
Objects →Query →Query Time Domain →Get Total Duration
F0 and Pitch can be measured in a number of ways in Praat, more and less reliably.
The surest way to get an accurate F0 for a single cycle is to open the le in the Editor window,
then:
The most reliable way of getting a sense of the pitch through the course of the word in Praat is by
examining a narrowband spectrogram with a reduced visible range (0 - 400 Hz for speech). This can
be done by editing the spectrogram settings as described in Section 6.2. The contours of the
harmonics will accurately represent the pitch contours of the voice during the word, and doing this
will give you a sense of the contour before using the Praat pitch tracker for more precise
measurement.
Praat does have the ability to provide a pitch track in the editor window. To enable the pitch track in
the Editor window:
Editor →Pitch →Show Pitch
At this point, a blue line will be placed on top of the spectrogram representing the pitch, where Praat
can nd it. Once the pitch track is placed, you can use the cursor to check the pitch at any given point
in the word. Just place the cursor and look for the middle blue number on the right side of the
window. You can also place your cursor at a given point in the le and Editor →Pitch →Get Pitch.
Running Editor →Pitch →Get Pitch when a chunk of the sound is collected will return the average
pitch during that selection.
It's worth noting, though, that Praat's pitch tracking can be quite nicky. You will often see it jump up
and down, doubling and halving the actual F0, and in many cases, especially where the
speaker is at all creaky, the pitch track will drop out altogether. This does not represent any
speci c failing of the software, but instead, comes from the variability and noise inherent in
actual phonetic data. Part of the strength of Praat's approach is that you as a user can help
Praat improve its pitch tracking for a given le or speaker by changing some of the Pitch
settings.
So, in order to do any serious research using the pitch track, and to avoid some of the problems
discussed above, you may need to adjust some of the pitch settings, to help Praat's pitch tracker better
re ect the speaker's voice. To do so:
Editor →Pitch →Pitch Settings...
Then adjust the settings as follows:
You may want to tweak the advanced settings as well. To do so:
Editor →Pitch →Advanced Pitch Settings...
Then adjust the settings as follows:
Praat's pitch tracking is a good way to get a rough idea of what's going on with the
speaker's F0, but relying on it to give you sane measures is not wise, especially in
scripts. Make sure you sanity-check any measures which seem unreasonable against
single-cycle F0 measurements or against harmonic frequencies, and that you throw
out anything completely ridiculous.
If you're not scripting, disregard this section. Working from a pitch object will win you nothing in a
human-centric work ow.
When scripting, you may want to create a Pitch object (select the sound, then Objects →Periodicity →
To Pitch, specifying the proper range) so that you don't need to open the editor to measure pitch.
Once a pitch object is created, you can instead select the Pitch object and run Objects →
Query →Get value at time... to nd the pitch at whatever time you'd like. Pitch in a pitch
object is calculated in the same way as in the Editor window, so the same disclaimers
apply.
This is easy.
Note that Editor →Pulses →Voice Report will give this information as well.
As a part of its pitch-handling system, Praat includes the ability to nd individual glottal pulses in a
signal and to analyze the pulses as part of more complex analyses. To view these pulses, Editor
→Pulses →Show Pulses, and they'll then display on top of the waveform in your le.
Although the pulses themselves are mostly only useful in scripting, the Editor →Pulses
menu contains one of the more useful commands in the program: Editor →Pulses →Voice
Report
To use this command, simply select a voiced section of the sound, then Editor →Pulses →Voice
Report. An information window will then pop up providing you with a variety of useful measures. In
addition to maximum and minimum pitch (with additional statistics), you will also be given the jitter,
shimmer, harmonics-to-noise ratio (HNR), and the noise-to-harmonics ratios for the selected
portion of the sound.
Jitter is a measure of the periodic deviation in the voice signal, or the pitch perturbation of the
signal. Put di erently, each cycle of speech with a given F0 should, in a perfect world, have the same
period. The jitter in a person's voice is how much one period di ers from the next in the speech
signal. This is a useful measure in speech pathology, as pathological voices will often have a higher
jitter than healthy voices.
Shimmer (amplitude perturbation) is similar to jitter, but instead of looking at periodicity, it
measures the di erence in amplitude from cycle to cycle. Once again, this is a useful measure in
speech pathology, as pathological voices will often have a higher shimmer than healthy
voices.
Harmonics-to-noise ratio (HNR) and Noise-to-harmonics ratio are both measures of the amount of
periodic noise compared to the amount of irregular, aperiodic noise in the voicing signal. Because the
aperiodic noise often represents frication in the vocal tract, the HNR will go down signi cantly with
hoarse or breathy speech, and other laryngeal pathologies will lower the HNR further
still.
Praat has several methods of built in formant measurement. Of course, the easiest way to examine
formant heights is by simply looking at a broad-band spectrogram and using the cursor to nd,
roughly their frequencies. However, "eyeballing it" won't pass scienti c muster, and is
more time consuming than using Praat's built-in LPC algorithms as a tool to help to nd
them.
When you open a sound le in the Editor window, you can choose to have Praat calculate and display
where it thinks that the vowel formants are (Editor →Formants →Show Formants). This will overlay
a series of red dots onto the image which represent peaks in the series of LPCs which Praat has
run.
This formant track can be queried at any time in a variety of ways, all accessed through the Editor
→Formants menu. If you're interested in a single formant's height, you can place the
cursor where you want a measurement and choose Editor →Formants →Get formant...,
but it's often more e cient to use Editor →Formants →Formant Listing, which will give
you heights for F1, F2, F3 and F4, along with the timepoint at which the measures were
taken.
In addition, if you're interested in formant bandwidth, bandwidth for the rst four formants can be
taken using the Editor →Formants →Get ___ Bandwidth commands.
For hand measurement, using Editor →Formants →Formant Listing and sanity-checking
by visually inspecting the formants on the Spectrogram will usually produce reasonable
results, but there are ways to improve Praat's formant-picking performance for a given
speaker.
For most speakers, the default settings will su ce, but if you nd Praat to be struggling with "missing"
or the addition of extra formants, you'll likely nd that that particular speaker's formants are more
e ectively measured if you make some tweaks to Praat's Formant Settings, helping the computer with
its task.
To apply any of these changes, you'll want to open the Formant Settings window (see
Figure 4):
Editor →Formants →Formant Settings....
Praat has to make a series of guesses about how many formants it will nd, and how spread out those
formants will be. We typically will assume that speakers will have one formant per 1000 Hz, and thus,
that there will be 5 formants in the 5000 Hz we usually worry about for speech research. Thus, "5" is
the default setting for Number of Formants, and the highest we'll look for formants (the Maximum
Formant) is 5000 Hz by default.
Usually, you'll only need to adjust the Number of Formants. Although 5 formants is a good
baseline, if Praat is nding formants where there are none (between two actual formants,
usually), you should lower this value down to 4 or 3. If Praat is nding too few formants
(missing F2 and labeling F3 as F2, for instance), you'll want to raise this number up to
6.
If you're working with a child, a person of unusually small stature, or somebody with an otherwise
tiny vocal tract, you may nd that the Praat is nding non-existent formants between the speaker's F1
and F2, and missing the speaker's higher formants (F3 and F4) altogether. In this situation, you'd
want to increase the Maximum Formant (Hz) value to tell Praat to search a bit higher up
in the spectrum for formants, and perhaps lower the number of formants it's searching
for.
Realize, though, that Praat can always nd more peaks, and there are often small peaks not
perceptible to humans which may still have an acoustical relevance. When there are "too many
formants", Praat is not necessarily nding formants which "aren't there", but is nding additional
peaks which, although present, aren't the F1, F2 and F3 peaks which we as linguists are chie y
interested in. When there are "too few", Praat is just giving you only the most prominent peaks that
you've asked for. The results of Praat's formant tracker, in reality, are largely determined by what
you're asking it to nd, and this settings adjustment be done with a mind to what you're actually
interested in.
Dot size (mm) simply controls how large the red dots in the formant display are. Although changing
this can be useful if the track obscures the spectrogram, this will have no e ect on your
measurements.
Just remember, these settings persist even once you've closed Praat, so if you make adjustments here,
you'll want to return these settings to the defaults when you've nished with your odd
speaker.
No matter your settings, Praat will happily nd you formants even in fricative noise
or silence, and because it doesn't know how many formants it should be searching
for where, it commonly merges F1 and F2 for high back vowels (where they're close
together). In addition, Praat will often have issues nding a single timepoint, so if
you're getting an unusual measurement, a timepoint shortly before or after may be
more accurate. Always sanity-check your measurements, make sure you know what
you're measuring, and during automated measurement, always run the results by a
trained human rst! If you're not scripting, disregard this section. Working from a formant object will win you nothing in a
human-centric work ow.
When scripting, you may want to create a Formant object (select the sound, then Objects →Formants
& LPC →To Formant (burg)..., specifying the proper settings as described above) so that you don't
need to open the editor to measure formants. Once a formant object is created, you can instead select
the Formant object and run any of the commands in the Objects →Query menu to get
information.
Oddly, formant measures taken at the same timepoint and with the same settings from a
formant object and from the editor window do not always agree, and in fact, can di er
signi cantly. If measuring formants automatically, you may consider using both methods (the
formant object and the editor window's formant track). It often happens that if one of the
measurement tactics misses or adds a formant, the other will not, so a measure where both are
in agreement is often more trustworthy than one where they disagree signi cantly. The
author cannot explain the discrepancy, but is quite happy to leverage it extensively in his
scripting.
Measuring intensity in Praat is relatively straightforward, albeit with a major disclaimer.
To get the overall intensity of a sound, select the desired sound and run Objects →Query →Get
Intensity (dB). To get the intensity at a speci c point in the sound, open it in an editor window, Editor
→Intensity →Show Intensity, and then use the various commands available in the Editor →Intensity
menu to get whatever information you desire.
That said, in most recordings made for phonetic research, absolute intensity measures as given
by Praat are largely meaningless. To accurately measure the absolute intensity of a speaker's voice,
a sound-attenuated booth with a calibrated sound level meter or calibrated microphone with
specialized software should be used. Relative intensity (say, between two segments or words) can be
measured with an uncalibrated microphone, but is only truly accurate if the recording is made
in a consistently quiet area, and the speaker stayed in the same position relative to the
microphone throughout the recording(s). This issue is discussed in depth in Praat's user
manual.
Sometimes, you need speci c details about the frequencies and individual harmonics in a sound at a
given moment in time, and examining a narrowband spectrogram alone does not provide su cient
information. In these cases, you'll need to take a spectral slice for analysis. Spectral slices (also
referred to as FFTs or spectra) are the result of a fast fourier transform done on a very small portion
of the sound, providing you with very speci c information about the frequencies present in the sound
and their relative amplitudes.
Spectral slices are useful for a variety of measures of F0, nasality, creak, breathiness, and spectral tilt,
and are a crucial part of many measurement work ows.
To take a spectral slice, you'll need to do the following:
This will create a new Spectrum object, and pull up a window like that in gure 5, showing
amplitude on the Y axis, and frequency (from 0 up to the Nyquist frequency) on the X axis. You can
zoom in and out using the buttons in the bottom left corner, as you wish.
If you've selected a portion of the sound (rather than a single timepoint) when you use Editor →
Spectrum →View Spectral Slice, Praat will create a spectrum representing the average characteristics
across the entire selection, which isn't useful for most of the spectral measures discussed
below.
Getting harmonic frequency and amplitude in a Spectrum Editor window is fairly straightforward, as
clicking anywhere within the spectrum editor window will give you the frequency and amplitude
measurements at the cursor. So, to nd the amplitude and frequency of a given point in the spectrum,
click that point and read o the amplitude (on the left) and the frequency (at the top), as shown in
gure 5.
This can be done even more easily and e ciently by script, allowing you to nd the highest point on a
given harmonic without clicking guesswork.
Spectral tilt is often used in phonetic research as a measure of creak. As discussed in Gordon and
Ladefoged 2001 [?]:
One of the major acoustic parameters that reliably di erentiates phonation types
in many languages is spectral tilt, i.e., the degree to which intensity drops o as
frequency increases. Spectral tilt can be quanti ed by comparing the amplitude of the
fundamental to that of higher frequency harmonics, e.g., the second harmonic, the
harmonic closest to the rst formant, or the harmonic closest to the second formant.
Spectral tilt is characteristically most steeply positive for creaky vowels and most
steeply negative for breathy vowels. Spectral tilt is easily measured by nding H1 and H2, measuring their amplitudes as described above,
and comparing the two numbers.
A1-P0 is an acoustical measure of nasality rst described by Marilyn Chen in Acoustic correlates of
English and French nasalized vowels ([?]). Like spectral tilt, it's a ratio measure of the amplitudes of
two harmonics: A1, which is the highest harmonic peak near the rst formant, and P0, which is a low
frequency harmonic (usually H1 or H2) which corresponds to a low resonance in the nasal passages.
See Figure 6 for an illustration of these peaks in spectra. To compute A1-P0, you need to take three
main steps3:
Because the nasal peak (P0) will be reinforced by the resonances in the nose during nasal vowel
production, nasal vowels will tend to have lower A1-P0 values than non-nasal vowels. Across many
tokens, A1-P0 can be a very good predictor of vowel nasality, however, there are several important
things to keep in mind when using A1-P0 to measure vowel nasality:
Spectral center of gravity (Spectral COG) is useful for measuring the frequency characteristics of
aperiodic sounds in speech (release bursts and fricatives, usually). It is most often used to describe
the production of fricatives (with the understanding that sounds with a higher spectral COG are often
produced more towards the front of the mouth), and simply measures the overall weighting of the
noise in the spectrum by reporting its "center of gravity". See Figure 7 for a more visual
demonstration. This measure can be useful in sociophonetic work, as well as in eldwork, for
determining the articulatory positions of di erent fricatives.
To measure spectral COG in Praat:
An info window will then pop up, presenting you with the spectral COG for the point represented by
the spectrum.
For further information about Spectral Center of Gravity and an example of its use in fricative description
and cross-linguistic comparison (showing the occasionally rocky relationship between articulation
and spectral COG), refer to Gordon et al 2002 A cross-linguistic acoustic study of voiceless fricatives.
[?].4
For an example of this measure used in discussing gender di erences in spectral COG, refer to
Jane Stuart-Smith's Empirical evidence for gendered speech production: /s/ in Glaswegian.
[?]
To create a sound from formula (a pure or complex tone) , you'll want to use:
Objects →New →Sound →Create sound from formula...
There, you can plug in a formula which will generate the sound you want. For instance:
To create a 1000 Hz puretone at 0.5 dB:
To create a 250 Hz puretone at 1 dB:
To create a complex sound with 1 dB components at 250 and 1000 Hz:
For more information, see the Praat Help guide's excellent Formulas Tutorial. To create a sound with
harmonics, use Objects →New →Sound →Create sound from tone complex...
It's not unusual to need to move, remove, or copy sound within and across di erent sound les, and
luckily, Praat makes that relatively easy. Most le editing is done with a combination of selection,
copying and pasting.
However, producing quality splices is not as straightforward as copy and pasting within a word
document. Because sound waveforms are continuous, you need to make sure that all the cuts you're
making occur at the same point in the cycle, namely, at the zero crossing. Failure to do so will result
in loud pops or clicks in the resulting le. To ensure that you're being zero-crossing friendly, following
the below steps (substituting "Ctrl" (the "control" key) for "Cmd" (the "command" key) if you're using
a Windows or Linux machine):
To copy/paste a portion of the sound le:
Following these steps will cleanly insert the snippet into the word. Given time, you'll develop muscle
memory and nd yourself quickly typing "Cmd + , Cmd + . Cmd + c" to copy and "Cmd + 0 Cmd +
p" to paste. Copy-pasting can be done either within the same le, or between two di erent les in
Praat.
This can also be done from the objects window using Objects →Convert →Extract Part
To delete a portion of a le or to remove silence, you'll select, again attending to zero crossings, and
use the "Cut" command (without pasting anywhere else):
To delete a portion of the sound le:
Unfortunately, Praat doesn't include an easy way to trim, splice or cut portions of the le from the
objects window, meaning that any scripts will have to use GUI scripting (the computer controlling the
mouse/selection tool) on the Editor window, telling the Editor what to select, then to cut, etc. This
works well, but is slightly less e cient than is desirable. Some progress can be made from the Objects
window alone by using a combination of Objects →Convert →Extract Part and Objects →Combine →
Concatenate to, e ectively, create new sounds which resemble a cut or trimmed sound, but this can be
quite counterintuitive.
If Praat won't let you copy and paste a chunk between two les, the les may need to be resampled
to match.
Praat is very picky about the sampling rates of the les it works with. When combining sounds or
copy/pasting from one le to another, both sounds will need to have the same sampling
rate.
To get the sampling rate of an existing le:
To resample a sound le (e.g. change the sampling rate from 44,100 Hz to 22,050 Hz):
Not all changes you'll want to make involve parts of les. Sometimes (for perception experiments and
otherwise), you'll nd it necessary to lter your sound les.
Often, sounds les will have extraneous background noise, or in the case of particularly
low-frequency-sensitive microphones, room noise not blocked by sound attenuation. In those cases,
you'll want to lter the sound le to remove it:
Low-pass lters are useful for simulating high-frequency hearing loss and cellular phone speech,
among other things. They remove all signal above a given frequency.
To low-pass lter a sound le (e.g. removing all sound above 2000 Hz):
High-pass lters are useful for removing low frequency noise from recordings (which might seep
through a sound-booth). They remove all signal below a given frequency.
To high-pass lter a sound le (e.g. removing all sound below 2000 Hz):
Band-pass lters (also called "Notch lters") are useful for removing sound in a very speci c band of
the spectrum. Notch lters are best suited for removing particular background noises with speci c
frequencies (e.g. computer fans, mains hum, or chair squeaking). Your bands will be wider or
narrower depending on the signal you're working to cut out.
To band-pass lter a sound le (e.g. removing all sound between 1500 and 3500 Hz):
Finally, note the Objects →Filter →Filter (Formula) option, which lets you lter sounds in a much
more speci c way than the two options above provide.
Praat does allow you to manipulate the speaker's pitch in already-recorded sound les.
To create a manipulation object (which allows you to change a sound's pitch and duration):
This will open a manipulation window (like the one shown in Figure 8). It shows you the pitch track
(in the center), as well as the waveform. The blue lines on top of the waveform represent pulses. This
window allows you to modify the duration and pitch of the sound by creating and moving pitch
points. A good rst step is stylizing the pitch contour which will change the detailed contour into
something more manageable.
Manipulation →Pitch →Stylize Pitch
If you still have too many points, select a few (by selecting a part of the sound) and go to
Manipulation →Pitch →Remove pitch point(s). If you need a di erent pitch point, place your cursor
where you want a point and Manipulation →Pitch →Add pitch point at cursor.
You can now drag the individual green pitch points around to raise and lower the speaker's pitch at
di erent points throughout the word, to great phonetic and comedic e ect.
To save the result of your manipulations, use Manipulation →File →Publish Resynthesis, and a
pitch-modi ed copy of the sound will be placed in the Objects window to be saved as
usual.
Note as well that Praat can use either LPC resynthesis (discussed later) or "overlap-add" resynthesis to
create the le. "Overlap-add" is actually PSOLA (Pitch Synchronous Overlap Add Method)
resynthesis, and will almost always produce more natural results.
When combining sounds, or creating perception experiment stimuli, it can be useful to match the
pitch contours of two sounds. Although one can attempt this in the Manipulation window
(as described above), it's far easier to use the below procedure to match the pitch track
automatically.
To give Sound A the same pitch pattern as Sound B:
Praat's pitch matching feature is only as e ective as its pitch tracking feature,
which means that both are suspect. Although the two sounds' pitch tracks will be
signi cantly closer following this step, they will not be identical, and there may be
artifacts and odd jumps left over. If you require the sounds to be exactly matched,
match them both to a completely at pitch generated by formula. (see Section 7.1)
It's useful, especially when splicing or sound combination is occurring, to be able to ensure that two
sounds are of the same overall intensity. This is not extremely accurate, and for precise perception
studies there are more complex methods, but for most purposes, this will produce a good amplitude
match.
To scale Sound A to the same average intensity as Sound B:
There are two ways to combine two sounds using Praat. The rst will sometimes work well,
and works best when both sounds are to be added equally and have the exact same le
length:
To combine (overlay) Sound A and Sound B:
This will often work, and if it does, that's wonderful. If you end up with odd or undesirable results
from this, move onto the next section and combine the two sounds using a formula.
Praat is quite capable of doing sample-by-sample mathematical operations on both individual les
and on pairs or groups of les. This is done using one of the most obtuse yet most powerful functions
available in Praat, Objects →Modify →Formula function.
Formula modi cation is best visualized by thinking about digitized sound. Remember that when
sound is digitized, the waveform itself isn't saved, but instead, the waveform is sampled (at the
sampling rate), leaving you with a series of times and the amplitude of the wave at that
moment.
So, to add two digitized waveforms, you simply move through the le sample-by-sample and compare
each sample. During waveform addition, if, at the 31st sample (e.g.), the amplitude of Waveform A is
at 28 and Waveform B is at -5, you add those two timepoints together (28 + (-5)), and in your
resulting sound le, the 31st sample will have an amplitude of 23. Because this moves
sample-by-sample, both sounds will need to have the same sampling rate, and need to be of the same
length.
Unfortunately, formula combination of sounds is among the least polished of Praat's features, but
don't let that scare you o . To do any formula modi cation:
This will then pull up a very technical looking input box, pictured in Figure 9. To actually make the
combination, you'll need to put into that box the formula which will be applied to the amplitude
value of each individual sample.
To make this process a bit more clear, let's imagine that we've got a le called sounda
and a le called soundb in our Objects window. You've gone through, made a copy of
sounda to work on, selected that copy, and then Objects →Modify →Formula. Here are
several formulas you could put into that window, and the e ect that each of them would
have:
Using the above as a template, you can create a formula to do nearly anything you'd like to your
sound waveform, both through the user interface or using Praat scripting.
Praat o ers the ability to synthesize sounds using a Klatt Synthesizer, an articulatory synthesizer, the
Vowel Editor and more. The use of these synthesizers is outside the scope of this class, but is well
explained in the Praat Documentation.
When creating stimuli for vowel perception experiments (as well as many other times), it can be
useful to generate vowels of a controlled quality. Although Praat includes both articulatory and
cascade (Klatt) synthesis, as well as the vowel editor, sometimes, it's important to maintain the vocal
characteristics of the recorded speaker. In these situations, you'll want to use Source-Filter vowel
resynthesis to alter the vowel's formant qualities without altering or replacing other signi cant
aspects of the signal. Source- lter resynthesis is most e ciently done by script, but can be done
step-by-step by hand if needed.
To understand both the process and the workings of source- lter resynthesis (SFR), it's
important to understand the source- lter theory of vowel production. This understanding
of vowel production holds that a given vowel is composed of two element: the source
(the voicing coming from the larynx), and the lter (the articulations and anatomy of
the vocal tract above the larynx). When the source signal passes through the vocal tract,
the resonances in the mouth heighten some frequencies and damp others. In this way, a
relatively unremarkable voicing spectrum, passed through a vocal tract with an /i/ tongue
shape, ends up with formants at 250 Hz, 2500 Hz, and 3000 Hz (your resonance may
vary).
Source lter resynthesis takes advantage of this idea to modify vowel qualities by taking the following
steps in the abstract:
Performing Source-Filter Resynthesis of a vowel in Praat:
This will output your new vowel, ideally, with the new formants. That said, this is a very nicky
process with lots of room for error, and it will require some work to get working cleanly. This is also a
situation where using a good Praat script can speed things up signi cantly, and allow the rapid
repetition of small changes to improve output.
Given some work, though, and some time, this can be an excellent way to modify vowel
qualities. For examples of this in use for stimulus preparation, contact the presenter or
examine the author's Establishing the Nature of Context in Speaker Vowel Space Normalization
[?].
To be completely honest, the fastest (and usually su cient) means of getting images from Praat for
documents or presentation is arranging the windows to display what you'd like, and then taking a
screenshot, which can later be cropped.
However, with a bit more work, Praat can be used to create and annotate publication quality graphs.
The Praat Picture window (Figure 10) is used to create and display images.
Using the Praat picture window can be thought of as a ve step process: Create an object, choose your
size, draw your object into the picture window, garnish, and export. To give a brief example, let's say
you'd like to export a spectrogram of sounda:
There is obviously much more complexity possible, but repeating (and adapting) the steps will yield
wonderful graphs for any publication. This entire process is quite easily scriptable, as
well.
For additional information about using Praat pictures, consult Jennifer Smith's
wonderful Printing and copying/pasting Praat Images handout, available at
http://www.unc.edu/~jlsmith/ling120/pdf/5images.pdf.
By creating sounds from formula (see Section 7.1) and combining them together
using waveform addition and subtraction (see Section 7.9), it's a breeze to create the
sorts of lightweight-yet-accurate waveform graphs needed when teaching and testing
students on the fundamentals of acoustics and waveform addition. Praat can't reliably tell where one word starts and where another ends. Nor can it nd the speci c
segment you're looking for, nor identify the vowel in the word. As such, you'll often need to segment
sound les with that information when using any sort of automated measurements. In Praat, this is
done by creating /textbfTextgrid annotations in a textgrid le, which is saved separately from the
sound itself.
Textgrid annotations are composed of di erent tiers which mark either intervals or speci c
points within the sound le. Interval tiers are designed to mark elements of a le with a
distinct span, like a vowel, word, or segment. Point tiers mark single points, like release
bursts, turn changes, or glottal openings. Both intervals and points can (and should) be
labeled. The names and relative position of these tiers are speci ed when the Textgrid is
created.
It's worth noting that Praat counts EVERY interval in the le, not just human-created or labeled ones,
so if you mark and label a single vowel interval in a le, Praat will consider the le to have three
intervals: the section before the start of the vowel, the marked vowel, and the section after
the vowel. The marked vowel, in this situation, would be considered interval number
2.
To create a Textgrid for a sound le...
Once your textgrid is created, you'll be presented with the Textgrid Editor Window5(Figure 12). To
annotate the le...
Once your le has been textgridded as above (looking something like Figure 13), you'll
want to save the textgrid le (either from the Objects window (Objects →Save →Save as
Text File...) or within the Textgrid editor (Textgrid Editor →File →Save Textgrid as Text
File...).
Textgridded les can then be read in by Praat scripts which measure only certain parts of the word,
can be split and labeled according to a given tier by script (see the file_segmenter.praat script), or
can simply be examined with the bene t of the labels. Once all your les have been textgridded,
you'll be in a much better position to start automatically measuring data and manipulating your
sound les.
So far, all discussion of measurement has assumed you would be taking individual hand
measurements and writing them down on your own. These last two sections describe two ways to
more e ciently capture data from your measurements.
Praat has the ability to easily capture the measurements you take as you move through your data
using log les, which are then easily exported into Excel (or the statistics program of your choosing).
This is useful when doing a series of repetitive measures which still require human intervention, but
in many cases, the use of Praat scripting can speed this process up further and in some cases,
eliminate the need for human intervention altogether.
To create and use a log le:7
Much like a movie script tells a set of actors exactly what to say and what actions to take, a Praat
script is a text le which tells Praat exactly what to do, and walks the program through a series of
steps. Anything that you can do through the GUI of the program (GUI is "graphical user interface", the
menus and buttons you use to interact with Praat), you can command Praat to do in a
script.
Praat scripting is a wonderful tool, then, for situations where you nd yourself repetitively doing the
same tasks over and over again, and with increased sophistication, you can have Praat make simple
decisions based on its measurements and changes. Simply put, Praat scripting is a way to use the
computer as a co-pilot, handling the boring, repetitive tasks independently and allowing you to do
your job more e ciently.
Praat scripts can be as simple as a single line which tells Praat to adjust the Spectrogram settings to
display a narrowband spectrogram, or as complicated as 500+ lines of code which allow Praat to go
through a folder of les, measuring A1-P0 nasality for each le and presenting any suspect
measurements for human con rmation.
Here's a very basic Praat script, which shows a series of commands to Praat, with commented lines
(prefaced with #) to explain what it's doing:
Note, though, that Praat scripting isn't the same as writing a new computer program. Praat scripting
uses the same commands as you use in the GUI, and only works within Praat, whereas coding (say, in
C) is much more opaque, but programs in C can be compiled to run on many di erent devices and
don't need speci c programs.
That said, there are a few things that Praat scripting cannot do:
To do anything vaguely scripty in Praat, you'll use the Praat menu (in the menubar on a Mac, at the
top of the objects window on a PC), and choose New Praat Script to open the scripting
editor.
Perhaps the most useful part of Praat's documentation is the Scripting tutorial, accessible through
Objects →Help →Praat Intro →Scripting or through the Script Editor window. Because these
tutorials are so excellent at explaining the peculiarities and structures of Praat's scripting language,
this document will skip many of the topics discussed there, focusing instead on overall
usage.
One small but worthwhile note is that Praat actually draws a division between scripts and "editor
scripts". They use the same syntax, the same commands, and are stored in the same way, but some
scripts are meant to run within the Editor window (because they use the functions in that window),
and some are meant to run from the Objects window.
Simply put, if there's a script whose function is only useful once you've already opened the sound you
care about in the editor window, it's going to be run as an Editor script, but if a script needs access to
more than one sound, or to the functions in the Objects window, it'll run from the main windows.
There is some exibility here, though, as you can always use the Edit and Editor commands to work
within the editor in a Praat script, and using endeditor can bring you back to the Objects window from
an editor script.
The primary way in which this distinction matters is that you'll open Editor scripts using the Editor →
File →Open Editor Script... option, whereas you'll open regular Praat scripts with Praat Menu →Open
Praat Script....
Sometimes you'll download a script from the internet or from a friend and it just
won't run, or it'll fail in odd ways. In those situations, try running it as an Editor
script (or as a Praat script, if you're trying it in the Editor). This is a simple step
that, if it works, can save you hours of frustration and troubleshooting, as there's
often no immediate indication how a given chunk of code was meant to be run.
Because a Praat script is literally just a text le with a series of commands to Praat, they can be found
all over the internet, and can be saved as a plaintext le (it's best to give it the .praat
su x, if nothing else, for your own reference). Praat scripts can be run in two distinct
ways.
To open a Praat script in Praat and then run it:
To open an Editor script in Praat and then run it:
To run a script (either Editor or Praat scripts):
Note that if you just want to run a small part of the script (useful when cannibalizing scripts for
certain functions), you can select the part in question and use Script Editor →Run →Run
Selection.
Sometimes, you'll want frequent access to a Script without having to nd it, open it, then click
"Run". To do this, you can add the script to a menu. There are two options on how to do
this8.
First, you can add the script as a button on the right-hand side of the Object window (called a
dynamic menu). This will only work for Non-Editor scripts. To do this:
The other option is to add your script to a pull-down menu in the Object window. (You
can follow the same directions to add an Editor script to an Editor window menu.) To do
this:
To remove a script from a menu, take the below steps9:
Editor scripts can also be associated with one of the Script Logs (Log 3 or 4) in the "Query" menu of
the Editor window. To do this:
Once this is completed, you can use a keyboard shortcut to run your script.
Adding scripts to the Log Script slots is particularly useful for scripts which you might
run extraordinarily often, as you can then, with some additional software, set a
button on a Multi-button mouse to one of your log script keystrokes. For instance, if
you have a script that will take the current selection, create two textgrid boundaries,
label it "vowel", then resize the view to the next interval on another tier, you could
bind it to a log script, then just make a selection, click a mouse button, rinse and
repeat, saving countless hours. At its core, a Praat script is just a plaintext le with commands meant to be read by Praat. As such,
creating a script is as easy as saving a text le, then editing the contents. The easiest way to do this is
using Praat's built-in Script Editor.
To create a new Praat script:
Although Praat has an editor built in which is quite capable, praat scripts can be created from within
any plaintext editor. Using an external editor allows you features like syntax highlighting (Praat script
is similar to Perl in enough ways to make Perl syntax highlights useful), always-on line numbers
(because Praat gives you line numbers where your script crashed and it's less of a pain to just scroll
than to use Script Editor →Search →Go to line...), and the sorts of advanced nd/replace tools
present in more robust editors.
Some good editor choices include:
For Mac OS X:
For Windows:
Praat has a few odd quirks involving lenames which you'll need to work around in your scripting.
First, Praat chokes on lenames with decimals in them. Be careful.
Also, absolute le paths in Praat scripts will need to be referred to di erently on Windows machines
vs. on Macs:
Relative le path names (relative to where the script is) do not need to change across platforms. For
instance, so if you included the below directory assignments in your script:
(or)
Praat would always look for data in a folder called "test data", in the same folder as the script itself.
This script would function well on any operating system, provided the data is put in the proper
folder.10
Incorrectly formatted absolute path names are the most common issue which
prevents you from running scripts you download from the internet. If your script
won't run, check the le paths throughout the script and update them to match
your operating system. Praat scripting relies on Commands, which are, e ectively, verbs which describe the actions Praat
should take. These commands can take a variety of forms, but they usually start with an
uppercase letter. Here are a bunch of Praat commands, selected randomly from several
scripts:
The most beautiful part of Praat scripting comes with the realization that if you can do something
through the GUI, Praat will magically give you the exact commands to do it by script. Let's
examine this wonderful reality by unintentionally writing a Praat script, using Praat's history
function.
First, let's do a little bit of work in Praat, to simulate doing phonetic research:
Now, let's get the duration of the sound
Now, let's get the average height of F1 and F2 of the sound
Now, let's reap what we've sown:
If all went to plan, your Script Editor window will have something like the code pictured
below:
Code generated from the above process:
Each of those lines are the Praat script commands to do each of the tasks. To Formant (burg)... 0
5 5500 0.025 50 turns a sound into a Formant object, with the settings speci ed in the trailing
numbers. Get mean... 1 0 0 Hertz, intuitively enough, gets the mean of the formant speci ed in
the rst number, in the time range speci ed by the next two (0 = "all"), and gives it in Hertz (as
opposed to Bark). Note, though, that because you used the mouse to do the selection (instead of
using the commands in the Editor →Select menu), the exact de nition of the selection doesn't show
up.
In short, this is the kernel of a Praat script that does everything you just did, and this is one of the
most e ective ways of guring out what commands to use in your Praat scripting. The process is
always the same:
By doing this, you'll be able to see how to command Praat to do anything that you can do in the
GUI.
Praat scripts can run the gamut between massive, 800+ line programs and single-function, single line
editor scripts. Although the massive programs are often ashiest, in many cases, the single-item
scripts are the ones you can't live without.
First, let's "write" a script which will turn the Spectrogram displayed in the editor window into a
Narrowband spectrogram (as described in Section 6.2.1), using the history function. To do
this:
The resulting "script" will look like:
That's it.
Because this code works entirely with the Editor window, you'll want to open it as an
Editor script. You can use the Editor →File →Open Editor Script... command to open it and
run it from there, or you can add it to a menu (likely Spectrum) using the procedure in
Section 11.2.2.
Once you've done that, if you want to change the spectrogram type, you're only a click away. You'll
likely end up with a few of these scripts in that menu, to change the spectrogram into broadband,
narrowband, 0-10000 Hz broadband, and so forth. But sometimes, you need to get a bit more
complicated.
Variables are constructs in programming which are just labels which store pieces of information,
either numeric or string (text). In Praat, they have a few characteristics worth noting11:
For a more concrete demonstration, let's take another task. In Acoustic and Auditory Phonetics, Keith
Johnson provides a formula to calculate the length of person's vocal tract based on any formant of a
neutral vowel. He gives this formula as:
L = (2n-1)c∕4Fn L = Length in Meters , n = Formant Num., c = the speed of sound in air (343 m/s)
Let's say you want to calculate this more often, and grow tired of manually calculating it. Instead,
you'd like to be able to record a neutral vowel, then calculate the length based on F3 at the cursor's
location.
First, you'll need to capture the F3 value at the cursor. By using the history command, you'll nd that
the command for getting F3 at the cursor is Get third formant.
However, this normally just pops the output of the command (the F3 height) into an info window.
Because we need that information to be accessible to the script, we need to capture it as a variable.
Although Praat's tutorial on Scripting has a wonderful section on Variables, and you should really
read through that to get a full idea, in Praat, capturing the output of a command as a variable is
easy.
To assign a variable to the output of a command, you just name the variable, then put an equals sign,
then the command whose output you want to capture, like so:
variable = commandtogetoutput Or, in our case:
f3height = Get third formant The above line will then capture the output of "Get third formant" and store it. So, if F3 =
2600 Hz at the cursor, once this command is run, the variable f3height will be equal to
2600.
Then, you'll use that number in the formula above to calculate a new variable, the length of the vocal
tract. Remember, having run the rst command, f3height will now be equal to the height of F3. Praat
is perfectly capable of doing basic math, so we can hard-code the other parts of the equation into the
script:
length = ((2*3 -1) * 343/(4 * f3height))
This will assign the output of ((2*3 -1) * 343/(4 * f3height)) to the variable length.
Finally, you'll want to convert the output (length), which is currently in meters, to a more useful
unit, namely, centimeters:
lengthcm = length * 100 Then, you'll need to display this information in an information window. To do that, use the print
command.
print Your vocal tract length is 'lengthcm:1' cm
This command will print the sentence "Your vocal tract length is", followed by the lengthcm variable's
contents, followed by "cm". The :1 attached to lengthcm rounds the output down to one decimal
point.
Put together, this is your entire script:
You would then save the script and either open it as an Editor script (because it relies on the mouse
cursor within the editor window when getting the third formant), or add to a menu in the editor
window. So, here, three steps of measurement and calculation are condensed into one easy menu
selection.
We've already talked about variables, but there are several other programming constructs used in
Praat scripting which you'll need to know about to successfully script.
In Praat, sometimes, you'll want to do the same thing over and over again, for, e.g. each
item on a list, or for each vowel in a textgrid. To do this, you'll use a for loop. For loops
iterate through large amounts of data, doing the same thing many times over and over
again.
if statements have the form:
for loops always have the format for [var] from 1 to [other var], followed by an indented
block, ended with an endfor (to tell Praat when to stop).
Here's a sample script:
This script selects a textgrid (named 'sounda'), gets the number of intervals in the textgrid,
then goes through and changes the text for each interval in tier two of that textgrid to
"Vowel")
Really, though, the best way to understand for loops is to see them in action and to look through
other scripts.
if statements tell Praat to take a certain set of actions only if the requested conditions are met. This
condition is usually checking whether a variable is equal to (or greater, lesser than) a certain value,
but it can get more complicated than that.
if statements have the form:
Here are a few example if statements that you might see in a script:
The above code will change the textgrid's label to "HighFrontVowel" only if the vowel's label is
"i".
The above code will change the textgrid's label to "AnotherVowel" only if the vowel's label is not "i".
As you can see, if statements are incredibly useful, and will show up constantly to control the ow of
your scripts. You'll learn to love them very quickly.
Praat script uses <> to mean "not equal to" (rather than the usual != or /= or =/=).
This is very weird, and will likely take forever to get used to. If you already know
another programming language which isn't BASIC, this will cause you pain. I'm so
sorry.
Forms can run either at the start of the script, or during the script itself, and are your way of getting
information from the user. Forms can be used to tell the script how to run, specify options, or have the
users input starting information (say, pitch ranges or the number of measures per vowel). These let
more complex scripts get user feedback before and while they do what they do best. For an example
starting form, please see Figure 14.
Forms are created with blocks of code like the below:
This code would create a form like below, in Figure 15.
Not every part of a Praat script is designed to be read by a computer. Lines which start with a #
symbol are called Commented Lines, and will be ignored by Praat. They're usually written
in by human programmers to explain exactly what the code is doing, or in some cases,
as a header. Do yourself a favor and comment the code that you write, as sometimes,
it's the only way you'll understand your code when you look at it days/months/years
later.
Here's an example of some commented code. Remember, Praat will only "see" the lines which don't
start with #:
These are a few tips and tricks that I learned well after they would've saved me hours
upon hours of time. I'm passing them along in hopes that they'll save you the time more
quickly.
Praat scripting takes a long time to really get your mind around, and there are all sorts of other
constructs which can be useful in working. You would be well served, once you've got your mind
wrapped around the basics, to examine the Praat Scripting tutorial pages (Objects →Help →Praat
Intro →Scripting) for some of the following concepts, which will improve your scripting e ciency
even more.
There is very seldom any need to reinvent the wheel, and there is no shortage whatsoever of Praat
scripts available online and oating around departments. Although it's unlikely that you'll happen to
nd a script which does exactly what you need, chances are very good that what you need can be
cobbled together from several scripts. So long as you give attribution to the original author(s) of the
script(s) you borrow code from, there's no shame in reusing parts of other scripts as you work on your
own.
Also, it's worth noting that one of the best ways to learn how to code is to nd a script, see
how it works (in terms of what it does) by running it, and then looking at the script's
code to nd out how it does what it does. Once you've started collecting scripts, you'll
nd yourself reaching for certain chunks of code every time you, say, want to open and
analyze every le in a given folder, or need to generate a plot showing nasality in a given
word.
To that end, along with this handout, there should be a script called DemoScript.praat (and its
uncommented friend, DemoScriptNoComments.praat). This is a very basic formant measurement
script that takes in TextGridded sound les and spits out the formant readings for those les. This
script was written speci cally to be used for learning and cannibalism, and is commented heavily. It's
also included as an appendix to this document.
In short, the more time you spend nosing around scripts, the better.
Scripting can very quickly start to save you some time, and as such, the payo for even a small
amount of work can be great.
However, to get really incredible results, and to trim hours o of your measurement tasks, you'll need
to put more time in. You'll need to code, then code some more, then go steal somebody
else's code, then re-code it because they did it wrong. Then you'll need to spend lots of
time with Praat's tutorials, then spend lots of time on the Praat users list. You'll add and
remove quotes until you never want to see one again, and add loops until you're blue in the
face.
But then nally, that one script that you've been working on forever will work. You'll start it, ll in the
form, and it will run like a cheetah after a hyperactive gazelle. And it'll run the next time. And the
time after that. And each time you start up your script, it'll keep running, and you'll see the time
savings mounting.
Then eventually, you'll realize that all that time, that agony, totally paid o , and rather than spending
the afternoon taking measurements, you can just start a script running to do it for you, then go
actually enjoy your life.
That, my friends, is why we Praat script.
6.1.1 Pulling out a smaller section of the le for analysis
6.2 Adjusting the Spectrogram settings
6.2.1 Narrowband vs. Broadband Spectrograms
6.3 Measuring Duration
6.4 Examining and measuring F0/Pitch
6.4.1 Measuring F0 from a single cycle
6.4.2 Viewing Pitch via a narrowband spectrogram
6.4.3 Using Praat's Pitch Tracking
6.4.4 Improving Pitch tracking by changing the Pitch Settings
Danger! 6.4.5 Scripting only: Creating a Pitch Object
6.4.6 Getting Maximum, Minimum, and Average pitch for a section of speech
6.5 Measuring Pulses, Jitter, Shimmer, and Harmonics-to-noise ratio
6.6 Measuring Formants
6.6.1 Using the Formant tools in the Editor window
6.6.2 Improving Formant Finding results
Danger! 6.6.3 Scripting Only: Formant Objects
6.7 Measuring Intensity/Amplitude
6.8 Working with Spectra
6.9 Taking a spectral slice
6.10 Measuring Harmonic Amplitude, Frequency
6.11 Measuring Creakiness and Breathiness using Spectral Tilt
6.12 Measuring Nasality using A1-P0
6.13 Measuring Spectral Center of Gravity

7 Creating and manipulating sound Files in Praat
7.1 Creating sounds from Formula
7.2 Cropping, Copying, Splicing and Pasting
7.3 Sampling rates and Resampling
7.4 Filtering Sounds
7.4.1 Low-pass ltering
7.4.2 High-pass ltering
7.4.3 Band-pass (notch) ltering
7.5 Pitch Manipulation (To Manipulation...)
7.6 Matching the pitch tracks of two sounds
Danger! 7.7 Matching Intensity
7.8 Combining Sounds
7.9 Formula Modi cation: Waveform addition, subtraction and so much more
7.10 Synthesizing Sounds from scratch
7.11 Source-Filter Vowel Resynthesis
8 Exporting images for use and publication

Bonus! 9 Annotating Sound Files (Praat TextGrids)
10 Using Log Files
11 Scripting in Praat
11.1 What is Praat scripting?
select Sound untitled
# Plays the sound
Play
# Gets the duration
Get total duration
# Gets the amplitude
Get intensity (dB)
# Renames it
Rename... My_awesome_sound
# Prints a message into the Praat information window
print "Script Finished"
11.1.1 Praat's scripting tutorials
11.1.2 Praat scripts vs. Editor scripts
Danger! 11.2 Working with Scripts
11.2.1 Opening and running a Praat script
11.2.2 Making (and removing) Menu Shortcuts for scripts
Bonus! 11.3 Creating a new script
11.3.1 Using other text editors
11.3.2 Filenames
Danger! 11.3.3 How to magically write a Praat script (using the Praat "history" function)
Extract part...
Get starting point...
select
Get high index...
To Manipulation... 0.01 75 600
Get first formant
Get frequency of maximum...
Erase all
(...and many, many more)
Extract selected sound (time from 0)
Close
Get total duration
To Formant (burg)... 0 5 5500 0.025 50
Get mean... 1 0 0 Hertz
Get mean... 2 0 0 Hertz
11.3.4 Writing your rst single-command script
11.3.5 Scripts with Variables
length = ((2*3 -1) * 343/(4 * f3height))
lengthcm = length * 100
print Your vocal tract length is 'lengthcm:1' cm11.4 About the Praat Scripting Language
11.4.1 'for' loops
number_intervals = Get number of intervals... 2
for k from 1 to number_intervals
Set interval text... 2 k Vowel
endfor11.4.2 'if' statements
if vowel_label = "i"
Set interval text... 2 2 HighFrontVowel
endif
if vowel_label <> "i"
Set interval text... 2 2 AnotherVowel
endif
Danger! 11.4.3 Forms
comment [what you're asking the user for]
text directory [your suggestion for what they type in]
comment [Another request, but this lets them assign a number for each choice]
integer vowel 1
integer word 2
comment [Yet another request from the user, but here, with a boolean choice]
choice avariable 2
button yes
button no
endform
11.4.4 Commented lines (#)
# the above directory and keeps reading in files each time it iterates
for j from 1 to number_files
select Strings list
filename$ = Get string... 'j'
Read from file... 'directory$''filename$'
# At this point, we now have the variable "soundname"
# which refers to the file being worked on
soundname$ = selected$ ("Sound")
...11.4.5 Useful tips
minus Sound 'soundname$'
minus TextGrid 'soundname$'
minus (whatever other files you care about)
Remove11.4.6 Everything Else
11.5 In defense of Code Cannibalism
11.6 Closing Remarks on Praat scripting