DISENT-KWS β Speech Disentanglement for Robust Custom Word Detection

- Demo Video Link β YouTube Demo Video
- Setup & Result Reproducibility Video Link β YouTube Setup Video
Quick Start
# Install dependencies
uv sync --all-extras
# Run tests (verify 60+ tests pass)
make test
# Option A: Live record 5 utterances from mic, then enroll
python src/demo.py record --model model_final.pt --out enrollment.pt
# Option B: Provide pre-recorded WAV files
python src/demo.py enroll \
--recordings ./my_recordings/*.wav \
--model model_final.pt \
--out enrollment.pt
# Real-time detection
python src/demo.py detect --enrollment enrollment.pt --auto-threshold --vad-threshold 0.02
Project Artifacts
Technical Documentation
All technical documentation is organized in the docs/ directory:
| Document | Description |
|---|---|
docs/solution_architecture.md | Architecture, mathematical foundations, loss functions, ablation study & results |
docs/installation.md | Environment setup, dependencies, dataset configuration |
docs/user_guide.md | Training pipeline, speaker enrollment, real-time demo, result reproducibility |
docs/ax.md | Agentic AI setup, workflows, tool chaining, and developer retrospective |
Source Code
The complete source code is organized under src/:
Models Used
| Model | Description | License |
|---|---|---|
| SpeechBrain ECAPA-TDNN | Pre-trained speaker verification teacher | Apache 2.0 |
Models Published
| Model | Link | Format | Size |
|---|---|---|---|
| DISENT-KWS | π€ Hugging Face (free tier) | PyTorch + ONNX | 7 MB + 0.60 MB |
The model is hosted on Hugging Face’s free tier β no payment required to download or use.
Datasets Used
| Dataset | Usage | Samples | License |
|---|---|---|---|
| Google Speech Commands v2 | Keyword spotting pre-training | 105K utterances | CC BY 4.0 |
| VoxCeleb1 | Speaker verification training | 153K utterances (1,251 speakers) | CC BY 4.0 |
| LibriPhrase | Hard-negative triplet pairs (up to 3K triplets generated from metadata) | Apache 2.0 | |
| MUSAN | Noise augmentation | 109 hrs | CC BY 4.0 |
Datasets Published
No custom datasets were published. All datasets listed above are publicly available.
Architecture Overview

The system uses a dual-head disentangled architecture built on a shared BC-ResNet-2 encoder (total 1.806M parameters):
- Shared Encoder (BC-ResNet-2) β Broadcasted residual network, 33.8K params
- Temporal Block (Mamba SSM / Dilated Conv1D) β O(T) temporal context modeling, 10.3K params
- Phonetic Head (Causal Conformer) β Extracts keyword-discriminative embeddings zβββ β βΒΉβΉΒ², 1,673K params
- Speaker Head (ECAPA-TDNN Lite) β Extracts speaker-discriminative embeddings zβββ β βΒΉβΉΒ², 88.8K params
- Disentanglement Module (GRL + CLUB) β Adversarial gradient reversal + mutual information minimization forces zβββ β zβββ
- Dual-Gate Scorer β Weighted cosine similarity (
w_kw=0.30,w_spk=0.65) with EMA smoothing and DET-calibrated threshold (Ο=0.2222)
Three-Layer Defense Against False Accepts
| Layer | Mechanism | Failure Mode Blocked |
|---|---|---|
| β | FiLM Conditioning | Directs attention toward enrolled speaker/keyword |
| β‘ | GRL + CLUB Disentanglement | Prevents speaker ID leaking into phonetic embeddings |
| β’ | Dual-Gate Scoring | Both keyword AND speaker must match independently |
Final Performance Benchmarks
Evaluated on Google Speech Commands v2 test set (11,005 samples, 35 classes) and VoxCeleb1 (1,251 speakers). Scorer weights calibrated via joint verification grid search over 10Γ10 weight combinations + DET-driven threshold selection.
| Metric | Achieved | Target | Status |
|---|---|---|---|
| Parameters | 1.806 M | < 3.0 M | β |
| ONNX Model Size | 0.60 MB (INT8) | β | β |
| CPU Latency | 26.43 ms (p95: 28.29 ms) | < 200 ms | β |
| Real-Time Factor (xRT) | 0.0132 | < 0.20 | β |
| Keyword EER (standalone) | 4.69% | low | β |
| Speaker EER (standalone) | 17.86% | low | β |
| Joint EER | 23.47% | β | β |
| Joint AUC | 0.8425 | β | β |
| Optimal Scorer Weights | wβw=0.30, wβββ=0.65 | β | β |
| EER Threshold (Ο) | 0.2222 | β | β |
Detection Error Trade-off (DET) Curve

SNR Robustness Across -5 dB to 30 dB

Ablation Study Results
To isolate each component’s contribution, we systematically disabled modules and re-evaluated:
| Configuration | Keyword EER (%) | Speaker EER (%) | Params | Impact |
|---|---|---|---|---|
| Full Model (baseline) | 4.69 | 17.33 | 1.806 M | β |
| No FiLM Conditioning | 4.69 | 17.33 | 1.683 M | Saves 123K params, no EER change on this test set |
| No Speaker Head | 4.69 | N/A | 1.806 M | KWS-only mode; speaker verification disabled |
| No Temporal Block | 11.22 | 25.48 | 1.796 M | π΄ Keyword EER β6.53pp, Speaker EER β8.15pp |
| Equal Scorer Weights | 4.69 | 17.33 | 1.806 M | Calibrated 0.30/0.65 > equal 0.50/0.50 |

Key Insight: The temporal block is the single most critical component β removing it degrades keyword EER by 2.4Γ and speaker EER by 1.5Γ.
Attribution
This project builds upon and transfers weights from the open-source SpeechBrain repository (ECAPA-TDNN for speaker verification).
Citation
If you use DISENT-KWS in your research, please cite it:
@misc{bt2026disentkws,
title={DISENT-KWS: Speech Disentanglement for Robust Custom Word Detection},
author={Banerjee, Sohini and Tripathi, Swarnim},
year={2026},
howpublished={\url{https://github.com/tripathiji1312/DISENT_KWS}},
note={BC-ResNet-2 backbone with Causal Conformer phonetic head, ECAPA-TDNN Lite speaker head, and GRL+CLUB disentanglement. 1.806M parameters.}
}
Novel Contributions Developed for This Solution
| Innovation | Description |
|---|---|
| Decoupled Dual-Head Architecture | Separate Causal Conformer (phonetic) and ECAPA-TDNN Lite (speaker) heads on a shared BC-ResNet-2 backbone |
| Feature Disentanglement | Gradient Reversal Layer (GRL) + CLUB Mutual Information estimator enforces orthogonal latent spaces |
| Dual-Gate Scorer | Weighted cosine similarity (wβw=0.30, wβββ=0.65) + EMA smoothing for stable real-time streaming |
| Calibration Pipeline | Grid-searched scorer weights + DET curve-driven threshold selection (Ο=0.2222) |
| Rejection Loss | Contrastive triplet loss with hard-negative mining from LibriPhrase for confuser rejection |
| GE2E Speaker Fine-tuning | Generalized End-to-End loss for speaker head refinement in Phase 3 |
| Mamba SSM Fallback | Automatic fallback from Mamba to Dilated Conv1D for cross-platform compatibility |