Before the Implant: causal speech enhancer
A small neural network that takes noisy speech and gives back cleaner speech, one sample at a time, without ever looking ahead. It is built for the moment that is hardest for cochlear-implant users: one voice you want to hear inside a room full of other voices.
- Strictly causal Conv-TasNet-style waveform enhancer (
CausalTasNetEnh) - 602,510 parameters, 16 kHz mono
- 5.88 ms algorithmic latency (excluding compute), zero lookahead
- Research and story: https://beforetheimplant.com
- Code and full research record: https://github.com/bmarti44/meta-hackathon-deaf-hard-of-hearing
Erratum (2026-11-05): output sign and DC offset
A later audit on real recordings found two defects in what the model outputs. Neither changes any score in the results below, because those scores ignore sign and DC. Both can matter if you play or mix the output.
- Sign (polarity). The default
model.safetensors(seed 17) andseed19.safetensorsoutput an inverted (upside-down) waveform.seed18.safetensorsdoes not. Training used a loss that cannot see sign, so the sign was set by chance early in training. - DC offset. The last layer adds a constant to every output sample:
+0.110 for seed 17, −0.165 for seed 18 and −0.146 for seed 19.
enhance.pythen restores the output's RMS with that offset included. The file keeps the input's RMS, but the speech itself comes out quieter, with a DC offset. In our check it was 2.3 dB quieter for the default model, 3.9 dB for seed 18 and 3.1 dB for seed 19.
The weights are unchanged, and no code fix has been published yet. A candidate output fix has been tested:
- correct the sign;
- remove the offset;
- restore the speech to the input's level;
- keep peaks below −1 dBFS.
It passed every registered check on fresh audio that fits within full scale. It did not pass the registered rule as a whole, because inputs beyond full scale trade level against peak safety. See Gen 34–36 in the research record: https://github.com/bmarti44/meta-hackathon-deaf-hard-of-hearing/tree/main/research
Until a fix is published, you can correct the output of enhance() for
mono input like this. These are the same steps as the tested candidate,
applied after the fact. In our check they matched it to within 1e-7:
import numpy as np
POLARITY = {"model.safetensors": -1, "seed18.safetensors": 1, "seed19.safetensors": -1}
y = enhance(noisy, sr, model=model) # as before
y = POLARITY["model.safetensors"] * (y - y.mean()) # fix the sign, remove the DC offset
level = np.sqrt(np.mean((noisy - noisy.mean()) ** 2))
y = y * level / (np.sqrt(np.mean(y ** 2)) + 1e-12) # speech back to the input's level
y = y * min(1.0, 10 ** (-1 / 20) / (np.max(np.abs(y)) + 1e-12)) # keep peaks below -1 dBFS
Why
This was built by Graham's dad. Graham has bilateral cochlear implants, and like many implant users he hears well in quiet but struggles when a crowd is talking around him. This project asks whether a tiny, fast, strictly causal model could clean up speech before it reaches an implant's sound processor, and tests that question carefully on a computer first, before any implant is involved.
The research loop that produced this model, from the first generation through Gen 21 (including the test bench, the 14-check scorecard and this Gen 19 model), was run by Muse Wonder Full, Meta's AI model, under Graham's dad's direction, with Codex Astra as an independent reviewer. Claude (Anthropic) ran the final experiments and packaged this release.
Quick start
pip install torch numpy scipy soundfile safetensors huggingface_hub
hf download bmarti44/before-the-implant-causal-enhancer --local-dir before-the-implant
cd before-the-implant
python enhance.py noisy.wav enhanced.wav # default weights: model.safetensors
python enhance.py noisy.wav enhanced.wav --weights seed18.safetensors --device cpu
Any wav works: it is mixed to mono, resampled to 16 kHz and back, and the output has the same length and sample rate as the input. Its RMS matches the input's, but see the erratum above: that RMS includes a DC offset.
Python:
import sys, soundfile as sf
from huggingface_hub import snapshot_download
d = snapshot_download("bmarti44/before-the-implant-causal-enhancer")
sys.path.insert(0, d)
from enhance import load_model, enhance
model = load_model(f"{d}/model.safetensors")
audio, sr = sf.read("noisy.wav")
sf.write("enhanced.wav", enhance(audio, sr, model=model), sr)
Raw model use: model(x) takes a (batch, samples) float tensor at 16 kHz
and returns the enhanced waveform delayed by DELAY = 63 samples
(out[63 + n] estimates clean [n]). enhance.py scales the file to RMS
0.14 (the level of a 0 dB training mixture), removes the delay, and restores
the input level. Those two level steps use the whole file's RMS; the network
itself is causal (verified by a suffix-invariance test in model_causal.py).
Files
| File | What |
|---|---|
model.safetensors | Gen 19 final weights, seed 20261117 (default) |
seed18.safetensors, seed19.safetensors | The other two training seeds |
model_causal.py | Model code (PyTorch only) |
enhance.py | CLI and Python API |
config.json | Sample rate, delay, latency, sizes |
Results (synthetic in-silico bench)
Mean of 3 training seeds, measured against the unprocessed mixture, on synthetic LibriSpeech mixtures with speakers not seen in training. "Crowd" is 8-12 overlapping talkers.
| Row | Result |
|---|---|
| Crowd ΔSI-SDR | +3.51 dB |
| Crowd ΔSTOI | +0.035 |
| Simulated 8-of-22 ACE electrodogram correlation | +0.072 |
| Crowd @ 0 dB | +4.65 dB |
| Crowd @ −5 dB | +1.19 dB (target +1.5, the one failing row) |
| Speech-shaped noise | +6.45 dB |
| Held-out white noise | +0.73 dB |
| Quiet, absolute SI-SDR | 36.3 dB |
13 of 14 required scorecard rows pass. The full scorecard and how each row is
computed are in the GitHub repo (research/bench-n6/).
Training
24,000 steps on mixtures built from LibriSpeech train-clean-100: one target talker plus crowd babble (2-12 other talkers), speech-shaped noise, or quiet, at −5 to +10 dB SNR. Loss: negative SI-SDR against the delay-shifted clean speech.
Training data: LibriSpeech (Panayotov et al., 2015), CC BY 4.0.
Limitations
- It has only been tested by computer, on synthetic mixtures.
- No listener has tried it, and it has never been used with any implant.
- It has not been compared with the Nucleus 6 processor's own noise processing.
- The hardest case, a crowd louder than the voice (−5 dB), still misses its target.
- Streaming speed (real-time factor) has not been measured yet.
- It was trained on read English audiobook speech at 16 kHz; other voices, languages and rooms are untested.
Citation
@misc{martin2026beforetheimplant,
title = {Before the Implant: a strictly causal speech enhancer for cochlear-implant listening research},
author = {Martin, Brian},
year = {2026},
howpublished = {\url{https://huggingface.co/bmarti44/before-the-implant-causal-enhancer}},
note = {Code: https://github.com/bmarti44/meta-hackathon-deaf-hard-of-hearing}
}
@inproceedings{panayotov2015librispeech,
title = {Librispeech: an {ASR} corpus based on public domain audio books},
author = {Panayotov, Vassil and Chen, Guoguo and Povey, Daniel and Khudanpur, Sanjeev},
booktitle = {ICASSP},
year = {2015}
}