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.
# get pyloudness source
git clone https://github.com/csteinmetz1/pyloudnorm.git
# install dependancies
pip install -r requirements.txt
# run setup from new directory
python setup.py install
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 loudnessMethods 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)- SciPy (https://www.scipy.org/)
- NumPy (http://www.numpy.org/)
- Add true peak measurement
- Develop unit tests - include audio files - check potential changes in loudness measurements
- Add additional filters (see this paper)
- Include tests from the EBU R128 spec
- Setup documentation