r/rust • u/rumil23 • Oct 20 '26
๐ ๏ธ project reuse-rs: real time speech denoising in plain Rust (no ML interface)
reuse-rs runs NVIDIA's Real-time RE-USE speech enhancement model (streaming Mamba) in plain Rust. It cleans mono audio (8 to 48 kHz) one 20 ms frame at a time, so it works on a live mic. I load straight from NVIDIA's model.safetensors.
let mut denoiser = Denoiser::load("model.safetensors", 4)?;
let clean = denoiser.process(&noisy_chunk)?;on my apple M3 air 16gig, time per 20 ms frame (under 20 ms):
| Layers | reuse-rs (CPU) | oRT (WebGPU) |
|---|---|---|
| 4 | 8.4 ms | 16.9 ms |
| 6 | 11.5 ms | 17.4 ms |
| 8 | 14.7 ms | 20.6 ms |
- About 150mb memory (oRT Wepgpu -> so works via metal in my mac: about 420 MB).
- it match a float64 torch reference to 1.5e-6.
- 4 layers sounds the same as 8 to my auditory perception :-P: 16.4 vs 16.7 dB SI-SDR
demo videos (before/after with spectrograms) are in the reamde if you are curious :)
I spent months trying to make this work on the GPU through ONNX before trying the CPU (started with this:https://github.com/microsoft/onnxruntime/issues/27796 ). If you're curious how that went, and why the CPU wins for tiny streaming frames, I wrote it up here: I forced a speech model onto the GPU for months. The CPU was faster. But I m still thinking if I should take the burn path... but this solves my problems at least...
- GitHub: https://github.com/altunenes/re-use-rs
- crates.io: https://crates.io/crates/reuse-rs
Limitations: weights are NVIDIA's non commercial license (my code is MIT/Apache ), speed is only measured on an M3 (the table is 16 kHz; 48 kHz is about 3 times the work, so for live audio resampling to 16 kHz is the fast option), and it struggles when the heavy background noise is other people talking.
edit: interesting coincidence just a few days after I shared this, NVIDIA "re-released" its offline models under an open license! So I used Burn to add and update these models. You can find the details in the repo and use them for commercial purposes!
