mr710
mr710

Reputation: 11

Parselmouth batch full voice report

I was wondering if there is a way to batch process audio files and generate full voice reports using parselmouth or another pythonic implementation of praat. So far I have only been able to get the median pitch but I need to be able to work out the total number of pulses and periods, the degree of voice breaks and the shimmer. If this isn't possible using python would it be possible using a praat script? praat generated voice report

Upvotes: 1

Views: 2743

Answers (2)

Sergio Lucero
Sergio Lucero

Reputation: 896

I am using parselmouth to extract a large number of features from some audio files. In general, I end up using something along these lines:

import parselmouth
from parselmouth.praat import call

sound = parselmouth.Sound(filename)
pitch = call(sound, "To Pitch", 0.0, F0min, F0max)
pulse = call([sound, pitch], "To PointProcess (cc)")

voice_report = call([sound, pitch, pulse], "Voice report", 0.0, 0.0, 75, 600, 1.3, 1.6, 0.03, 0.45).split(chr(10))

From the report, you can retrieve coefficients such as harmonic-to-noise ratio (HNR), Jitters, Shimmers and classic pitch statistics.

Upvotes: 0

Yannick Jadoul
Yannick Jadoul

Reputation: 401

[Disclaimer: I am the author of the mentioned Parselmouth library]

This question was asked and solved on the Gitter chatbox for Parselmouth, but for future reference, this was the solution I suggested there:

A similar question was asked on StackOverflow before: How to automate voice reports for Praat, explaining how to get the voice report without the Praat 'View & Edit' window (i.e., using a Sound, Pitch, and PointProcess object).

So first you get these these three objects, the Sound sound, Pitch pitch, and PointProcess pulses, possibly changing parameters you want to have differently:

import parselmouth
sound = parselmouth.Sound("the_north_wind_and_the_sun.wav")
pitch = sound.to_pitch()
pulses = parselmouth.praat.call([sound, pitch], "To PointProcess (cc)")

After that, you can query the different quantities you want to extract in different ways. For example, the number of pulses in the PointProcess can be extracted with:

n_pulses = parselmouth.praat.call(pulses, "Get number of points")

And the others:

n_periods = parselmouth.praat.call(pulses, "Get number of periods", 0.0, 0.0, 0.0001, 0.02, 1.3)
shimmer_local = parselmouth.praat.call([sound, pulses], "Get shimmer (local)...", 0.0, 0.0, 0.0001, 0.02, 1.3, 1.6)

Getting the degree of voice breaks is somehow harder. No idea why Praat has no command to get this.

A quick way of getting this in Python would be:

max_voiced_period = 0.02  # This is the "longest period" parameter in some of the other queries
periods = [parselmouth.praat.call(pulses, "Get time from index", i+1) -
           parselmouth.praat.call(pulses, "Get time from index", i)
           for i in range(1, n_pulses)]
degree_of_voice_breaks = sum(period for period in periods if period > max_voiced_period) / sound.duration

You could also find the line that reports this percentage in the output string of "Voice report"; see https://stackoverflow.com/a/51657044/2043407

If you have a look at the Praat user interface, there's indeed no button "Get median", so that's why that line doesn't work. However, there is a "Get quantile" command in Praat So I would suggest

parselmouth.praat.call(pitch, "Get quantile", 0.0, 0.0, 0.5, "Hertz")

(That 0.5 is then the 50% quantile, i.e., the median)

Upvotes: 5

Related Questions