CLARITY-Net is a speech denoising project built around a lightweight causal U-Net that works on short-time Fourier transform (STFT) spectrograms. The repository combines the research paper in CLARITY Net.pdf with the full notebook-based pipeline for dataset preparation, model training, inference, and evaluation.
The goal of the project is to improve speech quality in noisy environments while keeping latency and model size low enough for real-time or edge-device deployment.
The codebase implements a complete speech enhancement workflow:
- Prepare clean speech clips and generate noisy mixtures.
- Train a causal U-Net-style enhancement model on log-magnitude STFT features.
- Run denoising on the test set and save enhanced waveforms.
- Evaluate the output with objective speech-quality metrics.
The research paper reports the following headline results for the proposed model:
- 63,896 trainable parameters
- SI-SDR: 13.7 dB
- PESQ: 2.865 (narrowband) and 2.135 (wideband)
- STOI: 0.906
- Real-time factor (RTF): 0.309
.
├── CLARITY Net.pdf
├── architecture.ipynb
├── evaluation.ipynb
├── generate.ipynb
├── requirements.txt
└── dataset/
├── clean/
├── clean_clipped/
├── noisy/
├── noisy_pink/
├── noisy_white/
├── noisy-2/
└── test/
├── clean/
├── enhanced/
└── noisy/
generate.ipynbprepares the training and test mixtures.architecture.ipynbdefines the CLARITY-Net model and trains it.evaluation.ipynbbenchmarks denoising quality and computes speech metrics.
The model operates in the time-frequency domain:
- Audio is resampled to 16 kHz.
- STFT is applied with Hann windows.
- The network consumes log-magnitude spectrograms.
- The model predicts a residual correction to the noisy magnitude.
- The enhanced waveform is reconstructed with the original noisy phase.
The paper describes CLARITY-Net as a causal U-Net with:
- depthwise separable convolutions,
- squeeze-and-excitation channel attention,
- group normalization,
- a bottleneck dilation block for a larger receptive field,
- residual learning with a scaling factor of 0.3.
This design keeps the model small while preserving temporal causality for streaming use.
CLARITY-Net is described in the paper as a lightweight causal U-Net for real-time speech enhancement. The model learns to map a noisy signal
The paper uses a Hann-windowed STFT with:
- FFT size: 512
- hop length: 256 samples
- window length: 512 samples
- sample rate: 16 kHz
This yields a spectrogram patch shaped like 257 x 24 in the default notebook implementation, where frequency bins are processed over a short causal time window.
Rather than predicting the clean magnitude directly, the model predicts a residual correction
with the paper using
The noisy phase is reused during reconstruction. This keeps the system simple and consistent with the paper’s real-time design goal.
The network is a compact encoder-decoder with skip connections:
- encoder stages downsample only along the frequency axis,
- the time axis remains causal,
- a bottleneck expands the receptive field using dilation,
- the decoder upsamples the frequency axis and fuses skip features,
- the final output is a residual spectrogram estimate.
The paper’s reference configuration is:
- input:
257 x 24 - encoder channels:
[12, 24, 48] - bottleneck channels:
96 - output:
257 x 24
To support streaming inference, the paper uses causal padding on the time axis so each prediction depends only on current and past context. To reduce compute, the convolutions are depthwise separable:
- depthwise convolution handles per-channel spatial filtering,
- pointwise convolution mixes channel information,
- GroupNorm is used for stability with small batch sizes.
The model includes Squeeze-and-Excitation blocks that apply channel-wise attention. These blocks compress each feature map with global average pooling, then learn a channel scale through a small bottleneck MLP before reweighting the activations.
This gives the network a lightweight way to emphasize informative channels without adding much cost.
The paper presents a hybrid objective that combines magnitude-domain reconstruction with SI-SDR-based waveform quality. In the notebook implementation, the optimization is kept compact and stable by emphasizing an L1 loss on the predicted magnitude residuals, while the paper describes a broader composite training strategy.
The paper includes the following core figures, which are useful when reading the implementation:
- Fig. 1: High-level CLARITY-Net architecture showing the encoder, bottleneck, decoder, and skip connections.
- Fig. 2: The Squeeze-and-Excitation block used for channel attention.
- Fig. 3: The convolutional block used throughout the network.
The notebook implementation follows the same structure, so the figures in the paper map directly to the model classes in architecture.ipynb.
flowchart LR
A[Clean speech] --> B[Add ESC-10 / white / pink noise]
B --> C[STFT magnitude + phase]
C --> D[Log-magnitude spectrogram]
D --> E[CLARITY-Net causal U-Net]
E --> F[Residual magnitude estimate]
F --> G[Reuse noisy phase]
G --> H[iSTFT reconstruction]
H --> I[Enhanced speech]
flowchart TB
I[Input 257 x 24] --> E1[Encoder 1 12 ch]
E1 --> E2[Encoder 2 24 ch]
E2 --> E3[Encoder 3 48 ch]
E3 --> B[Bottleneck 96 ch + dilation]
B --> D3[Decoder 3 48 ch]
D3 --> D2[Decoder 2 24 ch]
D2 --> D1[Decoder 1 12 ch]
D1 --> O[Output residual 257 x 24]
The project uses a composite dataset built from:
- clean speech from LibriSpeech,
- environmental noise from ESC-10,
- synthetic white noise,
- synthetic pink noise.
The generation pipeline in generate.ipynb produces noisy mixtures at multiple SNR levels and organizes them into the dataset folders used by training and evaluation.
Common dataset folders used by the notebooks are:
dataset/clean/- original clean speechdataset/clean_clipped/- clean clips trimmed to a common lengthdataset/noisy_white/- white-noise mixturesdataset/noisy_pink/- pink-noise mixturesdataset/noisy/- final training noisy setdataset/test/noisy/- evaluation noisy setdataset/test/clean/- matching clean references for the test setdataset/test/enhanced/- model outputs written during inference
Install the Python dependencies with:
pip install -r requirements.txtThe project was developed in a Python 3.11 virtual environment. If you want to reproduce the notebook workflow locally, make sure Jupyter support is available in the same environment.
Open generate.ipynb and run the cells in order. This notebook:
- measures the shortest clean clip length,
- clips all clean files to a common duration,
- mixes in white and pink noise at multiple SNR levels,
- builds the ESC-10 based noisy set,
- creates balanced train/test splits under
dataset/noisy/anddataset/test/.
Open architecture.ipynb and run the training cells. This notebook:
- validates the dataset folders,
- builds the
AudioDatasetclass, - converts audio into STFT magnitude and phase pairs,
- defines the lightweight causal U-Net,
- trains the model and saves the best checkpoint as
best_denoiser.pth, - exports a portable model payload as
best_denoiser.pkl.
The training notebook uses residual learning on magnitude spectrograms and reconstructs audio with the noisy phase.
The inference section in architecture.ipynb loads the best checkpoint and writes enhanced .wav files to dataset/test/enhanced/.
It also includes a streaming-style latency benchmark that estimates average per-chunk latency and real-time factor.
Open evaluation.ipynb to compute objective metrics on the test set. The notebook reports:
- PESQ
- STOI
- SI-SDR
- SNR / SI-SNR
- composite measures such as CSIG, CBAK, and COVL when available
After running the notebooks, you should see:
- a trained model checkpoint (
best_denoiser.pth), - a serialized model export (
best_denoiser.pkl), - denoised audio in
dataset/test/enhanced/, - metric tables and benchmark prints inside the evaluation notebook.
The implemented model is intentionally compact:
- input shape:
257 x 24spectrogram patches, - encoder: 3 layers with channels
[12, 24, 48], - bottleneck: 96 channels with a dilated block,
- decoder: symmetric upsampling path,
- output: residual spectrogram estimate.
The paper emphasizes causal processing and low latency, making the model suitable for streaming-style enhancement rather than offline, full-context denoising.
The paper reports that CLARITY-Net was compared with stronger baseline families, including:
- classical enhancement methods,
- vanilla U-Net,
- CRN / DCCRN-style models,
- Conv-TasNet,
- other lightweight speech enhancement models.
The intent of the evaluation is to balance speech quality against computational cost.
The paper also frames the method around the following ideas:
- real-time speech enhancement under latency constraints,
- causal processing for streaming deployment,
- efficiency gains from depthwise separable convolutions,
- feature recalibration using SE attention,
- reconstruction quality evaluated with SI-SDR, PESQ, and STOI.
These ideas are the best guide for reading both the notebook code and the included PDF.
- Keep the dataset folder structure unchanged.
- Make sure training and test file naming stays consistent between noisy and clean pairs.
- If you regenerate the dataset, rerun the notebooks in the order:
generate.ipynb,architecture.ipynb,evaluation.ipynb. - On Apple Silicon, the notebooks prefer
mpswhen available and fall back to CPU when needed.
CLARITY Net.pdf- the research paper for this implementation.architecture.ipynb- model architecture, training, and inference.generate.ipynb- dataset creation and noisy mixture synthesis.evaluation.ipynb- benchmark and metric computation.
No explicit license file is present in the repository. Add one if you want to publish or share the project.