Anja Arnhold's Praat scripts


Here are some of my Praat scripts that I hope will be of use to others. I plan to upload more scripts slowly.

To use any of the scripts, click the link, copy the text from the tab that opens into a simple text file and save it on your device with your favourite script file extension (.praat, .script, .txt). Then open and run in Praat like any other script.

I also highly recommend the large collection of Praat scripts hosted by the UCLA phonetics lab, which also has resources on how to use, modify and write Praat scripts.

Support, disclaimer and copyright

All the scripts here work fine on my laptops, which are Windows machines. I cannot guarantee that they will work for you. If you notice an issue other than the known issues listed below, or if you have an idea how to solve the known issues, you can contact me at arnhold [at] ualberta [dot] ca. I cannot promise I will be able to solve the issue or even answer your email, but it is worth a try.

Where I have used code from other people's scripts, this is acknowledged in the comments at the top of each script file (if you notice I have forgotten to acknowledge something, please contact me at arnhold [at] ualberta [dot] ca). All scripts are commented fairly extensively so they should be easy to use and modify.

If you use one of these scripts basically unadjusted, I would appreciate attribution in resulting publications.

Known issues

The fileappend code has changed a bit over time, which I think is the reason why sometimes, code that is supposed to add measurements to an existing text file overwrites this file instead. I have not yet figured out exactly what the problem is and how to fix it (it seems worse on Macs?). This is a problem when you are hand-editing files in a folder in batches and save comments to a text file as you go along. The overwriting does not happen between files, but everytime you re-start the script. Sound files, textgrids, pitch objects etc. are not affected. To be on the safe side, I recommend making a copy of such output text files before you re-run the script over a new batch of sound files or textgrids.

Backspaces in paths sometimes cause issues. If a script says it cannot find an existing file and you have copied the correct path, try replacing backward slashes with forward slashes.

Sometimes things mysteriously go awry on Mac machines.

Acoustic measurements (for prosody research)

MeasureIntensityDurationF0minF0maxF0contourpoints.praat

My basic all-purpose script for quantitative prosody research. Measures duration, f0 maxima and minima, intensity and f0 at 10 equidistant points per interval. Measurements can be used to generate average f0 contours.

Needs sounds and corresponding textgrids with labelled interval tiers. Manually edited pitch objects can be used, but are optional. You can choose to measure all labelled intervals or only intervals with a certain label on any tier. Will also optionally record the label on the parallel interval on another tier (e.g. word label when measuring vowels).

This script is based on a script for measuring intensity by Catherine Crosswhite and modified by Taehong Cho and Holger Mitterer. I have added the code for all other measures, as well as modified general functionality, e.g. measuring corresponding labels on other tiers.

Updated on November 20, 2023: The script now also measures mean f0, over the duration of the whole interval and separately for the middle 50% of the interval. Additionally, it also outputs the interval number of the parallel tiers ("word" and "syllable").

Updated on January 30, 2024: Fixed an error in output of the interval numbers of the parallel tiers ("word" and "syllable") introduced in the last version.

measureDurationOfSound.praat

Measures durations of all sound files in a folder and writes the file names and corresponding durations (in ms) into a single text file. That's it.

Extract information from textgrids

Print_all_intervals.praat

Prints out label, tier, beginning time, end time and file name for all intervals in all textgrids in a folder into one tab-separated file.

I use this in for phonetics course assignments, when I have all students in a class make a textgrid for the same sound file. Also useful for research if you are only interested in labels and duration data.

Print_out_file_names.praat

Prints out names of all files in a folder into one tab-separated file. Optionally also measures total durations of sound files.

Simple changes to files

Rename_soundfiles_from_textfile.praat

There are other ways to do this, but I use Praat for changing the file names of all sounds in a folder. The script expects you to have a text file with one line per new sound file name (can be created in notepad, Excel etc.). It will warn you if the number of new names in the file is different from the number of sounds.