PyRnNoise

raw JSON →
0.4.3 verified Fri May 01 auth: no python

Python wrapper for the RNN noise suppression library (RNNoise), enabling real-time speech denoising. Current version 0.4.3, maintained on GitHub.

pip install pyrnnoise
error AttributeError: module 'pyrnnoise' has no attribute 'RNNoise'
cause Incorrect import path; often due to an older version or typo.
fix
Use 'from pyrnnoise import RNNoise'. Ensure you have version 0.4.0 or later.
error RuntimeError: Input audio must be 1D array of float32
cause Audio data is int16, int32, or multi-channel (2D array).
fix
Convert to mono float32: audio = audio.astype(np.float32) if audio.dtype != np.float32 else audio; if audio.ndim > 1: audio = audio.mean(axis=1).
error OSError: No such file or directory: 'librnnoise.so'
cause Missing native dependency (RNNoise shared library). This can happen if the platform is not supported or the C library is not compiled.
fix
Install from source: on Linux, apt install build-essential cmake; on Windows, use precompiled wheels or build manually.
breaking The RNNoise class expects audio data as a numpy array of shape (N,) with dtype float32. Providing int16 or multichannel data will cause silent errors or poor results.
fix Convert to float32 and ensure mono: audio = audio.astype(np.float32) / 32768.0 for int16 input.
gotcha The filter() method expects the entire audio at once; it does not support streaming or chunked processing out of the box. Attempting to call filter() on small chunks may produce artifacts at boundaries.
fix Process the whole audio array in one call, or implement overlap-add for streaming.
deprecated The 'sample_rate' parameter in RNNoise constructor is deprecated and ignored; the model always operates at 48 kHz. Passing it may raise a warning in future versions.
fix Remove the sample_rate argument; resample your audio to 48 kHz before passing to denoiser.

Load a noisy audio file, filter it with RNNoise, and save the denoised result.

from pyrnnoise import RNNoise
import soundfile as sf

denoiser = RNNoise()
data, samplerate = sf.read('noisy_audio.wav')
output = denoiser.filter(data)
sf.write('denoised_audio.wav', output, samplerate)