Praat is software that is used for a wide range of hearing and speech scientific research. It is maintained by Paul Boersma and David Weenink at the University of Amsterdam.
Praat can be used as a point-and-click GUI, but its full power is accessible if you create scripts - instructions to tell Praat to do work for you - much faster than you could ever point and click.
In the past few years, I have developed a number of scripts to perform various tasks in Praat, and I frequently share these scripts with my colleagues.
Some scripts perform simple tasks like measuring intensity or duration, while other scripts do more complicated procedures like speech manipulation.
Note: I never received any training in computer programming, so it's likely the case that some of this code is less than optimal. You are welcome to contribute any suggestions to improve these scripts.
Note: The Praat scripting language has undergone a couple of significant changes in the past couple years. Scripts written in the old style will still work, but there are some functions that have a new look. For example, sometimes you'll see
Scale intensity... 70
or
do ("Scale intensity...", 70)
or
or Scale intensity: 70
... all of these are synonyms for the same operations. because many of my scripts were written and updated during various stages of Praat evolution they sometimes contain mixed function styles.
Note: Please acknowledge me if you benefit from my coding :)
For some speech synthesis and manipulation scripts, it would be a good idea to download a sample sound to get a sense of what the input should look like.
Custom batch processing
The most common
piece of code that I use is a few lines that allow “batch processing” of customized
actions.
What does this
mean? Well, Praat can perform the same action (such as “Scale intensity”) for
all the sound objects that you have selected. But sometimes, you want to
perform an action over many sounds, but Praat only allows you to do it once at
a time. This code opens up some new options to repeat the same action for each
object that you have selected.
Examples of custom batch processing
Get intensity of
all selected sounds
Get duration of
all selected sounds
Save all
selected sounds
Gradually Blend Sounds
Start with Sound
A and Sound B, create X number of sounds by gradually blending those two
sounds.
Calculate continuum values (form)
Start with two
values and a number of continuum steps. Calculate linear interpolation of those
values to create a continuum.
Calculate continuum values (procedure)
Calculate
continuum levels and assign them to new variables that you can use in your
script
Manipulate F0 (pitch) contour
Flatten, flip,
or multiply F0 contour in a sound
Fade in, Fade out
Fade in and/or
Fade out a sound at the edges
Calculate “corner frequencies” using the
Greenwood function
As for setting
channel specifications for a vocoder
Scale intensity of all sounds in a folder
(note: this sometimes
doesn’t work on older Windows computers, on networks, or on Macs. If it doesn’t
work for you, you ought to simply call up all the sounds into the list, scale
them, and save them using the batch processing script)
Make speech-shaped noise
(match spectrum
of broadband noise to the long-term average spectrum of selected sounds)
Local time reversal
Reverse sequential time windows, as done by Saberi & Perrott ("Cognitive restoration of reversed speech," Nature 398: 760, 1999)
Add silence to equate absolute duration of sounds
Match duration of all selected sounds by padding onset or offset silence. Note that this does *NOT* normalize phonetic duration. It's only for when you need raw file size to be equal.
Somewhat more challenging scripts
Harmonize two sounds
Make vocal
harmonies by adding sounds where the pitch has been altered by specified
semitone intervals. You have the choice of changing just the pitch, or a
combination of the pitch and “vocal tract size”
Make duration continuum
For all selected
sounds, alter duration of a selected region within the sound (e.g. the vowel
nucleus) between endpoint levels, using a specified number of continuum steps.
In the case of multiple selected sounds, timing landmarks are set according to
those chosen in the first sound, so
you want to make sure that all the sounds have the same relative duration
properties to begin with.
Make fricative continuum
Specify many
aspects of a fricative noise, including three frequency peaks. For each peak,
you modify the center frequency, the bandwidth (in terms of dB attenuation per
octave). Control the spectral tilt by changing the amplitudes of the first and
third peaks relative to the second peak. Control overall duration, risetime,
falltime, and intensity. Create isolated fricatives, or append / pre-append the
fricatives to some other (vowel) sound. Interpolate between any number of
continuum steps using a linear scale, logarithmic scale, Bark scale, or
cochlear space using the Greenwood function.
Make Voice Onset Time (VOT) / F0 continuum
Control a
continuum of VOT and F0 in word-initial stop consonants. You have the choice to
control *only* VOT, *only* F0, or a combination of both. When altering both,
you have the option to have the both co-vary together, or to control them
orthogonally (as for cue-weighting experiments). Control the time range over
which the F0 perturbation will occur.
Most
importantly, ensure that the transition between the burst/aspiration portion
and the vocalic portion is smooth and natural-sounding.
There are some
options to select the aspiration from the original sounds that you will change,
or from a pre-made sound object (for the purposes of keeping things constant
across many stimulus continua). There are many options to control low-level
details like the proportion of vowel that is cut back by each portion of
aspiration.
Make spectral ripples
Spectral ripple
discrimination is a psychophysical task thought to be a metric for spectral
resolution (Supin et al., 1994; Henry et al., 2005; Won et al., 2007; Anderson
et al., 2011). This script applies a spectral envelope filter to broadband
noise in order to create a rippled noise.
Parameters to
control: sound duration, number of ripples per octave, ripple phase, ripple
modulation depth, final intensity, high-pass filter and low-pass filter. Any of
these parameters can be altered side-by-side in two ripple sounds, so that you
can compare any one of them independently, or in combination.
Added feature:
the spectra of each ripple is drawn on the picture window so that you can see
the output.
Vocode all selected sounds
The vocoder is a
commonly used tool to study spectral resolution and to simulate a cochlear
implants (CIs).
Vocoding can be
a very simple process, or a VERY complicated process. This script allows you to
have it either way. There is extensive documentation inside the script if you’re
interested, but here are the main points:
What you can
control: Number of channels, spectral shape of each channel (flat-top, or
peaked-top); in the case of peaked-top channel, you can control the filter
bandwidth in terms of attenuation per mm of cochlear space (to simulate “spread
of neural excitation” in a CI). You can control the temporal envelope filter to
determine the specificity of temporal pitch coding. You can control whether you
want to represent each analysis channel in the output, or select the top n
peaks out of m analysis channels (as in ACE / SPEAK-style CI processing). Note
that if you do wish to incorporate peak-picking, the vocoder is very slow, due
to the limitation of Praat in handling arrays. For peak-picking vocoders, you
control the duration of the window within which the spectrum is analyzed for peaks,
as well as the duration of overlap between consecutive time windows.
For channel
selection, there are embedded options to simulate the filter specs for the
Cochlear Nucleus CI, and the Advanced Bionics experimental device that uses
current focusing in a 15-channel setup. These settings are crude
representations in the frequency domain only, and have NOT been provided by
Cochlear or Advanced Bionics. They are just me playing around trying to
simulate the implants worn by patients that I have seen. No input has been
given by the actual manufacturers, so do not assume that this script re-creates
the processing used by those devices.
Make Formant Continuum
This is my Moby
Dick of Praat scripts – a wizard-style GUI to let you alter formant structure
of natural speech sounds.
The goal of this
script is to alter the formant structure of a single word to either make it
more like another pre-existing word, or to simply alter it free-form.
This script is
not “plug-and-play”; it requires a decent amount of acoustics knowledge on the
part of the user before it can be used successfully. And that’s not because the
script isn’t robust – it is – it’s because formant tracking and manipulation is
something of a “dark art” (thanks Bill Idsardi for that excellent term). Before
formants are manipulated, they have to be correctly tracked, and verification
of that requires a bit of human experience.
Strengths of
this script:
You can control
or not control individual formants 1,
2 and 3.
You can retain
the original bandwidth contour or override bandwidths.
You can
interpolate formant frequency using a linear scale or the non-linear Bark scale.
All of the
settings used to create the continuum are printed to the info window, along
with the exact formant frequencies for each formant at each timestep for each
step of the continuum.
You can maintain
a high degree of sound naturalness by restoring high-frequency energy that is
lost in the process of LPC decomposition. The high-frequency energy is still
phase-locked to the manipulated portion of the sound. It is congruent across
all continuum steps, meaning that it isn’t informative, but it adds value to
make the stimulus sound more natural.
There are some
experimental techniques used in this script with regard to sampling frequencies
and filter modification. I wont claim that everyone will agree with the
technique used here, but I can vouch for it by saying that, when controlled
carefully, the output can be exceptional.
This script is
occasionally updated as bugs are discovered, or as new features are desired.
Support: If you
want to use this script and aren’t having an easy time, please read the documentation and learn elements of the scripting
language to understand it first before contacting me for support.
Playtime
Calculate Quarterback Passer Rating
Enter a
quarterback’s attempts, completions, yards, touchdowns and interceptions. Find
the QB rating!
Acknowledgments
I have learned a lot about Praat coding by observing comments by Paul and David on the Yahoo! Praat User group, as well as comments and scripts from José Joaquín Atria, Hugo Quené, Daniel Hirst, Chris Darwin, Pauline Welby, Allison Blodgett, and others.
Advice
Here's how I advise Praat beginners. First, figure out how to do what you need to do manually, by pointing and clicking through the GUI menus in Praat. Once you can do that, take advantage of the "Paste History" tool in the Praat script editor window. That will give you the code-level language that you'll need to write your script. Also, peruse the manual and the Yahoo Praat user group, because there is a wealth of knowledge and advice therein.
No comments:
Post a Comment