Implementation of ITU-R BS.1770-4 loudness algorithm in Python.
Low maintenance activity. Last release 11 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install pyloudnormpyloudnorm

Flexible audio loudness meter in Python.
Implementation of ITU-R BS.1770-4.
Allows control over gating block size and frequency weighting filters for additional control.
For full details on the implementation see our paper with a summary in our AES presentation video.
Installation
You can install with pip as follows
pip install pyloudnorm
For the latest releases always install from the GitHub repo
pip install git+https://github.com/csteinmetz1/pyloudnorm
Usage
Find the loudness of an audio file
It's easy to measure the loudness of a wav file. Here we use PySoundFile to read a .wav file as an ndarray.
import soundfile as sf
import pyloudnorm as pyln
data, rate = sf.read("test.wav") # load audio (with shape (samples, channels))
meter = pyln.Meter(rate) # create BS.1770 meter
loudness = meter.integrated_loudness(data) # measure loudness
Loudness normalize and peak normalize audio files
Methods are included to normalize audio files to desired peak values or desired loudness.
import soundfile as sf
import pyloudnorm as pyln
data, rate = sf.read("test.wav") # load audio
# peak normalize audio to -1 dB
peak_normalized_audio = pyln.normalize.peak(data, -1.0)
# measure the loudness first
meter = pyln.Meter(rate) # create BS.1770 meter
loudness = meter.integrated_loudness(data)
# loudness normalize audio to -12 dB LUFS
loudness_normalized_audio = pyln.normalize.loudness(data, loudness, -12.0)
Loudness range
Attempt to measure the Loudness Range (LRA) of an audio file based on EBU Tech 3342. LRA quantifies the variation in loudness over time, measured in LU (Loudness Units).
import soundfile as sf
import pyloudnorm as pyln
data, rate = sf.read("test.wav") # load audio
meter = pyln.Meter(rate) # create BS.1770 meter
lra = meter.loudness_range(data) # measure loudness range
print(f"Loudness Range: {lra:.1f} LU")