Praat Scripts

broken image


Praat Scripts The following Praat scripts were all based on pre-existing scripts given to me by others (see full credit, where possible, in the files). Most of them are used for working with files that are to be, or have been, ToBI annotated. They are all shared under a GNU General Public License.

  1. Contingency table maker This perl script takes a list of consonant pairs and creates a co-occurrence table.; Praat scripting for dummies Well, this handout provides step-by-step instructions for Praat scripting.; Add noise This praat script superimposes a noise file onto all sounds in a specified folder.; Add sounds This praat script combines (not concatenates) all the sound files in a folder.
  2. Praat script to export all possible data about audio. Create text file from textGrid using Praat or any other audio processing tool. How do I print data with commas separating each element in praat script. How can you find and replace text in a file using.

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 you can find some refined versions of these scripts at:

The lab's GitHub page here

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)

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
2019
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

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.

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

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.

Start with Sound A and Sound B, create X number of sounds by gradually blending those two sounds.

Start with two values and a number of continuum steps. Calculate linear interpolation of those values to create a continuum.

Calculate continuum levels and assign them to new variables that you can use in your script

Flatten, flip, or multiply F0 contour in a sound

Scripts

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

As for setting channel specifications for a vocoder

(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)

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

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

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.

As the title implies

As the title implies.

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.

Praat Scripts

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 modulaitons

Praat Scripts Tutorial

Somewhat more challenging scripts

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

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.

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.

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.

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.

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 /sinewave / pulse / low-noise noise). 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.

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

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.

Playtime

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

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 Yahoo! 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.

Praat website
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

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.

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

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.

Start with Sound A and Sound B, create X number of sounds by gradually blending those two sounds.

Start with two values and a number of continuum steps. Calculate linear interpolation of those values to create a continuum.

Calculate continuum levels and assign them to new variables that you can use in your script

Flatten, flip, or multiply F0 contour in a sound

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

As for setting channel specifications for a vocoder

(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)

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

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

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.

As the title implies

As the title implies.

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.

Praat Scripts

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 modulaitons

Praat Scripts Tutorial

Somewhat more challenging scripts

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

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.

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.

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.

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.

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 /sinewave / pulse / low-noise noise). 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.

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

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.

Playtime

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

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 Yahoo! 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.

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





broken image