Matthew Winn

Au.D., Ph.D.

University of
Minnesota

 

 

Praat Scripts

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.

Here you can find some of the scripts that I use most often in my research.

There are simple things like measuring intensity or duration, and also some more complicated procedures like speech manipulation and cochlear implant simulation.

 

Many of these scripts havebeen updated since the last time they were posted. I don't have the bandwidth to continually update this page. But occasionally there are wholesale updates. I am not able to personally service your programming needs, but occasionally I can spot an easy-to-correct error in the code.

(eventually this site will have some accompanying images / help files)

Here's a brief tutorial on downloading and doing very basic things in praat (for beginners)

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. 

How to Run a Praat Script
Custom batch processing
Examples of custom batch processing
Compare spectra of all selected sounds
Gradually Blend Sounds
Calculate continuum values (form)
Calculate continuum values (procedure)
Manipulate F0 (pitch) contour
Fade in, Fade out
Calculate “corner frequencies” using the Greenwood function
Scale intensity of all sounds in a folder
Make speech-shaped noise
Local time reversal
Add silence to equate absolute duration of sounds
Print series of ERB boundaries
Filter a sound into ERB filters

 

Harmonize two sounds
Make duration continuum
Make fricative continuum
Make Voice Onset Time (VOT) / F0 continuum
Make spectral ripples
Vocode all selected sounds
Make Formant Continuum
Calculate Quarterback Passer Rating
Practice sounds
Acknowledgments
Advice

(return to top)

 

How to run a praat script

There's more than one way to do it. Here's what I do:

Open the txt file in your preferred text editor (like TextPad). Read through it and tinker with it however you wish. Open Praat (and any required sound objects) and click "Praat" -> "New Praat script". Copy the text of the script into the Praat scrip window and press ctrl+R.

(return to top)

 

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.

(return to top)

Examples of custom batch processing

Get intensity of all selected sounds

Get duration of all selected sounds

Save all selected sounds

(return to top)

Compare Spectra of All Selected Sounds

Check to see if sounds vary in their spectral properties by quickly visualizing them in the picture window. This is *especially* useful for after you've created some sort of speech continuum or spectral ripple sounds. The first object will be drawn in blue, and the last in red; all intermediates will be interpolated between those two colors.

Gradually Blend Sounds

Start with Sound A and Sound B, create X number of sounds by gradually blending those two sounds. Note that this will NOT create equal spacing in terms of auditory perception.

(return to top)

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

(return to top)

Manipulate F0 (pitch) contour

Flatten, flip, or multiply F0 contour in a sound

(return to top)

Fade in, Fade out

Fade in and/or Fade out a sound at the edges

(return to top)

Calculate “corner frequencies” using the Greenwood function

As for setting channel specifications for a vocoder

(return to top)

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)

(return to top)

Make speech-shaped noise

match spectrum of broadband noise to the long-term average spectrum of selected sounds

(return to top)

Local time reversal

Reserves sequential windows of a sound, as by Saberi et al. (1999)

(return to top)

Pad sound with silence to equalize signal duration

Add silence to the onset or offset of a sound for the purpose of equalizing absolute file duration. Note: this does not manipulate phonetic duration at all.

(return to top)

Print sequence of ERB boundaries

As the title implies

(return to top)

Filter a sound into a sequence of ERB filters

As the title implies.

(return to top)

Make low-noise noise

Low-noise noise is narrowband noise whose envelope fluctuations are minimized. A little-known property of filtered noises is that as you narrow the bandwidth of a Gaussian (/white) noise, the envelope (intensity over time) does not remain flat, but actually fluctuates quite a bit. Low-noise noise was invented to minimize these fluctuations. More details in the script.

 

(return to top)

 

Amplitude-modations

This is a classroom demonstration that I use to show what amplitude moduations sound like. You can choose either a white-noise carrier or a 2000-Hz sinewave carrier, and declare the rate and depth of your modulations

 

(return to top)

 

 

 

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”

Example of harmonized sounds:

Original . Major chord . Minor chord . Major 7th chord

(return to top)

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. Why are you selecting landmarks instead of just time-warping the entire sound? because sometimes you want to modify the vowel without modifying the neighboring consonants! For example, check out the image below of the word "dog" where the vowel has been expanded to 6 different durations between 75 and 350 ms.

(return to top)

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.

(return to top)

Make Voice Onset Time (VOT)  / F0 continuum

So far, this is the only script that is *properly* documented and on GitHub.

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, you can 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.

(return to top)

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 (in dB), 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.
Pro tip: draw the spectra of each ripple on the picture window so that you can see the output.

Spectral ripples

(return to top)

Vocode all selected sounds

See paper here: https://pubs.aip.org/asa/jasa/article/155/4/2407/3280705/How-to-vocode-Using-channel-vocoders-for-cochlear 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), carrier signal type (noise / pulse). 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 cochlear 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). 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. You can also control amplitude compression, but 1) this slows down the process by a lot, and 2) the compression algorithm isn't the same as what's used in an actual real-life CI firmware.


For channel selection, there are embedded options to simulate the filter specs for the Cochlear Corporation CI, and the Advanced Bionics experimental device that uses current focusing in a 14-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 fully re-creates the processing used by those devices.

(return to top)

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 listener 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.

Example of output of the formant manipulation script:
continuum between /i/ and /I/ vowels.

five step continuum . . . . . . . twelve step continuum

spectrogram image of 5-step continuum

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: No personalized support is offered for this script. If you want to use this script and aren’t having an easy time, I encourage you to read the documentation and learn elements of the scripting language to understand it. Eventually there will be a full-length paper describing this technique, with advice on how to best use it. But for now I don't have the bandwidth to help other users.

(return to top)

 

Playtime

Calculate Quarterback Passer Rating

Enter a quarterback’s attempts, completions, yards, touchdowns and interceptions. Find the QB rating!

Jalen Hurts

 

(return to top)

 

Practice sounds

On this page, you can download a few sample .wav files to play with these scripts.

 

Acknowledgments
I have learned a lot about Praat coding by observing comments by Paul and David on the Praat User group, as well as comments and scripts from José Joaquín Atria, Hugo Quené, Daniel Hirst, Chris Darwin, Eleanor Chodroff, Pauline Welby, Allison Blodgett, and others.

Will Styler has an excellent page of resources and advice for acoustic phonetics here.  

Joe Toscano maintains a google site full of Praat resources here.

Mauricio Figueroa has recently made an excellent Praat manual.

 

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 Praat user group, because there is a wealth of knowledge and advice there.