How to extract formant tracks with Praat and python

This tutorial was adapted based on the examples from David R Feinberg

This tutorial assumes you started a Jupyter notebook . If you don't know what this is, here's a tutorial on how to set one up (first part)

First you should install the parselmouth package, which interfaces Praat with python:

!pip install -U praat-parselmouth

which you would then import:

import parselmouth 
from parselmouth import praat

You do need some audio input (wav header, 16 kHz sample rate)

testfile = '/home/felix/data/data/audio/testsatz.wav'

And would then read in the sound with parselmouth like this:

sound = parselmouth.Sound(testfile) 

Here's the code to extract the first three formant tracks, I guess it's more or less self-explanatory if you know Praat.

First, compute the occurrences of periodic instances in the signal:

pointProcess =, "To PointProcess (periodic, cc)", f0min, f0max)

then, compute the formants:

formants =, "To Formant (burg)", 0.0025, 5, 5000, 0.025, 50)

And finally assign formant values with times where they make sense (periodic instances)

numPoints =, "Get number of points")
f1_list = []
f2_list = []
f3_list = []
for point in range(0, numPoints):
    point += 1
    t =, "Get time from index", point)
    f1 =, "Get value at time", 1, t, 'Hertz', 'Linear')
    f2 =, "Get value at time", 2, t, 'Hertz', 'Linear')
    f3 =, "Get value at time", 3, t, 'Hertz', 'Linear')

One thought on “How to extract formant tracks with Praat and python”

  1. Thanks for the code.

    May I know how I can do the process if I want to slice each formant value into 10%?
    For example,
    vowelstart=, “Get starting time”)
    vowelend=, “Get end time”)
    f1_10 =, ‘Get value at time’, 1, vowelstart+(vowelend-vowelstart)*0.1, “Hertz”, “Linear”)
    f2_10 =, ‘Get value at time’, 2, vowelstart+(vowelend-vowelstart)*0.1, “Hertz”, “Linear”)
    f3_10 =, ‘Get value at time’, 3, vowelstart+(vowelend-vowelstart)*0.1, “Hertz”, “Linear”)
    f1_20 =, ‘Get value at time’, 1, vowelstart+(vowelend-vowelstart)*0.2, “Hertz”, “Linear”)
    f2_20 =, ‘Get value at time’, 2, vowelstart+(vowelend-vowelstart)*0.2, “Hertz”, “Linear”)
    f3_20 =, ‘Get value at time’, 3, vowelstart+(vowelend-vowelstart)*0.2, “Hertz”, “Linear”)
    f1_90 =, ‘Get value at time’, 1, vowelstart+(vowelend-vowelstart)*0.9, “Hertz”, “Linear”)
    f2_90 =, ‘Get value at time’, 2, vowelstart+(vowelend-vowelstart)*0.9, “Hertz”, “Linear”)
    f3_90 =, ‘Get value at time’, 3, vowelstart+(vowelend-vowelstart)*0.9, “Hertz”, “Linear”)

Leave a Reply

Your email address will not be published. Required fields are marked *