This repository is a conversion of nvidia/NVIDIA-NemotronLabs-RE-USE to LiteRT, made with litert-torch 0.9.4. The original is universal speech enhancement: one 9.6M-parameter network that restores noisy, reverberant, clipped, band-limited or codec-damaged speech. The files here restore 2 s of 16 kHz audio per run; the STFT, the inverse STFT and the joining of the chunks run on the host. On a Galaxy S26 the sample app restored our 10 test clips with the main file on the GPU at 2.697 s per second of audio (measured 2026-11-03). That is slower than real time: use it on recordings, not on a live call. Loading the main file took more than a minute on each of the three phones we measured, with a peak memory of 2.94–3.74 GB in our benchmark app; the fastload file took under a minute (Limits, Load time).
Top: 5 LJ Speech sentences (public domain), each degraded by code in one way. Bottom: the same audio restored by reuse_16k_2s_fp32.tflite with the Python example below (LiteRT CPU on a Mac). Frequencies up to 8 kHz, the first 4 s of each. Degradations: reverberation (synthetic exponential room response, RT60 0.7 s), clipping (gain 4, hard clip at ±0.25), band limit (8 kHz sampling), Opus at 8 kb/s, packet loss (57 of 377 frames of 20 ms set to zero).
The original restores speech damaged by additive noise, reverberation, clipping, bandwidth limitation, codec artifacts, packet loss and low-quality mics, with one network for all of them; its card lists input rates of 8, 16, 22.05, 24, 32, 44.1 and 48 kHz. The files here run it at 16 kHz only: resample other rates to 16 kHz mono on the host first. For overlapping speech the original's card says it is "trained to preserve the main speaker while suppressing other speakers". For long recordings (over 30 s, against training clips shorter than 10 s) the same card points to chunked inference, its inference_chunk.py; the files here always work in chunks (How it works, Chunks).
| file | bytes | what |
|---|---|---|
reuse_16k_2s_fp32.tflite |
54,155,412 | main: the graph for 2 s chunks, input args_0 [1, 2, 401, 321], output output_0 [1, 3, 401, 321], 91,014 ops, float32 weights. Start with this one. |
reuse_16k_2s_fastload_fp32.tflite |
44,289,500 | fastload: the same network with the same input and output, 33,114 ops. It loads several times faster and uses less memory; on a GPU each chunk takes longer (Speed). Use it on phones with less memory (Limits). |
android/SpeechRestorer.kt, android/Spectral.kt |
4,185 and 7,916 | the Kotlin of "Use it" and the STFT and inverse STFT it calls |
LICENSE |
3,211 | the original repository's LICENSE (OpenMDW-1.1), unchanged |
NOTICE |
2,246 | where the files come from and what the conversion changed |
LICENSE.mamba_ssm.txt |
11,348 | the Apache License 2.0 of mamba_ssm (see License) |
[1, 2, frames, 321].NOTICE lists the changes). The two files differ only in the order of the time scan inside the Mamba blocks: one frame at a time in the main file, blocks of 8 frames in the fastload file. Output [1, 3, frames, 321]: a compressed magnitude m, then the phase as (x_r, x_i), the two arguments of the original's final atan2.inference.py does; the phase is (x_r, x_i) / hypot(x_r, x_i); then the inverse STFT with the same window.inference_chunk.py: each restored chunk is weighted by a Hann window (at least 1e-7), the chunks are summed, and the sum is divided by the summed windows; the last chunk ends at the end of the clip. A chunk starts every 1.75 s, so neighbours overlap by 0.25 s. The original's script uses 5 s chunks every 2.5 s.Save the block as restore.py. It reads a 16 kHz mono WAV and writes the restored audio as a 32-bit float WAV; cpu runs XNNPACK with 4 threads, gpu the LiteRT GPU accelerator (Metal on a Mac). It works with either file: the chunk length comes from the graph's input shape. The install line pins ai-edge-litert 2.3.0; the Mac rows under Speed were measured with 2.2.0.
"""NVIDIA NemotronLabs RE-USE on LiteRT: restore a 16 kHz mono wav with one fixed-chunk graph (CompiledModel API).
pip install ai-edge-litert==2.3.0 numpy soundfile
python restore.py reuse_16k_2s_fp32.tflite noisy_16k.wav restored.wav [cpu|gpu]
"""
import sys
import numpy as np
import soundfile as sf
from ai_edge_litert.compiled_model import CompiledModel, CpuOptions, HardwareAccelerator, Options
SR, N_FFT, HOP = 16000, 640, 80
WIN = (0.5 - 0.5 * np.cos(2 * np.pi * np.arange(N_FFT) / N_FFT)).astype(np.float32) # periodic Hann
def stft(x):
"""Chunk [n] -> graph input [1, 2, T, 321]: log1p|X| and angle(X) (centered, reflect padding)."""
xp = np.pad(x, N_FFT // 2, mode="reflect")
frames = np.stack([xp[i:i + N_FFT] for i in range(0, len(x) + 1, HOP)]) * WIN
spec = np.fft.rfft(frames, axis=-1)
return np.stack([np.log1p(np.abs(spec)), np.angle(spec)])[None].astype(np.float32)
def istft(y, n):
"""Graph output [1, 3, T, 321] (m, x_r, x_i) -> chunk [n]."""
m, xr, xi = y[0]
mag = np.expm1(np.maximum(m, 0))
mag[(mag == 0).mean(axis=1) > 0.5] = 0 # zero the frames with more than half of the bins at 0
h = np.hypot(xr, xi)
phase = np.where(h > 0, (xr + 1j * xi) / np.where(h > 0, h, 1), 1) # = exp(i atan2(x_i, x_r))
frames = np.fft.irfft(mag * phase, n=N_FFT, axis=-1) * WIN
out = np.zeros(N_FFT + HOP * (len(frames) - 1))
env = np.zeros_like(out)
for i, f in enumerate(frames):
out[i * HOP:i * HOP + N_FFT] += f
env[i * HOP:i * HOP + N_FFT] += WIN ** 2
s = slice(N_FFT // 2, N_FFT // 2 + n) # the centered frames cover these samples, so env > 0 here
return (out[s] / env[s]).astype(np.float32)
def restore(model_path, wav_in, wav_out, accel="cpu"):
if accel == "gpu":
options = Options(hardware_accelerators=HardwareAccelerator.GPU)
else:
options = Options(hardware_accelerators=HardwareAccelerator.CPU, cpu_options=CpuOptions(num_threads=4))
model = CompiledModel.from_file(model_path, options=options)
frames = model.get_input_tensor_details("serving_default")["args_0"]["shape"][2]
chunk = HOP * (frames - 1) # the input shape [1, 2, T, 321] fixes the chunk length
hop = chunk * 7 // 8 if chunk >= 2 * SR else chunk // 2 # 2 s chunks overlap by 1/8, shorter ones by half
inputs, outputs = model.create_input_buffers(0), model.create_output_buffers(0)
out_size = model.get_output_buffer_requirements(0, 0)["buffer_size"] // 4
x, sr = sf.read(wav_in, dtype="float32")
assert sr == SR and x.ndim == 1, "expects a 16 kHz mono wav"
n = len(x)
x = np.pad(x, (0, max(0, chunk - n))) # a clip shorter than one chunk is zero-padded
win = np.maximum(0.5 - 0.5 * np.cos(2 * np.pi * np.arange(chunk) / chunk), 1e-7).astype(np.float32)
out, wsum = np.zeros(len(x), np.float32), np.zeros(len(x), np.float32)
for s in list(range(0, len(x) - chunk, hop)) + [len(x) - chunk]: # the last chunk ends at the clip end
inputs[0].write(stft(x[s:s + chunk]))
model.run_by_index(0, inputs, outputs)
y = outputs[0].read(out_size, np.float32).reshape(1, 3, frames, -1)
out[s:s + chunk] += istft(y, chunk) * win
wsum[s:s + chunk] += win
sf.write(wav_out, (out / wsum)[:n], SR, subtype="FLOAT")
if __name__ == "__main__":
restore(*sys.argv[1:5])
We ran this block as printed on a Mac (Apple M4 Max, macOS 27.0) in a new virtual environment made with its install line (Python 3.12.12, ai-edge-litert 2.3.0). On the CPU its output was 34.42–73.96 dB SI-SDR from the PyTorch original run in the same chunks with the main file and 34.42–73.96 dB with the fastload file (10 clips each; the two files gave the same per-clip values to two decimals); with gpu, 43.85 and 44.00 dB on 1 clip.
The block is android/SpeechRestorer.kt without its package line and two marker comments, the same text as in the RE-USE sample app of LiteRT-Models, which measured the sample-app rows below. It takes the chunk length from the graph's input shape, so it runs either file: the sample app ran both on a Pixel 11 Pro (2026-11-03), and the fastload file's output was 46.73 dB SI-SDR from the main file's. android/Spectral.kt holds the STFT and the inverse STFT (double precision). Add LiteRT from Google's Maven, implementation("com.google.ai.edge.litert:litert:2.2.0"), put the .tflite in app/src/main/assets/ and keep it uncompressed: androidResources { noCompress += listOf("tflite") }.
import android.content.Context
import com.google.ai.edge.litert.CompiledModel
import com.google.ai.edge.litert.Environment
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.max
// NVIDIA NemotronLabs RE-USE speech restoration on LiteRT: one fixed-length chunk graph (CompiledModel), the STFT and
// iSTFT on the host (Spectral.kt), chunks joined by a Hann-weighted overlap-add as in NVIDIA's inference_chunk.py.
//
// Usage (16 kHz mono float PCM in, the same length out):
// val env = Environment.create()
// SpeechRestorer(context, "reuse.tflite", CompiledModel.Options(Accelerator.GPU), env).use { restorer ->
// val restored = restorer.enhance(pcm)
// }
class SpeechRestorer(
context: Context,
modelAsset: String,
options: CompiledModel.Options,
env: Environment,
hopPortion: Double? = null, // the step between chunks as a fraction of the chunk; null = the default below
) : AutoCloseable {
init {
require(hopPortion == null || (hopPortion > 0.0 && hopPortion <= 1.0)) {
"hopPortion must be in (0, 1]: $hopPortion"
}
}
private val model = CompiledModel.create(context.assets, modelAsset, options, env)
private val inputs = model.createInputBuffers()
private val outputs = model.createOutputBuffers()
// The input shape [1, 2, T, 321] fixes the chunk: T STFT frames, hop 80 samples at 16 kHz.
private val dims =
checkNotNull(model.getInputTensorType("args_0", "serving_default").layout) { "No input shape" }.dimensions
init {
require(dims.size == 4 && dims[1] == 2 && dims[3] == Spectral.BINS) { "Unexpected input shape $dims" }
}
val frames = dims[2]
val chunk = Spectral.HOP * (frames - 1)
// 2 s chunks overlap by 1/8 (hop 0.875), shorter chunks by half, unless hopPortion is given.
val hop =
when {
hopPortion != null -> (hopPortion * chunk).toInt()
chunk >= 2 * SAMPLE_RATE -> chunk * 7 / 8
else -> chunk / 2
}
private val spectral = Spectral()
private val window = FloatArray(chunk) { max(0.5 - 0.5 * cos(2.0 * PI * it / chunk), 1e-7).toFloat() }
/** Per chunk of the last enhance(), in ms: STFT, writeFloat, run, readFloat, iSTFT + overlap-add. */
val chunkTimes = ArrayList<DoubleArray>()
/** The final division by the window sum in the last enhance(), in ms. */
var finalizeMs = 0.0
fun enhance(pcm: FloatArray): FloatArray {
val x = if (pcm.size >= chunk) pcm else pcm.copyOf(chunk) // zero-pad a clip shorter than one chunk
val n = x.size
val out = FloatArray(n)
val wsum = FloatArray(n)
val spec = FloatArray(2 * frames * Spectral.BINS)
val wav = FloatArray(chunk)
chunkTimes.clear()
for (start in chunkStarts(n, chunk, hop)) {
val t0 = System.nanoTime()
spectral.analyze(x, start, chunk, spec) // [log1p|X|, angle X]
val t1 = System.nanoTime()
inputs[0].writeFloat(spec)
val t2 = System.nanoTime()
model.run(inputs, outputs) // enqueues the graph
val t3 = System.nanoTime()
val y = outputs[0].readFloat() // waits for it: [m, x_r, x_i]
val t4 = System.nanoTime()
spectral.synthesize(y, frames, wav)
for (i in 0 until chunk) {
out[start + i] += wav[i] * window[i]
wsum[start + i] += window[i]
}
val t5 = System.nanoTime()
chunkTimes.add(doubleArrayOf(ms(t0, t1), ms(t1, t2), ms(t2, t3), ms(t3, t4), ms(t4, t5)))
}
val t6 = System.nanoTime()
for (i in 0 until n) out[i] /= wsum[i]
finalizeMs = ms(t6, System.nanoTime())
return out.copyOf(pcm.size)
}
override fun close() {
inputs.forEach { it.close() }
outputs.forEach { it.close() }
model.close()
}
companion object {
const val SAMPLE_RATE = 16000
/** Chunk starts as in inference_chunk.py: every [hop] samples, the last chunk aligned to the end. */
fun chunkStarts(n: Int, chunk: Int, hop: Int): IntArray {
val count = if (n <= chunk) 1 else (n - chunk + hop - 1) / hop + 1
return IntArray(count) { i -> if (i < count - 1) i * hop else n - chunk }
}
private fun ms(from: Long, to: Long) = (to - from) / 1e6
}
}
LiteRT CompiledModel, version 2.2.0 on the phones and ai-edge-litert 2.2.0 on the Mac, on the GPU at its default precision unless the row says CPU or NPU. "Per audio second" is the time it takes to restore one second of audio: the time per chunk times 0.571 chunks per second of audio (2 in the NPU row). A value below one is faster than real time.
| device | backend | file | graph per chunk (ms) | host per chunk (ms) | per audio second (s) | load (s) |
|---|---|---|---|---|---|---|
| Galaxy S26 | GPU | main | 4,139.0 | — | 2.365 | 94.7–98.6 |
| Pixel 11 Pro | GPU | main | 6,801.5 | — | 3.887 | 102.7–140.6 |
| Pixel 8a | GPU | main | 7,967.2 | — | 4.553 | 204.4–221.9 |
| Galaxy S26 | GPU | fastload | 6,007.2 | — | 3.433 | 15.0 |
| Pixel 11 Pro | GPU | fastload | 7,866.4 | — | 4.495 | 28.2 |
| Pixel 8a | GPU | fastload | 9,823.7 | — | 5.614 | 48.2 |
| Galaxy S26 | GPU, the sample app | main | 4,225.6 | 59.17 | 2.448 | 80.0 (again: 97.5) |
| Pixel 11 Pro | GPU, the sample app | main | 6,729.4 | 116.97 | 3.912 | 73.9 (again: 160.9) |
| Galaxy S26 | NPU (Qualcomm HTP) | not provided | 71,703.3 | — | 143.4 | 4.0 |
| Mac (Apple M4 Max) | GPU (Metal) | main | 779.8 | 2.21 | 0.447 | 137.3 |
| Mac (Apple M4 Max) | CPU (XNNPACK, 4 threads) | main | 5,244.2 | 1.85 | 2.998 | 109.8 |
| Mac (Apple M4 Max) | GPU (Metal) | fastload | 871.1 | 1.88 | 0.499 | 10.0 |
| Mac (Apple M4 Max) | CPU (XNNPACK, 4 threads) | fastload | 5,109.8 | 1.88 | 2.921 | 7.3 |
CompiledModel (LiteRT reading the graph and compiling it for the GPU). The main file ran 4 chunks on the Galaxy S26, 4 on the Pixel 11 Pro and 3 on the Pixel 8a, the fastload file 1 on each; a row of several chunks shows the median (of 4, the slower of the two middle ones), except the Galaxy S26's main-file row, below. The Galaxy S26's main-file row is its first chunk, at a GPU clock cap of 1,300 MHz: the phone then lowered the cap to 1,000–1,100 MHz (thermal status MODERATE) and the other chunks took 4,223.1–4,345.7 ms (2.464 s per audio second at their median). Its fastload row ran after them, with the cap at 1,000–1,050 MHz.Deserialization failed: DATA_LOSS) and compiled the graph again.CompiledModel.10 clips (65.03 s in all): 4 from the VoiceBank-DEMAND test set, 5 LJ Speech sentences with the degradations of the image above, and the original repository's noisy_audio/mic_test2.wav, all at 16 kHz. Means of UTMOS22 and DNSMOS P.835 OVRL:
| audio | UTMOS22 | DNSMOS OVRL |
|---|---|---|
| the degraded input | 2.852 | 2.713 |
| the PyTorch original, each clip in one piece | 3.961 | 3.296 |
| main file, Mac GPU | 3.881 | 3.310 |
| fastload file, Mac GPU | 3.880 | 3.310 |
| main file, Galaxy S26 GPU (the sample app) | 3.880 | 3.308 |
| main file, Pixel 11 Pro GPU (the sample app) | 3.883 | 3.314 |
| 0.5 s chunks every 0.25 s (not provided) | 3.756 | 3.246 |
| audio.cpp, each clip in one piece (Metal) | 3.960 | 3.296 |
Our pass mark was a mean of at least 3.861 UTMOS22 and 3.213 DNSMOS OVRL: the higher of the original's mean minus 0.1 and the input's mean plus 0.5.
Against the PyTorch original run in the same chunks (SI-SDR): on the Mac's GPU, 36.12–46.95 dB for the main file and 35.55–46.95 dB for the fastload file (10 clips each).
On the phones' GPUs, per 2 s chunk, the main file was at least 33.40 dB (Galaxy S26), 30.86 dB (Pixel 11 Pro) and 32.24 dB (Pixel 8a) on 3 chunks (one each from a VoiceBank-DEMAND clip, an LJ Speech clip and mic_test2.wav), and the fastload file 39.17, 35.68 and 38.40 dB on 1 chunk of mic_test2.wav.
On the 2 s chunk of mic_test2.wav where the Mac's GPU at its default precision differed most from the same GPU in float32, the main file gave 19.90 dB on the Pixel 11 Pro's GPU, under the 20 dB we required of the GPU's default precision; float32 on the same GPU gave 103.21 dB, and the Galaxy S26's GPU 32.45 dB.
The sample app's whole-clip outputs (10 clips, main file) were at least 36.63 dB (Galaxy S26) and 32.67 dB (Pixel 11 Pro) from the Mac GPU's output of the same file.
gpu_fp32 in the sample app): on the Pixel 11 Pro that took 12,229.7 ms per chunk against 6,801.5 ms and gave 103.21 dB on that chunk.Dilated im2col buffer size overflowed (a dilated convolution whose im2col buffer would reach 1 GiB); a re-export with longer chunks has to split those convolutions too.The model files are a conversion of nvidia/NVIDIA-NemotronLabs-RE-USE and are distributed under the OpenMDW License Agreement, version 1.1, as the original is: LICENSE is the original repository's file, unchanged, with NVIDIA's copyright notice, and NOTICE records the origin (repository, revision, checksum of the weights) and what the conversion changed. The Mamba scans in the graphs follow the reference scan of mamba_ssm (state-spaces/mamba, Apache License 2.0, Copyright 2023 Tri Dao, Albert Gu; LICENSE.mamba_ssm.txt); no mamba_ssm source file is in this repository. The code on this card and in android/ is under the Apache License 2.0.
The original's papers: Rethinking Training Targets, Architectures and Data Quality for Universal Speech Enhancement (NeurIPS 2026) and One Model, Many Latencies: Universal Speech Enhancement for Diverse Real-Time Applications (IEEE SLT 2026). The original's card asks:
@article{fu2026rethinking,
title={Rethinking Training Targets, Architectures and Data Quality for Universal Speech Enhancement},
author={Fu, Szu-Wei and Chao, Rong and Yang, Xuesong and Huang, Sung-Feng and Zezario, Ryandhimas E and Nasretdinov, Rauf and Juki{\'c}, Ante and Tsao, Yu and Wang, Yu-Chiang Frank},
journal={arXiv preprint arXiv:2603.02641},
year={2026}
}
@article{fu2026one,
title={One Model, Many Latencies: Universal Speech Enhancement for Diverse Real-Time Applications},
author={Fu, Szu-Wei and Chao, Rong and Yang, Xuesong and Huang, Sung-Feng and Juki{\'c}, Ante and Tsao, Yu and Wang, Yu-Chiang Frank},
journal={arXiv preprint arXiv:2606.25621},
year={2026}
}