Melsauce
Melsauce

Reputation: 2655

How to extract perceived loudness of a speech signal in an audio (WAV) file using Python?

I would like to extract loudness of a speech signal from an audio file (WAV). I believe it is a perceived quantity that depends not only on the amplitude of a signal but also the frequencies involved. I found a link that was useful https://github.com/librosa/librosa/issues/463 but I

  1. would like to use existing packages that calculate this efficiently
  2. am uncertain the approach described here is appropriate.

For 1, I found Parselmouth, a wrapper around Praat to work with, but am unsure on how to proceed after extracting the Intensity and Pitch values by doing so:

snd = parselmouth.Sound(path)

intensity = snd.to_intensity()
pitch = snd.to_pitch()

I have also looked into Pydub and PyAudioAnalysis but couldn't find direct methods of evaluating loudness using those either.

What is a pythonic, package object-oriented way of extracting loudness from a WAV file?

Upvotes: 0

Views: 3771

Answers (1)

Reveille
Reveille

Reputation: 4629

You could use pyloudnorm:

import soundfile as sf
import pyloudnorm as pyln

data, rate = sf.read("test.wav")
meter = pyln.Meter(rate) #
loudness = meter.integrated_loudness(data)

Upvotes: 3

Related Questions