voice-isolator-ONNX / README.md
jennyxue's picture
Link the realtime model
5e165b3 verified
|
Raw History Blame Contribute Delete
16.6 kB
---
base_model: inworld/voice-isolator
base_model_relation: quantized
license: apache-2.0
pipeline_tag: audio-to-audio
library_name: onnx
tags:
- onnx
- moonbox
- onnxruntime
- inworld
- voice-isolation
- speech-enhancement
- denoising
- noise-suppression
- 48khz
- full-band
---
# Inworld Voice Isolator ONNX
ONNX builds of [Inworld Voice Isolator](https://huggingface.co/inworld/voice-isolator), made by Moonbox for on-device use with ONNX Runtime (CPU, CUDA, DirectML). Each
precision is one folder; what the graphs take and return, and the signal processing that goes around them, is
under *How to run*.
## Files
The last column is the benchmark on the VoiceBank-DEMAND test set (824 noisy utterances; details under *How to
run*): each precision's speech-quality scores, and how far its output is from the original PyTorch model's.
| Precision | File | Size | sha256 | Benchmark |
|---|---|---|---|---|
| fp16 | [`fp16/model.onnx`](https://huggingface.co/moonbox-dev/voice-isolator-ONNX/blob/main/fp16/model.onnx) | 129.1 MB | `8c6f4348a4cb` | fp16 weights, fp32 math: PESQ 3.261, STOI 0.9553, SI-SDR 19.91 dB (original 3.259 / 0.9553 / 19.91); output 81.8 dB from the original's (worst file 69.3), no file below it by more than 0.003 dB (CUDA, RTF 0.26) |
| fp16 | [`fp16/pipeline.py`](https://huggingface.co/moonbox-dev/voice-isolator-ONNX/blob/main/fp16/pipeline.py) | 4.3 kB | `108a5130bf62` | fp16 weights, fp32 math: PESQ 3.261, STOI 0.9553, SI-SDR 19.91 dB (original 3.259 / 0.9553 / 19.91); output 81.8 dB from the original's (worst file 69.3), no file below it by more than 0.003 dB (CUDA, RTF 0.26) |
| int8 | [`int8/model.onnx`](https://huggingface.co/moonbox-dev/voice-isolator-ONNX/blob/main/int8/model.onnx) | 66.8 MB | `56dbd8b6551f` | weight-only int8: PESQ 3.272, STOI 0.9554, SI-SDR 19.90 dB; output 52.8 dB from the original's (worst file 43.1), no file below it by more than 0.06 dB (CUDA, RTF 0.29) |
| int8 | [`int8/pipeline.py`](https://huggingface.co/moonbox-dev/voice-isolator-ONNX/blob/main/int8/pipeline.py) | 4.3 kB | `108a5130bf62` | weight-only int8: PESQ 3.272, STOI 0.9554, SI-SDR 19.90 dB; output 52.8 dB from the original's (worst file 43.1), no file below it by more than 0.06 dB (CUDA, RTF 0.29) |
## How to run
Inworld Voice Isolator v1, the offline model (64M parameters: band-split dual-path network with transformers and
bidirectional Mamba along time and across bands; keeps the voice and removes noise, music and reverb from 48 kHz
mono audio), as one ONNX graph and `pipeline.py`, a numpy runtime that does the rest:
- `model.onnx`: `spec` [1, 1025, T, 2] (real and imaginary parts of the STFT: n_fft 2048, hop 480, periodic Hann,
centred) -> `change` [1, 1025, T, 2], the complex correction the network makes to that spectrum (mask delta x
spectrum plus a bounded residual). The output is the input plus the iSTFT of the change, as
`VoiceIsolatorNetwork.forward` in inworld-voice-isolation. T is free (100 frames per second).
- `pipeline.py`: STFT, iSTFT, and the original's 8 s windows overlapping by 2 s with linear crossfades for longer
audio. Needs numpy and onnxruntime (or onnxruntime-gpu); soundfile to read files.
```python
import sys; sys.path.insert(0, "fp16")
import soundfile as sf
from pipeline import VoiceIsolator
iso = VoiceIsolator("fp16", providers=["CUDAExecutionProvider", "CPUExecutionProvider"])
audio, sr = sf.read("noisy.wav", dtype="float32") # mono, 48 kHz (resample other rates first)
sf.write("voice.wav", iso.isolate(audio), 48000)
```
Every frame sees its whole 8 s window (it is not a streaming model; Inworld's realtime model,
`denoiser_realtime.safetensors`, is in
[moonbox-dev/voice-isolator-realtime-ONNX](https://huggingface.co/moonbox-dev/voice-isolator-realtime-ONNX)). One 8 s window takes about 5.4 GB of GPU memory with ONNX
Runtime's CUDA provider (`int8/` 5.2 GB; 4 s: 2.4 GB), mostly the attention over 800 frames; on the CPU provider it
needs about as much RAM. Over many files of different lengths the CUDA memory arena fragments: the benchmark below
ran with `gpu_mem_limit` 7 GB for `fp16/` and 9 GB for `int8/` (`arena_extend_strategy` `kSameAsRequested`).
**Precisions.** `fp16/`: the weights stored in fp16 and cast to fp32 where they are read, so the arithmetic is fp32
(fp16 activations overflow in this network); 129 MB, half the fp32 graph. `int8/`: weights int8 per output channel behind
DequantizeLinear (every matrix multiplication and convolution), activations fp32; 67 MB.
**Benchmark.** VoiceBank-DEMAND test set (Valentini et al.: 824 utterances by two unseen speakers, 48 kHz), each file
in one call of `isolate`. PESQ is wide-band (ITU-T P.862.2, at 16 kHz), STOI at 48 kHz, SI-SDR against the clean
speech; "vs original" is the SI-SDR of each output against the PyTorch model's output (mean / worst file). The
original is inworld-voice-isolation's `VoiceIsolator.isolate` (offline) in fp32 on CUDA; its own CUDA default, bf16
autocast, is shown too. Pass (speech enhancement): no file more than 0.5 dB SI-SDR below the original's. Real-time
factor (processing time / audio time) on an RTX 3080 Laptop GPU, whole pipeline.
| | PESQ | STOI | SI-SDR (dB) | vs original (dB) | Real-time factor |
|---|---|---|---|---|---|
| original (PyTorch fp32, CUDA) | 3.259 | 0.9553 | 19.91 | - | 0.22 |
| original, bf16 autocast (its CUDA default) | 3.276 | 0.9552 | 19.90 | 59.2 / 45.0 | 0.19 |
| `fp16/` (CUDA) | 3.261 | 0.9553 | 19.91 | 81.8 / 69.3 | 0.26 |
| `int8/` (CUDA) | 3.272 | 0.9554 | 19.90 | 52.8 / 43.1 | 0.29 |
A 4-bit build (MatMulNBits on the matrix multiplications, 44 MB) scored PESQ 3.292, SI-SDR 19.82 dB, but 8 files were
more than 0.5 dB below the original's (worst 1.44 dB; 35.4 dB from it on average), so it is not published.
## How these were made
From [Inworld Voice Isolator](https://huggingface.co/inworld/voice-isolator) at revision `9b0285b3fe`, starting from an fp32 ONNX graph (where it came from is said above).
fp16: onnxconverter-common with inputs and outputs kept fp32, or, where the network's activations leave fp16's
range, fp16 weights with fp32 math (said above when so). int8: weight-only, every Conv / MatMul / GRU weight int8
with a per-output-channel scale behind DequantizeLinear and activations in fp32, so it runs on the CPU provider
without a calibration set. int4: ONNX Runtime's MatMulNBits (weight-only, block 32) on the MatMul weights, the rest
int8 as above, where the graph has enough MatMul weights to matter. No bf16: ONNX Runtime has no bf16 convolution or
GRU kernels. Every graph was benchmarked before upload; the `sha256` column above is what the files must hash to.
## License
Apache-2.0. These files are a derivative of the original model and carry its license: it is copied in this
repository, and it governs your use of these files. The original model card follows unchanged.
---
# Original model card
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/inworld/voice-isolator/resolve/main/docs/assets/inworld-logo-white.svg">
<img src="https://huggingface.co/inworld/voice-isolator/resolve/main/docs/assets/inworld-logo-black.svg" alt="Inworld" width="220">
</picture>
</p>
<h1 align="center">Voice Isolator</h1>
<p align="center">
Open-license (Apache-2.0) 48 kHz voice isolation for noisy speech recordings and live audio.
</p>
<p align="center">
<a href="https://github.com/inworld-ai/voice-isolator"><img src="https://img.shields.io/badge/GitHub-inworld--ai%2Fvoice--isolator-181717?logo=github" alt="GitHub: inworld-ai/voice-isolator"></a>
</p>
---
## TL;DR
Inworld Voice Isolator v1 ships as two models that share one architecture:
| | `voice-isolator-v1` | `voice-isolator-v1-realtime` |
|---|---|---|
| made for | recorded audio and anything not latency-sensitive, at the best quality | live audio, as a stream in your pipeline or production |
| how it runs | offline: every frame sees its whole 8 s chunk | a causal stream with 20 ms of look-ahead |
| parameters | 64M | 58M |
**Use them for** cleaning recordings before playback or publication, curating speech datasets and voice pipelines where the speaker's identity must survive.
With the realtime model, use them for live calls and streams.
Subtract the isolated voice from the input to extract background noise or a backing-track residual for vocals/music separation.
**They are not** a speaker selector or a restoration model.
Restoration is planned for version 2 (see [Plans](https://github.com/inworld-ai/voice-isolator#plans)).
## Quick start
Using a coding agent? Point it at the [setup section of AGENTS.md](https://github.com/inworld-ai/voice-isolator/blob/main/AGENTS.md#setting-up-the-voice-isolator-for-a-user): it installs the package, checks the machine with `voice-isolate-doctor` and cleans a first file.
```bash
pip install inworld-voice-isolation
# or from a clone: git clone https://github.com/inworld-ai/voice-isolator && cd voice-isolator && pip install -e .
# a noisy example; a clone also has it at demo/examples/sample_14.wav
curl -LO https://raw.githubusercontent.com/inworld-ai/voice-isolator/main/demo/examples/sample_14.wav
# offline isolation (downloads the offline model on first use):
# the voice goes to sample_14_clean.wav and the removed background
# to sample_14_clean_background.wav, beside it
voice-isolate sample_14.wav sample_14_clean.wav
```
Both are float32 WAVs at 48 kHz, with their original levels preserved; together they reconstruct the aligned mono input.
Use `--output-sr 0` to keep the input rate, `--background noise.wav` to choose the background path for one file, or `--no-background` to save only the voice.
```python
from inworld import voice_isolation
# isolate a recording offline
offline = voice_isolation.VoiceIsolator("inworld/voice-isolator")
wav, sample_rate = voice_isolation.load_audio("sample_14.wav")
voice = offline.isolate(wav, sample_rate)
voice_isolation.save_audio("sample_14_clean.wav", voice, sample_rate, subtype="FLOAT")
voice_isolation.save_audio("sample_14_clean_background.wav", wav - voice, sample_rate, subtype="FLOAT") # what was removed
```
### Streaming
The realtime model isolates the voice as the audio arrives, with 20 ms of look-ahead:
```python
import torch
from inworld import voice_isolation
live = voice_isolation.VoiceIsolator("inworld/voice-isolator",
mode="streaming", lookahead_frames=2)
session = live.stream() # takes 48 kHz mono, in pieces of any size
wav, sample_rate = voice_isolation.load_audio("sample_14.wav") # 48 kHz mono, standing in for a live source
voice = []
for start in range(0, len(wav), 960): # 20 ms at a time, as a microphone delivers it
voice.append(session.push(wav[start:start + 960])) # the samples that are final: play or send them
voice.append(session.flush()) # the rest, once the source ends
voice_isolation.save_audio("sample_14_streamed.wav", torch.cat(voice), sample_rate)
```
The streaming CLI writes only the isolated voice, after the whole file has gone through:
```bash
voice-isolate sample_14.wav sample_14_streamed.wav --mode streaming --lookahead 2
```
The weights download on first use, and their checksums are verified.
The mode picks the checkpoint: `voice-isolator-v1` offline, `voice-isolator-v1-realtime` for streaming.
CUDA is used when available, Apple's Metal backend (`mps`) on an Apple-silicon Mac with PyTorch 2.6 or later, and the CPU otherwise; `--device` picks one.
The code, the [interactive demo](https://github.com/inworld-ai/voice-isolator/blob/main/demo/README.md) and the [benchmark](https://github.com/inworld-ai/voice-isolator/blob/main/bench/README.md) are on GitHub: [inworld-ai/voice-isolator](https://github.com/inworld-ai/voice-isolator).
The demo loads both models at startup: **Offline** processes files and samples into voice and background audio; **Online** streams the microphone for up to 60 seconds with updating waveforms and spectrograms, pausing capture before playback.
## Hardware
Tested on NVIDIA Ampere, Hopper and Blackwell GPUs (A100, H100, B200 and B300) and on CPU.
Smaller GPUs are not tested yet (see [Plans](https://github.com/inworld-ai/voice-isolator#plans)).
## The VIBE benchmark
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/inworld/voice-isolator/resolve/main/docs/assets/board-dark.svg">
<img src="https://huggingface.co/inworld/voice-isolator/resolve/main/docs/assets/board-light.svg" alt="Inworld VIBE full-band tier: denoising score per system" width="100%">
</picture>
</p>
Inworld VIBE (Voice Isolation Benchmark and Evals) ranks 48 kHz voice isolators on two boards.
The chart is the denoising board, which ranks every system except those that put more than 10 dB more energy above a band-limited input's band than inside it; those are ranked on restoration.
Inworld scores every system on its internal evaluation set, which is not distributed.
[How the systems are scored and what the scores mean](https://github.com/inworld-ai/voice-isolator/blob/main/bench/README.md).
## Architecture
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/inworld/voice-isolator/resolve/main/docs/assets/architecture-dark.svg">
<img src="https://huggingface.co/inworld/voice-isolator/resolve/main/docs/assets/architecture-light.svg" alt="The network: STFT, band split, seven dual-path blocks, per-band heads, iSTFT; the two checkpoints" width="100%">
</picture>
</p>
A band-split dual-path network over the STFT (n_fft 2048, hop 480 at 48 kHz, 10 ms frames).
Each frame's spectrum is cut into 46 bands, narrow at low frequency and wide at the top, one token per band and frame, width 512.
Seven blocks refine the tokens, alternating two kinds.
Four blocks run time attention with rotary position and exclusive self attention, followed by attention across bands.
Three blocks run Mamba along time, followed by Mamba across bands (state 16).
Per-band heads produce a bounded complex mask and a bounded per-bin residual, added to the input spectrum.
The offline model has 64.0M parameters.
The realtime model has 58.2M; its blocks are causal and it carries a look-ahead embedding.
Input is one channel at 48 kHz; nothing is separated or synthesized beforehand.
## Two checkpoints
The offline model, `voice-isolator-v1`, is two-sided: every frame sees its whole 8 s chunk, and long inputs render in 8 s chunks overlapping by 2 s.
The realtime model, `voice-isolator-v1-realtime`, is causal, with a trained look-ahead of 0, 20 or 40 ms; its algorithmic latency is 63 ms at 20 ms of look-ahead.
Both keep the foreground voice: when two people speak at once, the louder voice is kept and one a few dB quieter is removed, while voices at similar levels are usually both kept.
In the speech-enhancement literature, version 1 does denoising (noise suppression): it removes what surrounds the voice and restores nothing the recording lost, such as missing bandwidth; restoration comes with version 2.
## Training data
Inworld Voice Isolator v1 was trained on approximately 10,000 hours of unique audio.
Paired examples built from recorded speech: read and conversational speech in many languages, expressive and character voices, whispered speech, singing, and the speaker's own non-verbal sounds such as laughter, breaths and sighs.
The speech was mixed with environmental and household noise, traffic, rain and wind, music and crowd sound, isolated transient events and competing talkers, through measured and simulated room responses and telephony and codec degradations.
Real recordings of the same speech, captured clean and in rooms, complete the set.
The objective: return the voice as it was recorded, remove everything that is not the speaker (noise, music, other voices and the late room tail), keep the speaker's own non-verbal sounds, level and timing, and invent nothing.
Third-party datasets used in training are credited in [NOTICE](NOTICE).
## License
Code and weights are Apache-2.0 ([LICENSE](LICENSE)).
Third-party notices are in [NOTICE](NOTICE).
## How to contribute
Everyone is welcome to use the model however they like and to make it better in any way they see fit!
Development happens on GitHub: see [CONTRIBUTING.md](https://github.com/inworld-ai/voice-isolator/blob/main/CONTRIBUTING.md) for setup, tests and bug reports.
---
<p align="center">Built for people with ❤️ by Inworld.</p>