← Journal
Removing Recording Noise with noisereduce

Removing Recording Noise with noisereduce

A record of running noisereduce, a Python library that removes audio noise with spectral gating, while the network was disconnected. On a simple synthetic test signal, the noise reduction effect was limited.

Repository covered in this article

timsainb/noisereduce

Noise reduction in python using spectral gating (speech, bioacoustics, audio, time-domain signals)

1.9k Jupyter Notebook MIT License

Meeting recordings and voice memos recorded in the field contain fan noise from air conditioners and white noise. noisereduce is a Python library that estimates and removes this kind of steady noise with a technique called spectral gating. I installed it and tested whether noise reduction worked while the network was disconnected.

noisereduce estimates a noise profile from an audio spectrogram, then applies a gate (attenuation) to each frequency band based on that profile. The noisereduce project uses the MIT License (*1).

1. Install noisereduce

FROM docker.io/library/python:3.12.13-slim
RUN pip install --no-cache-dir --quiet 'noisereduce==3.0.3' 'scipy==1.18.0'
WORKDIR /work
podman build -t noisereduce-sandbox .

2. Try Noise Reduction on Synthetic Audio

I prepared a synthetic clip consisting of a 440Hz pure tone (sine wave) overlaid with white noise, along with a reference clip containing noise alone, then passed them to noisereduce without modification. I ran the command with the network disconnected.

import numpy as np
import noisereduce as nr
from scipy.io import wavfile

rng = np.random.default_rng(42)
sr = 22050
t = np.linspace(0, 3.0, int(sr * 3.0))

tone = 0.3 * np.sin(2 * np.pi * 440 * t)
noise = rng.normal(0, 0.15, size=t.shape)
noisy = (tone + noise).astype(np.float32)

noise_profile = rng.normal(0, 0.15, size=(sr,)).astype(np.float32)
reduced = nr.reduce_noise(y=noisy, sr=sr, y_noise=noise_profile, stationary=True)
podman run --rm --network none --memory 2g --cpus 2 --pids-limit 512 \
  -v "$(pwd)":/work -w /work noisereduce-sandbox \
  python denoise_demo.py

The -v option mounts the specified directory with read/write access inside the container. Use an empty directory dedicated to the experiment.

The command produced these values.

clean tone RMS: 0.2121
noisy signal RMS: 0.2604
denoised signal RMS: 0.0709
noise component RMS before: 0.1504
noise component RMS after:  0.1423
noise RMS reduction: 5.4%

We calculated the noise component as the difference from the original pure tone. Its RMS fell from 0.1504 to 0.1423, a mere 5.4% reduction. The processed signal's total RMS fell to 0.0709, below the original pure tone's RMS of 0.2121. The process attenuated the tone, the signal we wanted to preserve, along with the noise.

The result may reflect the simplified test conditions: a single-frequency pure tone plus white noise. The authors designed noisereduce's spectral gating for broadband signals such as human speech. Our test used a single-frequency synthetic sound, which differs from those conditions. We cannot determine the noise reduction on real voice recordings from this record.

Quantify Noise Reduction with RMS Values

Judging a noise reduction tool from listening impressions makes the assessment subjective. You can use RMS values from before and after processing to record the change. The record should include results like this one, where the tool had less effect than expected.

Sources

*1 noisereduce (GitHub), https://github.com/timsainb/noisereduce, MIT License