Instructions to use SayedShaun/resemble-enhance-litert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use SayedShaun/resemble-enhance-litert 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
Resemble Enhance LiteRT
Experimental Resemble Enhance conversion for local speech denoising and enhancement. Choose the model weight format with dtype:
| dtype | Approximate model size | Description |
|---|---|---|
"fp32" |
1.42 GB | Float32 weights. |
"fp16" |
712 MB | Float16-stored weights; default. |
"int8" |
360 MB | Experimental INT8 weights; the vocoder uses weight-only quantization. |
"mobile" |
570 MB | Recommended on phones. INT8 dynamic for the four small networks; the vocoder is re-exported for XNNPACK with float16 weights (see Mobile vocoder). |
All versions have float32 inputs and outputs. INT8 is a mixed quantization configuration, not a fully integer model; parts of the pipeline use floating-point computation.
Original model author: Resemble AI
License: MIT, copyright © 2023 Resemble AI
Python inference
Tested on Linux x86-64 with Python 3.12. Install the dependencies and download the inference class:
pip install 'huggingface_hub>=0.23,<3' ai-edge-litert==2.1.2 'numpy>=1.26,<3' 'scipy>=1.11,<2' 'soundfile>=0.12,<1'
hf download SayedShaun/resemble-enhance-litert inference.py --local-dir .
Create the class with the repository ID and enhance a file:
import soundfile as sf
from inference import ResembleEnhancer
model = ResembleEnhancer("SayedShaun/resemble-enhance-litert", dtype="int8")
audio, sample_rate = model.enhance("input.wav")
sf.write("enhanced.wav", audio, sample_rate)
The constructor downloads only the selected model files from the Hub and uses the Hugging Face cache. Set dtype="fp32", "fp16" (the default), "int8", or "mobile"; from_pretrained(repo_id, dtype=...) accepts the same option. Inference runs locally. You can also pass a mono or (frames, channels) NumPy float array with model.enhance(samples, sample_rate=16000). The returned audio is mono float32 at 44.1 kHz.
inference.py runs the neural networks using ai-edge-litert; NumPy and SciPy provide audio processing and the flow solver. PyTorch is not needed. It processes overlapping one-second windows.
Android Kotlin
Copy inference.kt into your Android project, and change its package line to match your app. Add these dependencies to the app module's build.gradle.kts:
implementation("com.google.ai.edge.litert:litert:2.3.0")
implementation("com.github.wendykierp:JTransforms:3.1")
Add internet access to AndroidManifest.xml, directly inside <manifest>:
<uses-permission android:name="android.permission.INTERNET" />
The tested project uses Kotlin 2.4.0, compile SDK 35, and minimum SDK 24. The constructor downloads the selected weights from the public Hub repository the first time and caches them in app-private storage. Downloading and inference must run on a worker thread. For example:
import android.content.Context
import android.os.Handler
import android.os.Looper
import java.util.concurrent.Executors
// samples must contain decoded mono PCM at 44,100 Hz, with values near -1..1.
// onComplete runs on the main thread.
fun enhanceSpeech(context: Context, samples: FloatArray, onComplete: (Result<FloatArray>) -> Unit) {
val appContext = context.applicationContext
val main = Handler(Looper.getMainLooper())
val worker = Executors.newSingleThreadExecutor()
worker.execute {
val result = runCatching {
ResembleEnhancer(appContext, "SayedShaun/resemble-enhance-litert", dtype = "int8").use { model ->
model.enhance(samples)
}
}
main.post { onComplete(result) }
worker.shutdown()
}
}
Use dtype = "fp32", "fp16" (default), "int8", or "mobile" (recommended on phones). Use result.onSuccess { enhanced -> /* use the mono 44.1 kHz samples */ }.onFailure { error -> /* handle the error */ } in the callback. The caller handles file decoding, resampling, playback and output encoding. You can instead load previously downloaded files with ResembleEnhancer(modelDirectory, dtype = "int8").
The source and example compile, and its DSP and solver unit tests pass. The downloader and cache were tested with INT8 files on an x86-64 Android emulator. With the "mobile" set, staged loading and an XNNPACK weight cache, an 11-second recording enhanced end to end on a 4 GB x86-64 emulator (peak anonymous memory 1.5 GB while loading the vocoder, then about 0.65 GB). FP32 and FP16 Android inference have not been tested end to end.
Mobile vocoder
models/vocoder-mobile-fp16.tflite is a re-export of the UnivNet vocoder from the original PyTorch weights (conversion/export_vocoder.py). The earlier vocoder files expressed three PyTorch constructs in ways that XNNPACK cannot run efficiently: the grouped transposed convolutions of the anti-aliased upsampling became one TRANSPOSE_CONV per channel (1,156 ops), and replicate padding and unfold became GATHER/TILE ops. The re-export replaces them with mathematically identical forms (zero-stuffing plus a depthwise convolution, edge concatenation, and one batched matrix multiply for the location-variable convolution); every replacement is checked against the PyTorch code (maximum difference below 1e-6). Inputs, outputs and the serving_default signature are unchanged.
Measured with LiteRT 2.3 and XNNPACK on one second of audio (desktop x86-64, 4 threads):
| Vocoder | File | Peak anonymous memory | Time | SNR vs PyTorch |
|---|---|---|---|---|
vocoder-int8-weights.tflite |
176 MB | 4.55 GB | 7.1 s | 20.6 dB |
vocoder-mobile-fp16.tflite |
384 MB | 1.32 GB | 2.5 s | 62.2 dB |
Full pipeline on an 11-second English recording ("mobile" small networks, matched random values), compared with the same pipeline using a float32 vocoder: vocoder-mobile-fp16.tflite 63.9 dB SNR, vocoder-int8-weights.tflite 26.3 dB.
On Android, set an XNNPACK weight cache (CompiledModel.CpuOptions(xnnPackWeightCachePath = …)) so the repacked weights live in a file-backed mapping: the full pipeline then completes on a 4 GB emulator, where the INT8 vocoder was always killed by the low-memory killer (it needed about 4.7 GB on an 8 GB phone).
Limitations
This is an experimental conversion, not an official Resemble AI release. One-second chunking can introduce artifacts. For one half-second INT8 test using identical input and random values, the Android Kotlin WAV differed from desktop Python LiteRT (RMS difference 0.0142 on a reference RMS of 0.0606); low-magnitude FFT phase differences contributed to the mismatch. In an earlier matched-noise, one-second FP16 comparison with PyTorch, 49 of 44,100 samples exceeded an atol=0.002, rtol=0.002 numerical threshold; maximum absolute difference was 0.00378.
Memory on phones. With the "int8" set, the vocoder needs about 4.7 GB while it runs: on an 8 GB Moto g96 (Android 16) Android's low-memory killer stopped it every time. Use "mobile" on phones. inference.kt keeps all five networks loaded at once for simplicity; to minimise peak memory, load each network, run it over every chunk, and close it before loading the next (as Audiops does), and run inference in a separate process so a memory kill cannot close your app.
Original model and license
The original Resemble Enhance model and code were created by Resemble AI.
- Original model: ResembleAI/resemble-enhance
- Original code: resemble-ai/resemble-enhance
- License: MIT; original copyright © 2023 Resemble AI.
This repository is an independent experimental LiteRT conversion, not an official Resemble AI release.
- Downloads last month
- 336
Model tree for SayedShaun/resemble-enhance-litert
Base model
ResembleAI/resemble-enhance