Blind SNR estimation for speech and voice technology pipelines. Designed for TTS, ASR, voice biometrics, and STS workflows. No clean reference file required.
Project description
mashood-neural-snr ๐๏ธ
Blind SNR estimation for speech and voice technology pipelines โ TTS, ASR, voice biometrics, and STS. No clean reference file required.
What Is This
mashood-neural-snr is a Python package that measures the Signal-to-Noise Ratio (SNR) of a voice recording โ without needing a separate clean version of the same recording.
It was built specifically for speech technology workflows where audio quality is not a nice-to-have but a direct input to model performance. If you are building or maintaining a TTS system, an ASR pipeline, a voice biometrics system, or a speech-to-speech engine โ the SNR of your audio data determines the quality of what comes out the other side.
What Is SNR โ In the Context of Voice
SNR stands for Signal-to-Noise Ratio. In the context of voice recordings, it measures how dominant the speech signal is over the background noise โ expressed in decibels (dB).
Think of it this way:
You have a voice recording. Inside that recording there are two things: the person's voice (the signal) and everything else โ traffic, HVAC, keyboard clicks, crowd noise (the noise). SNR tells you the ratio of one to the other.
A high SNR means the voice is loud and clear relative to the background. A low SNR means the noise is competing with or burying the voice.
+20 dB โ Voice is 100ร more powerful than noise โ Clean recording
+5 dB โ Voice is only 3ร more powerful than noise โ Noisy recording
0 dB โ Voice and noise are equal in power โ Very poor
-10 dB โ Noise is 10ร more powerful than voice โ Voice buried
In speech technology, SNR is not just a quality metric โ it is a data quality gate. Recordings below a minimum SNR threshold should not enter your training pipeline, your enrollment database, or your production system.
Why SNR Matters โ Per Domain
Text-to-Speech (TTS) and Voice Cloning
A TTS model learns to synthesize speech by studying the acoustic patterns in your training recordings. If those recordings contain background noise, the model learns the noise too โ and reproduces it in synthesis output as artifacts, distortion, or unnatural voice quality.
This is especially critical for voice cloning, where the model is learning the characteristics of a specific speaker. Noisy recordings corrupt the speaker representation at the identity level, not just at the quality level.
Consequence of ignoring SNR: Degraded synthesis quality, audible artifacts, failed voice cloning.
Automatic Speech Recognition (ASR)
ASR models convert voice to text. Background noise introduces acoustic ambiguity โ phonemes become harder to distinguish, and the model accumulates errors. This is measured as Word Error Rate (WER). The relationship is direct: lower SNR โ higher WER.
For ASR training data, noisy recordings teach the model wrong acoustic-to-phoneme mappings. For inference, noisy input audio causes transcription failures that no amount of model improvement can compensate for if the input quality is fundamentally poor.
Consequence of ignoring SNR: Elevated Word Error Rate, transcription failures, poor model generalization.
Voice Biometrics and Speaker Verification
Voice biometrics systems work by extracting a speaker embedding โ a mathematical fingerprint of a person's voice โ and comparing it against a stored enrollment embedding. This comparison needs to be stable across different recording conditions.
Background noise distorts the acoustic features that speaker embeddings are built from. A recording with poor SNR produces a distorted embedding that may not match even the correct speaker's enrollment profile, causing false rejections. Conversely, noise patterns that are consistent across recordings can cause false accepts.
Consequence of ignoring SNR: Increased false rejection rate (FRR), degraded Equal Error Rate (EER), unreliable biometric authentication.
Speech-to-Speech (STS)
Speech-to-speech systems โ voice translation, voice conversion, real-time dubbing โ chain together ASR, processing, and TTS or voice synthesis. Noise at the input compounds through every stage of the pipeline. A transcription error caused by low SNR at the ASR stage propagates forward and cannot be recovered by downstream components.
Consequence of ignoring SNR: Compounding errors across pipeline stages, degraded output naturalness and intelligibility.
Why Existing SNR Tools Fail on Real Voice Recordings
Traditional SNR estimation methods โ including VAD-based approaches and WADA-SNR โ share a fundamental assumption: noise can only be measured during silence.
Traditional method: [SPEECH+NOISE] [SILENCE] [SPEECH+NOISE]
โ
measure noise here only
This works in controlled laboratory recordings. It fails in the real world because:
- Continuous noise (traffic, HVAC, air conditioning) produces no silence gaps long enough for stable estimation
- Noise measured in silence is not noise under speech โ spectral characteristics differ during voiced activity
- Short clips (< 5 seconds) may have no silence at all
The blind estimation problem. In a real-world recording you never receive two separate files โ one clean, one noisy. You receive a single mixed file where speech and noise are already combined. The standard SNR formula requires signal power and noise power to be known independently โ but in a real recording you only have their sum. This is called blind SNR estimation, and it is why reference-based tools are useless in production pipelines: there is no clean reference to compare against.
WADA-SNR specifically fits a gamma distribution to speech amplitude values. It requires long recordings to converge and degrades on non-stationary or overlapping noise โ exactly the conditions present in real-world data collection.
mashood-neural-snr does not look for silence at all. It estimates the speech component directly using a neural enhancement model, making the noise derivation independent of silence regions and noise type.
How It Works
The package repurposes DeepFilterNet3 โ a real-time neural speech enhancement model โ as the engine of a blind SNR estimator. Here is exactly what happens when you call snr("recording.wav"):
Step 1 โ Load and Resample
The WAV file is loaded and resampled to 48 kHz, the fixed sample rate required by DeepFilterNet3.
Step 2 โ Neural Speech Enhancement
DeepFilterNet3 processes the noisy waveform and produces a denoised output. The model was trained specifically to preserve speech and suppress background noise โ it applies learned spectral gains and complex filters in the frequency domain to output its best estimate of what the clean speech sounds like.
noisy_recording โ DeepFilterNet3 โ enhanced_speech
This enhanced output is the speech estimate. The key insight is that a model trained to remove noise gives us a proxy for the clean signal โ which we can then use to derive the noise component by subtraction.
Step 3 โ Latency Correction
Neural enhancement introduces a small processing delay. The enhanced signal is time-shifted relative to the original. Cross-correlation finds the exact lag between them and aligns both signals to the same time axis.
Step 4 โ Amplitude Correction
The enhancement model may output at a slightly different amplitude than the original. A least-squares scalar ฮฑ is computed to match the enhanced signal's amplitude to the original โ ensuring the subsequent subtraction is numerically clean.
Step 5 โ Noise Extraction and SNR Computation
The scaled, aligned speech estimate is subtracted from the original to isolate the noise residual:
noise_estimate = original_recording โ (ฮฑ ร enhanced_speech)
SNR is then computed as the power ratio of the speech estimate to the noise estimate:
SNR (dB) = 10 ร logโโ ( Power(speech_estimate) / Power(noise_estimate) )
Requirements & Compatibility
| Python | >= 3.8, < 3.12 |
| PyTorch | >= 1.9, <= 2.5.1 |
| torchaudio | >= 0.9, <= 2.5.1 |
| Device | CPU and CUDA โ auto-detected |
| Google Colab | โ Compatible (see note below) |
| OS | Windows, Linux, macOS |
Why Python < 3.12? One of the underlying dependencies (
deepfilternet) does not yet publish prebuilt binaries for Python 3.12. Installing on 3.12 would otherwise silently fall back to compiling from source, which requires a Rust toolchain and fails on most systems, including a fresh Google Colab runtime. Using Python 3.8โ3.11 avoids this entirely.
Google Colab default Python version. Colab may default to Python 3.12 depending on the runtime. If installation fails, either select a Python 3.11 runtime, or install the Rust toolchain first:
!curl https://sh.rustup.rs -sSf | sh -s -- -y import os os.environ['PATH'] += ':/root/.cargo/bin' !pip install mashood-neural-snr
Installation
pip install mashood-neural-snr
Using uv:
uv pip install mashood-neural-snr
CPU-only torch (smaller download, no CUDA):
pip install mashood-neural-snr --index-url https://download.pytorch.org/whl/cpu
Usage
Basic
from mashood_neural_snr import snr
score = snr("recording.wav")
# SNR: 12.43 dB | Device: cpu
Device Control
# Auto-detect โ uses CUDA if available, falls back to CPU
score = snr("recording.wav")
# Force CPU
score = snr("recording.wav", device="cpu")
# Force CUDA
score = snr("recording.wav", device="cuda")
Batch Processing
Use SNREstimator directly for multiple files. It loads the model once on creation and reuses it across all calls. Using snr() in a loop initializes the model on every call, which is significantly slower.
from mashood_neural_snr import SNREstimator
estimator = SNREstimator(device="cuda") # model loads here, once
files = ["speaker1.wav", "speaker2.wav", "speaker3.wav"]
for f in files:
score = estimator.estimate(f, show_progress=False)
print(f"{f}: {score:.2f} dB")
Suppress Progress Bar
score = estimator.estimate("recording.wav", show_progress=False)
API Reference
snr(file_path, device=None)
Single-file convenience function. Maintains a module-level SNREstimator singleton โ the model loads on the first call and is reused on all subsequent calls with the same device.
| Parameter | Type | Default | Description |
|---|---|---|---|
file_path |
str |
required | Path to a .wav audio file |
device |
str |
None |
'cuda', 'cpu', or None (auto-detect) |
Returns: float โ estimated SNR in decibels (dB)
SNREstimator(device=None)
Class-based interface. Recommended for batch processing.
| Parameter | Type | Default | Description |
|---|---|---|---|
device |
str |
None |
'cuda', 'cpu', or None (auto-detect) |
Attributes:
.deviceโ the resolved device (torch.device) in use
.estimate(file_path, show_progress=True)
| Parameter | Type | Default | Description |
|---|---|---|---|
file_path |
str |
required | Path to a .wav audio file |
show_progress |
bool |
True |
Show per-step tqdm progress bar |
Returns: float โ estimated SNR in decibels (dB)
Supported Audio
| Property | Details |
|---|---|
| Format | .wav only |
| Channels | Mono and Stereo (stereo averaged to mono internally) |
| Sample Rate | Any โ resampled to 48 kHz internally |
| Minimum Duration | ~3 seconds recommended |
| Signal Type | Speech and voice only |
SNR Thresholds โ Per Domain
These thresholds reflect the SNR levels at which each speech technology domain experiences meaningful performance degradation. Use them as data quality gates in your pipeline.
Text-to-Speech (TTS) and Voice Cloning
| SNR | Recommendation |
|---|---|
| โฅ 35 dB | Ideal โ use for voice cloning and high-quality TTS training |
| 25โ35 dB | Good โ suitable for TTS training with standard preprocessing |
| 20โ25 dB | Acceptable โ apply enhancement before use |
| < 20 dB | Reject โ noise will corrupt synthesis quality |
LibriTTS, the standard benchmark corpus for TTS research, applies SNR filtering as a core curation criterion. 20 dB is widely treated as the minimum floor for TTS training data.
Automatic Speech Recognition (ASR)
| SNR | Recommendation |
|---|---|
| โฅ 30 dB | Ideal for training and inference |
| 20โ30 dB | Good โ acceptable for most ASR systems |
| 10โ20 dB | Marginal โ enhancement recommended before use |
| < 10 dB | Reject for training; expect elevated WER at inference |
ASR systems generally require SNR โฅ 30 dB for accurate contextual understanding. Below 10 dB, word error rates rise sharply.
Voice Biometrics and Speaker Verification
| SNR | Recommendation |
|---|---|
| โฅ 20 dB | Reliable speaker embeddings โ use for enrollment and verification |
| 10โ20 dB | Acceptable โ monitor Equal Error Rate (EER) closely |
| < 10 dB | Reject โ noise distorts speaker embeddings, degrades EER |
10 dB is the recommended minimum threshold for voice biometrics, based on empirical study of noise impact on speaker verification performance across Animal, Nature, Environmental, and Object noise categories at controlled SNR levels.
Speech-to-Speech (STS)
| SNR | Recommendation |
|---|---|
| โฅ 25 dB | Clean input โ full pipeline quality preserved |
| 15โ25 dB | Acceptable โ minor degradation at output |
| < 15 dB | Apply enhancement at input stage before pipeline entry |
| < 10 dB | Reject โ errors compound through ASR โ synthesis stages |
Benchmark Results
Evaluated on a controlled dataset of 2,560 samples built from LibriSpeech:
- Speakers: 8 LibriSpeech speakers โ 4 male, 4 female
- Duration: 50 seconds per sample
- Noise categories: Animal, Nature, Environmental, Objects
- Noise sources: ESC-50, UrbanSound8K, DEMAND
- SNR levels tested: โ20, โ15, โ10, โ5, +5, +10, +15, +20 dB
- Mixing: Power-based SNR mixing โ noise scaled to exact target SNR before mixing with clean speech
| True SNR | Mean Predicted | Mean Abs Error | Within ยฑ2 dB |
|---|---|---|---|
| +20 dB | 19.03 dB | 1.46 dB | 78.1% โ |
| +15 dB | 14.62 dB | 0.79 dB | 92.2% โ |
| +10 dB | 9.84 dB | 0.50 dB | 95.0% โ |
| +5 dB | 4.96 dB | 0.35 dB | 99.4% โ |
| โ5 dB | โ4.88 dB | 0.39 dB | 99.7% โ |
| โ10 dB | โ9.44 dB | 0.91 dB | 86.6% โ |
| โ15 dB | โ13.24 dB | 2.37 dB | 60.9% โ ๏ธ |
| โ20 dB | โ15.91 dB | 5.11 dB | 30.9% โ |
Overall Mean Absolute Error across the reliable operating range (โ10 dB to +20 dB): 0.97 dB
Sub-1 dB mean error across 7 out of 8 SNR levels covering the full practical range for speech technology applications.
Known Limitations
Reliable operating range is โ10 dB to +20 dB. Below โ15 dB, the speech signal is physically buried in noise. DeepFilterNet3 cannot reliably suppress noise at this level โ the enhancement output becomes unstable, and the residual no longer cleanly represents noise. Recordings in this range should be rejected outright. Do not rely on the estimated score as a quality signal below โ15 dB.
Speech and voice signals only. DeepFilterNet3 was trained to preserve speech and suppress everything else. Running it on music, environmental audio, or any non-voice signal will cause the model to treat signal content as noise โ producing meaningless SNR estimates.
WAV format only. MP3, FLAC, M4A, and other formats must be converted to WAV before use.
Minimum recommended duration: ~3 seconds. Cross-correlation alignment requires sufficient signal length to find a stable lag peak. Very short clips may produce unreliable alignment and unstable SNR estimates.
Single-speaker recordings. The package has been evaluated on single-speaker recordings only. Multi-speaker or overlapping speech has not been benchmarked.
License
Licensed under the MIT License.
You are free to use, copy, modify, merge, publish, distribute, sublicense, and sell copies of this software โ including in commercial products โ with no restrictions beyond preserving the copyright notice.
Full license terms: LICENSE
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mashood_neural_snr-0.1.6.tar.gz.
File metadata
- Download URL: mashood_neural_snr-0.1.6.tar.gz
- Upload date:
- Size: 8.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6534f4bb6c677e081590a95269c3942bf469cb95107b45103d3da6da8d8a175b
|
|
| MD5 |
01e3627046ede68fede8025f93e61a61
|
|
| BLAKE2b-256 |
02ca4fd8d56fb32e7b6481183b5a7f6f80df5a7671224feda957f8d810e74f90
|
File details
Details for the file mashood_neural_snr-0.1.6-py3-none-any.whl.
File metadata
- Download URL: mashood_neural_snr-0.1.6-py3-none-any.whl
- Upload date:
- Size: 8.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f57755f089a1b22acd584503daf3c9df8cf212b6fc2680ddbdae4c7b4c70f6e
|
|
| MD5 |
3737fe0d50ef22f70494bc13d11a472d
|
|
| BLAKE2b-256 |
97f09389ea600cab15f16ec58c364b3c1e0c5d799fe9d80b1fe00402a919d75b
|