Skip to main content

Deep Learning-powered speech denoiser based on U-Net with bounded cIRM phase optimization

Project description

speech-denoiser

A high-performance, deep learning-powered Python library for speech enhancement and denoising.

speech-denoiser uses a state-of-the-art U-Net CNN architecture equipped with self-attention at the bottleneck and bounded complex Ideal Ratio Mask (cIRM) phase-magnitude optimization. The underlying model is fine-tuned using a MetricGAN-style adversarial objective, making it highly specialized in restoring noisy speech signals.


Features

  • High-Quality Speech Enhancement: Restores clean speech from complex, noisy environments (trained on VCTK clean speech and DEMAND noise).
  • Flexible In-Memory API: Denoise raw NumPy arrays or PyTorch tensors in one function call.
  • Direct File Denoising: Load, enhance, and save clean .wav, .mp3, or other audio files in a single step.
  • Overlap-Add Processing: Prevents out-of-memory errors by windowing and stitching varying-length audio dynamically.
  • Automatic Resampling: Automatically handles arbitrary input sample rates (downsampling internally to $16\text{ kHz}$ for the model, and restoring the original sample rate at the output).
  • No Heavy System Dependencies: Utilizes a platform-independent audio backend (soundfile), eliminating the need for complex FFmpeg installations.

Installation

Install the library directly from PyPI:

pip install speech-denoiser

Or install the development version directly from GitHub:

pip install git+https://github.com/denizcaylak/signal-denoising.git#subdirectory=speech-denoiser

Quickstart

1. Denoise a Waveform Array (In-Memory)

Perfect for integration into audio pipelines, speech recognition front-ends, or web apps:

import soundfile as sf
import speech_denoiser as sd

# 1. Load your noisy audio (supports any sample rate)
noisy_audio, sr = sf.read("noisy_speech.wav")

# 2. Denoise
# Note: By default, this searches for checkpoints/gan_last_model.pt in your working directory.
clean_audio = sd.reduce_noise(noisy_audio, sr=sr)

# 3. Save the clean audio
sf.write("clean_speech.wav", clean_audio, sr)

2. Denoise an Audio File Directly

Provide the input and output paths to enhance audio files in one step:

import speech_denoiser as sd

# Enhance file directly
sd.denoise_file("noisy_speech.mp3", "clean_speech.wav")

3. Using a Custom Checkpoint

If you want to point to a specific trained PyTorch checkpoint path:

import speech_denoiser as sd

clean_audio = sd.reduce_noise(
    noisy_audio,
    sr=sr,
    checkpoint_path="checkpoints/gan_last_model.pt",
    device="cuda"  # or "cpu"
)

Under the Hood

speech-denoiser operates on the complex Short-Time Fourier Transform (STFT) of the audio:

  1. It extracts the Real and Imaginary channels of the spectrogram.
  2. The U-Net predicts a bounded complex Ideal Ratio Mask (cIRM) constrained within $[-K, K]$ using a hyperbolic tangent activation.
  3. The mask is decompressed back to its full dynamic range and applied to the noisy spectrogram via complex multiplication.
  4. The clean waveform is reconstructed using the Inverse Short-Time Fourier Transform (ISTFT) and an overlap-add window to ensure seamless stitching without audio artifact seams.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

speech_denoiser-1.0.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

speech_denoiser-1.0.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file speech_denoiser-1.0.0.tar.gz.

File metadata

  • Download URL: speech_denoiser-1.0.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for speech_denoiser-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f47498842e1e889bc5fc64f57bb815d174f49e7c688ec3e060a1bfc8a3d7dedd
MD5 3b3ea06ae05df4407240a8e19c2f58f1
BLAKE2b-256 3e241291499b29ae52bb67365c823ca28a2ed4971d27da889f4ed37be2cb190b

See more details on using hashes here.

File details

Details for the file speech_denoiser-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for speech_denoiser-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 114a5aa6642b2256300288a47f1e32a7b03560edac04db7d7d10525e6389fe8c
MD5 19381a411c8b928c2edb781a9c075316
BLAKE2b-256 eb058f6104ea97c8c0af68c0130d182a71e13f54527669260f0be4943a543951

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page