SpectraHush extends Boll's (1979) original spectral subtraction algorithm with the two parameters introduced by Berouti, Schwartz, and Makhoul (1979): the over-subtraction factor (
It is intentionally small: a single-file Python implementation with no heavy DSP dependencies, suitable for embedded use, telephony pipelines, voice front-ends, and as a teaching reference for classical speech-enhancement.
- Convert incoming audio to overlapping STFT frames (Hann window, 75% overlap).
- Track the background noise PSD on frames flagged as non-speech by an energy-ratio VAD.
- Apply Berouti-style spectral subtraction:
|S_hat(f)|^p = max( |Y(f)|^p - alpha * |N_hat(f)|^p , beta * |N_hat(f)|^p ) - Reconstruct the time-domain signal via overlap-add (OLA), reusing the noisy phase.
Requires Python 3.9+.
git clone https://github.com/Ajaneeshwar/SpectraHush.git
cd SpectraHush
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtOr install as a package (provides the spectrahush console command):
pip install -e .Stream directly from your microphone to your speakers with noise reduction applied in real time. Stay silent for the first 0.5 s so the noise profile can calibrate.
python spectral_subtraction.py liveApply the algorithm to a pre-recorded .wav file.
python spectral_subtraction.py file input.wav output.wavUse record_test.py to record yourself and generate both a noisy and a cleaned .wav file, along with SNR-reduction metrics.
python record_test.py --duration 10 --playTuning parameters live in config.yaml. Missing keys fall back to built-in defaults; CLI flags override the config.
| Parameter | Description |
|---|---|
alpha |
Over-subtraction factor. Higher = more suppression, more musical noise. |
beta |
Spectral floor as a fraction of noise PSD. Higher = preserves natural hiss. |
power |
2.0 for power subtraction (default), 1.0 for magnitude subtraction. |
vad_threshold_db |
SNR threshold (dB) above which a frame is treated as speech. |
noise_smooth |
Recursive smoother for the noise PSD on noise-like frames. |
mag_smooth |
1-pole smoother on ` |
Override on the fly:
python spectral_subtraction.py file input.wav output.wav --alpha 3.0 --beta 0.05If you use SpectraHush in academic work, please also cite the foundational papers:
@inproceedings{boll1979,
author = {Boll, Steven F.},
title = {Suppression of Acoustic Noise in Speech Using Spectral Subtraction},
booktitle = {IEEE Transactions on Acoustics, Speech, and Signal Processing},
year = {1979},
volume = {27},
number = {2},
pages = {113--120}
}
@inproceedings{berouti1979,
author = {Berouti, M. and Schwartz, R. and Makhoul, J.},
title = {Enhancement of Speech Corrupted by Acoustic Noise},
booktitle = {Proc. IEEE ICASSP},
year = {1979},
pages = {208--211}
}Bug reports, feature requests, and pull requests are welcome. See CONTRIBUTING.md for guidelines.
MIT License. See LICENSE for details.
