Instructions to use litert-community/voice-isolator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/voice-isolator with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Voice Isolator for LiteRT
This repository holds the offline model (voice-isolator-v1) of Inworld's inworld/voice-isolator as two LiteRT .tflite files for the CPU, tested on three Android phones and a Mac: voice_isolator_8s_fp32.tflite (float32 weights) and voice_isolator_8s_fp16w.tflite (float16 weights). The model keeps the foreground voice of a 48 kHz recording and removes noise, music and quieter voices; two voices at similar levels are usually both kept. Each file holds the model's network as one graph, which takes the STFT of one window of up to 8 s; the publisher's Python package does the steps around it (How it works). On a Snapdragon Galaxy S26, voice_isolator_8s_fp32.tflite takes 19.0 s with 8 CPU threads for one 8 s window, 2.4 times as long as the audio. The files therefore suit recorded audio, not live calls. On a Pixel 11 Pro and a Pixel 8a the same window takes about 67 s with 8 threads. Speed still being tuned (updates follow).
On the CPU the output is close to the publisher's: on 17 clips its SI-SDR against the publisher's own output (higher is closer; our bar was 20 dB) is at least 111 dB with voice_isolator_8s_fp32.tflite and at least 78.9 dB with voice_isolator_8s_fp16w.tflite, on all three phones and on a Mac (Accuracy).
With Python, python isolate.py voice_isolator_8s_fp32.tflite recording.wav voice.wav writes the voice of recording.wav to voice.wav (we ran it on a Mac); Use it has the script and its setup. This release has no Android code: an app passes each window to the graph and does the other steps of How it works itself.
On every GPU we tried (Metal on a Mac, Adreno on the Snapdragon Galaxy S26, PowerVR on the Pixel 11 Pro) the output was NaN or wrong, so use the CPU (Notes). In the phone runs of Speed, the process that ran the graph peaked at 3.6β3.8 GB of memory, and in the Galaxy S26's run of voice_isolator_8s_fp32.tflite with 8 threads, Android's low-memory killer closed 10 background app processes. On the Pixel 8a, available memory (MemAvailable) fell to 0.76 GB in the runs of Speed and to 0.64 GB in one of the runs behind Accuracy.
Files
| file | bytes | what |
|---|---|---|
voice_isolator_8s_fp32.tflite |
272,390,120 | the graph with float32 weights |
voice_isolator_8s_fp16w.tflite |
144,698,560 | the same graph with most of its weights in float16 (127.2 MB; 1.9 MB of other constants stay float32) and 236 DEQUANTIZE operators that read them |
LICENSE |
11,358 | the publisher's LICENSE (Apache License 2.0), unchanged from inworld/voice-isolator at revision 9b0285b |
NOTICE |
904 | the publisher's NOTICE, unchanged from the same revision |
Start with voice_isolator_8s_fp32.tflite: its output is the closer of the two to the publisher's, and its median time was the lower of the two on each phone (Speed). voice_isolator_8s_fp16w.tflite is about half the size.
How it works
audio β mono, 48 kHz β 8 s windows β STFT β graph β correction β inverse STFT, added to the window's audio β crossfade of the windows β voice (48 kHz)
The script in Use it runs the graph with LiteRT and takes the other steps from the publisher's package (src/inworld/voice_isolation/ in its GitHub repository), whose code is the reference for each step.
- Audio (
load_audio,VoiceIsolator.isolate). The recording is mixed to mono and resampled to 48 kHz. - Windows (
VoiceIsolatorNetwork.enhance). A recording of up to 8 s (384,000 samples) is one window. A longer one is cut into full 8 s windows, each starting 6 s after the one before, except the last, which ends where the recording ends. Each window's output is crossfaded linearly into the next over the last 2 s of the earlier window; where the last window reaches further back, its output before that crossfade is not used. - STFT (
stft): 2,048 points, hop 480 (10 ms), periodic Hann window, centered frames, reflect padding (constant padding for 1,024 samples or fewer). An 8 s window has 801 frames of 1,025 bins. - Graph (signature
serving_default, the same in both files):- input
spectrum, float32 [1, 801, 1025, 2]: the window's STFT by frame and bin, real and imaginary parts. A window shorter than 8 s fills the first frames and leaves the rest zero. - input
valid_frames, float32 [1, 801, 1, 1]: 1 for each frame of the window, 0 for the frames after it. - output
decoder_raw, float32 [1, 1025, 801, 4]: for each bin and frame, the two components of a complex mask and the two of a complex residual.
- input
- Correction and inverse STFT (
correction,bounded_correction,istft). On the window's frames, 2Β·tanh of the output's first two components gives a complex mask, and tanh of its last two gives a complex residual, shortened to length 1 when longer and multiplied by 0.5 Γ the bin's magnitude. The correction is the spectrum times the mask plus the residual. The inverse STFT of the correction, added to the window's audio, is the window's voice.
Use it
Both steps run in one shell and one new Python 3.12 environment; step 2 also needs git and curl.
1. Download
python3.12 -m venv .venv
. .venv/bin/activate
pip install -U huggingface_hub
hf download litert-community/voice-isolator voice_isolator_8s_fp32.tflite --local-dir voice-isolator
cd voice-isolator
2. Run it (Python, CPU)
Save this as isolate.py in the voice-isolator folder:
"""Isolate the voice of a recording with a voice-isolator .tflite file on the CPU."""
import sys
import time
from ai_edge_litert.compiled_model import CompiledModel, CpuOptions, HardwareAccelerator, Options
from inworld.voice_isolation.audio import load_audio, save_audio
from inworld.voice_isolation.isolator import VoiceIsolator
from inworld.voice_isolation.model import VoiceIsolatorConfig, VoiceIsolatorNetwork
import numpy as np
import torch
FRAMES, BINS = 801, 1025 # one 8 s window at 48 kHz: STFT frames (hop 480) and bins (2,048 points)
SIGNATURE = "serving_default"
OUTPUT_SHAPE = (1, BINS, FRAMES, 4) # decoder_raw
class LiteRTWindow:
"""The graph on one window: spectrum and valid_frames in, decoder_raw out."""
def __init__(self, model):
self.model = model
self.inputs = {key: model.create_input_buffer_by_name(SIGNATURE, key) for key in ("spectrum", "valid_frames")}
self.outputs = {"decoder_raw": model.create_output_buffer_by_name(SIGNATURE, "decoder_raw")}
def __call__(self, spectrum, mask):
self.inputs["spectrum"].write(spectrum.numpy())
self.inputs["valid_frames"].write(mask.numpy())
self.model.run_by_name(SIGNATURE, self.inputs, self.outputs)
data = self.outputs["decoder_raw"].read(int(np.prod(OUTPUT_SHAPE)), np.float32)
return torch.from_numpy(data.reshape(OUTPUT_SHAPE))
class GraphHost(torch.nn.Module):
"""The publisher's window placement, STFT, correction and inverse STFT, with the graph in place of its network."""
default_window = VoiceIsolatorNetwork.default_window
enhance = VoiceIsolatorNetwork.enhance
stft = VoiceIsolatorNetwork.stft
istft = VoiceIsolatorNetwork.istft
correction = VoiceIsolatorNetwork.correction
def __init__(self, config, run_window, frames=FRAMES):
super().__init__()
self.config = config
self.frames = frames
self.run_window = run_window
self.register_buffer("window", torch.hann_window(config.n_fft), persistent=False)
def forward(self, audio):
if audio.ndim != 2 or audio.shape[0] != 1 or not audio.shape[-1] or not audio.is_floating_point():
raise ValueError("Expected nonempty floating-point mono audio [1, samples].")
spectrum = self.stft(audio)
valid = spectrum.shape[-1]
if valid > self.frames:
raise ValueError(f"The graph accepts {self.frames} frames, received {valid}.")
components = torch.zeros((1, self.frames, BINS, 2), dtype=torch.float32)
components[:, :valid] = torch.view_as_real(spectrum).transpose(1, 2)
mask = torch.zeros((1, self.frames, 1, 1), dtype=torch.float32)
mask[:, :valid] = 1
raw = self.run_window(components, mask)[:, :, :valid]
return audio + self.istft(self.correction(raw, spectrum), audio.shape[-1])
if len(sys.argv) != 4:
sys.exit("usage: python isolate.py <file.tflite> <recording> <voice.wav>")
model_file, source, destination = sys.argv[1:]
torch.set_num_threads(8)
# The offline checkpoint's config: the package's defaults with these two values.
config = VoiceIsolatorConfig.from_dict({"width": 512, "chunk_seconds": 8.0})
options = Options(hardware_accelerators=HardwareAccelerator.CPU, cpu_options=CpuOptions(num_threads=8))
with CompiledModel.from_file(model_file, options=options) as compiled:
isolator = VoiceIsolator(GraphHost(config, LiteRTWindow(compiled)), device="cpu", precision="fp32", mode="offline")
wav, rate = load_audio(source)
start = time.perf_counter()
voice = isolator.isolate(wav, rate, output_sample_rate=48000)
seconds = time.perf_counter() - start
save_audio(destination, voice, 48000, subtype="FLOAT")
print(f"{source}: {wav.numel() / rate:.1f} s of audio, isolated in {seconds:.1f} s, voice written to {destination}")
The script uses the publisher's package for the steps around the graph (it brings PyTorch) and LiteRT for the graph. The exact versions below are those used for the Mac row of Accuracy; the last two lines fetch the publisher's noisy example clip and run the script on it:
pip install ai-edge-litert==2.3.0 numpy==2.5.4 soundfile==0.14.0 torch==2.13.0 torchaudio==2.11.1 \
"inworld-voice-isolation @ git+https://github.com/inworld-ai/voice-isolator@c73b3fab81a870410cbac50d2f05f25edc4d10aa"
curl -LO https://raw.githubusercontent.com/inworld-ai/voice-isolator/c73b3fab81a870410cbac50d2f05f25edc4d10aa/demo/examples/sample_14.wav
python isolate.py voice_isolator_8s_fp32.tflite sample_14.wav sample_14_voice.wav
Run as written on 2026-11-30 on a Mac (Apple silicon, macOS 27.0), in a new Python 3.12.13 venv (step 1 installed huggingface_hub 2.5.0): it wrote sample_14_voice.wav, a 48 kHz mono float32 WAV of 516,960 samples, and its SI-SDR against the publisher's output for the clip is 126.42 dB, the value this clip has in the run behind the Mac row of Accuracy.
For a recording of yours, give its path in place of sample_14.wav: a WAV or another file that soundfile reads. The package mixes it to mono and resamples it to 48 kHz; all our test clips were 48 kHz. The voice is written as a 48 kHz float32 WAV.
Accuracy
The measure is SI-SDR (scale-invariant signal-to-distortion ratio): the energy of the part of an output that follows the publisher's output, over the energy of the rest, in dB, with no mean removed. The publisher's output is that of its package 1.0.0 (GitHub commit c73b3fa) with the offline checkpoint in float32 (PyTorch 2.13.0, 8 threads) on a Mac's CPU. The 17 clips are the 15 examples of the publisher's demo (demo/examples) and the 2 inputs of its golden test (tests/fixtures, 3 s and 11 s): 48 kHz, 3.0β24.7 s long, 27 windows in all. Before any of these numbers, we set the bar each file had to meet on each device: at least 20 dB on every clip.
Both files met the bar on the CPU of all four devices. The lowest SI-SDR of the 17 clips:
| device | voice_isolator_8s_fp32.tflite |
voice_isolator_8s_fp16w.tflite |
|---|---|---|
| Mac (Apple silicon, macOS 27.0), ai-edge-litert 2.3.0, 8 threads | 111.28 dB | 78.92 dB |
| Snapdragon Galaxy S26 | 111.24 dB | 78.92 dB |
| Pixel 11 Pro | 111.24 dB | 78.92 dB |
| Pixel 8a | 111.24 dB | 78.92 dB |
Each phone ran the graph on all 27 windows (8 CPU threads, LiteRT 2.3.0 as in Speed, 2026-11-30), from inputs made on a Mac, and the Mac did the steps after the graph on the phone's outputs. The Pixel 11 Pro and the Pixel 8a gave the same output bytes on every window.
Speed
One call of the graph on one full 8 s window, on the phone's CPU:
| phone | file | CPU threads | seconds per window | RTF | peak memory |
|---|---|---|---|---|---|
| Snapdragon Galaxy S26 | voice_isolator_8s_fp32.tflite |
8 | 19.0 | 2.38 | 3.79 GB |
| Snapdragon Galaxy S26 | voice_isolator_8s_fp32.tflite |
4 | 20.9 | 2.61 | 3.79 GB |
| Snapdragon Galaxy S26 | voice_isolator_8s_fp16w.tflite |
8 | 23.6 | 2.95 | 3.66 GB |
| Pixel 11 Pro | voice_isolator_8s_fp32.tflite |
8 | 66.7 | 8.34 | 3.74 GB |
| Pixel 11 Pro | voice_isolator_8s_fp32.tflite |
5 | 71.8 | 8.97 | 3.74 GB |
| Pixel 11 Pro | voice_isolator_8s_fp16w.tflite |
8 | 70.5 | 8.81 | 3.61 GB |
| Pixel 8a | voice_isolator_8s_fp32.tflite |
8 | 67.0 | 8.38 | 3.74 GB |
| Pixel 8a | voice_isolator_8s_fp16w.tflite |
8 | 95.5 | 11.94 | 3.61 GB |
- Seconds per window: the median of 3 calls on the same window, after 3 calls that are not counted, each call from writing the input to reading the output. The steps around the graph (STFT, correction, inverse STFT, crossfade) are not in these times.
- RTF = seconds per window Γ· 8 s, computed from the times in milliseconds; above 1 is slower than real time. After its first 8 s, a recording needs one more window for each further 6 s or part of it: the windows start 6 s apart, except the last, which ends where the recording ends.
- Peak memory: the peak resident memory (VmHWM) of the process that ran the graph, during the run (GB = kB Γ 1024 / 10βΉ).
- Each run started with the phone at thermal status 0 and no CPU clock ceiling lowered. In most readings taken during each run, at least one CPU clock ceiling was below its maximum.
- Phones: Galaxy S26 model SM-S942Q (Snapdragon, SM8850) with Android 16, Pixel 11 Pro with Android 17, Pixel 8a with Android 16. LiteRT 2.3.0 from Google Maven, called through its C API; 2026-11-30.
Notes
- GPU. At the GPU's default precision the output was all NaN or infinite, with both files, on a Mac (Metal), the Snapdragon Galaxy S26 (Adreno) and the Pixel 11 Pro (PowerVR). At float32 precision the output was finite but still wrong: on the Mac its SI-SDR against the publisher's output was β14.5 to 8.9 dB on the 17 clips, and on both phones the graph's output differed from the CPU's by as much as the output itself. The cause is not known.
- How these files were made. The offline checkpoint (
denoiser.safetensorsof inworld/voice-isolator at revision 9b0285b) was loaded with the publisher's package at GitHub commit c73b3fa. Its network was rewritten as a graph of one 8 s window, with the frames after a short window kept out of the time attention and the Mamba scans along time, so that such a window gives the publisher's single-pass result (on the 3 s input of its golden test, the rewritten network's output differed from the publisher's by at most 6.0e-08). The graph was exported with litert-torch 0.9.4 (PyTorch 2.13.0) asvoice_isolator_8s_fp32.tflite, and ai-edge-quantizer 0.10.0 cast most of its weights to float16 forvoice_isolator_8s_fp16w.tflite.
License
The files are under the Apache License 2.0, like the weights of inworld/voice-isolator they come from. The publisher's LICENSE and NOTICE are included unchanged.
- Downloads last month
- 2
Model tree for litert-community/voice-isolator
Base model
inworld/voice-isolator