Skip to main content

SeLib

SeLib is a small speech-enhancement library for ONNX models. It provides a simple enhance() function, lightweight model wrappers, and utility functions for audio/noise experiments.

Install

Install the package directly from GitHub for the latest version.

pip install git+https://github.com/nipponjo/selib.git

or for the latest release:

pip install speech-selib

Basic Use

The shortest path is selib.enhance(wave, model_id). Pass a NumPy waveform at the sample rate expected by the model.

import librosa
import selib

from selib.utils import NoiseGenerator, snr_mixer

# Load clean speech at the model sample rate.
wave_clean, sr = librosa.load("./data/clean_freesound_33711.wav", sr=48000)

# Create artificial noise and mix it with the clean speech at 5 dB SNR.
noise_gen = NoiseGenerator(sample_rate=sr)
noise = noise_gen.sample(n_samples=len(wave_clean))
wave_noisy = snr_mixer(wave_clean, noise, snr=5)

# Enhance with a registered model id.
# The ONNX model is downloaded and cached automatically on first use.
wave_enhanced = selib.enhance(wave_noisy, "deepfilternet3")

You can also save the enhanced waveform directly. The loaded model is cached by default, so repeated calls with the same model_id do not reload the ONNX session.

# Save as 24-bit PCM WAV while returning the enhanced NumPy array.
wave_enhanced = selib.enhance(
    wave_noisy,
    "deepfilternet3",    
    save_to="enhanced.wav",
    bits_per_sample=24,
)

Model Objects

For more control, load the model wrapper once and call its enhance() method directly.

from selib import load_model
from selib.models import DeepFilterNetOnnx

# load_model() chooses the correct wrapper from the registry metadata.
model: DeepFilterNetOnnx = load_model("deepfilternet3")

# DeepFilterNetOnnx supports extra options such as attenuation limiting.
wave_enhanced = model.enhance(wave_noisy, atten_lim_db=12)

Magnitude-mask models can also be used directly. They predict a mask, multiply it with the noisy magnitude spectrogram, and reuse the noisy phase.

from selib.models import MagnitudeMaskModel

# ul_unas_16k is a 16 kHz magnitude-mask model.
mask_model = MagnitudeMaskModel("ul_unas_16k")
wave_enhanced = mask_model.enhance(wave_noisy_16k)

Metrics

SeLib includes a few quick NumPy-only metrics that do not require PESQ/STOI or other external scoring libraries.

from selib.metrics import snr, segsnr, si_sdr

# Compare clean reference speech against an enhanced waveform.
print("SNR:", snr(wave_clean, wave_enhanced))
print("segSNR:", segsnr(wave_clean, wave_enhanced, sample_rate=sr))
print("SI-SDR:", si_sdr(wave_clean, wave_enhanced))

Available Models

Model ID Type Sample rate #params Paper Repository
deepfilternet3 DeepFilterNet 48 kHz 2.13M arXiv:2305.08227 GitHub
deepfilternet2 DeepFilterNet 48 kHz 2.31M arXiv:2205.05474 GitHub
deepfilternet1 DeepFilterNet 48 kHz 1.78M arXiv:2110.05588 GitHub
ul_unas_16k Magnitude mask 16 kHz 0.171M arXiv:2503.00340 GitHub

DeepFilterNet models use ERB masks plus deep-filter coefficients. Magnitude-mask models predict a spectrogram mask and reconstruct audio with the noisy phase.

Metadata

Release files for speech-selib 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for speech-selib 0.2.2
File Size Uploaded Provenance Actions
speech_selib-0.2.2.tar.gz 33.9 kB Without provenance Details for speech_selib-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for speech-selib 0.2.2
File Interpreter ABI Platform Actions
speech_selib-0.2.2-py3-none-any.whl Python 3 none any Details for speech_selib-0.2.2-py3-none-any.whl

Total release size: 72.2 kB

Release files / speech_selib-0.2.2.tar.gz

Download URL speech_selib-0.2.2.tar.gz
Size 33.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dc4240b07f2b70593c2a786962d1b47a508eabf723f0326c525cff1c02b74bcb
BLAKE2b-256 checksum
How to use checksums
5ca33fbc4117b5c03b0d0d39b69ba58655834ba16c95b10149a3e6c9fc56f988
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / speech_selib-0.2.2-py3-none-any.whl

Download URL speech_selib-0.2.2-py3-none-any.whl
Size 38.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
191a44373599ccc2964ac9d9157b6ce0d81e101604196fbfb192c52eea54ae94
BLAKE2b-256 checksum
How to use checksums
59e6842868310cda7b24822c4912b200c51a071c7de7d270dd08851981a37f16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for speech-selib 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page