--- base_model: ASLP-lab/MeanVC base_model_relation: quantized license: other license_name: apache-2.0-and-cc-by-sa-3.0 license_link: https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/NOTICE pipeline_tag: audio-to-audio library_name: onnx tags: - onnx - moonbox - onnxruntime - meanvc - voice-conversion - zero-shot - streaming - wavlm - multilingual --- # MeanVC ONNX ONNX builds of [MeanVC](https://huggingface.co/ASLP-lab/MeanVC), made by Moonbox for on-device use with ONNX Runtime (CPU, CUDA, DirectML). Each precision is one folder holding the graphs and a small Python `pipeline.py` that does the rest (features, resampling, the conversion steps); what the graphs take and return is under *How to run*. ## Files The last column is the benchmark on Moonbox's voice-conversion set (English LibriSpeech and Chinese AISHELL-1 recordings, each converted into an English and a Chinese target voice; details under *How to run*): error rate of a Whisper transcript of the output against the source's transcript, speaker similarity to the target voice and DNSMOS, against the original PyTorch model. | Precision | File | Size | sha256 | Benchmark | |---|---|---|---|---| | fp16 | [`fp16/content.onnx`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/fp16/content.onnx) | 43.2 MB | `d291e11b3eee` | WER 13.7 % / CER 6.3 % (original 14.2 / 8.3, CPU), similarity 0.749 / 0.700 (0.757 / 0.704), DNSMOS 3.19 / 3.21 (3.17 / 3.14); RTF 0.18 (CUDA) | | fp16 | [`fp16/dit.onnx`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/fp16/dit.onnx) | 28.6 MB | `4c5cad95f449` | (the same build: numbers in its first row) | | fp16 | [`fp16/mel_basis.npy`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/fp16/mel_basis.npy) | 0.2 MB | `50f72dcd637c` | (the same build: numbers in its first row) | | fp16 | [`fp16/pipeline.py`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/fp16/pipeline.py) | 9.0 kB | `d7615e80b1e2` | (the same build: numbers in its first row) | | fp16 | [`fp16/speaker.onnx`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/fp16/speaker.onnx) | 648.9 MB | `7e7f09d71188` | (the same build: numbers in its first row) | | fp16 | [`fp16/vocoder.onnx`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/fp16/vocoder.onnx) | 16.6 MB | `72d4def75902` | (the same build: numbers in its first row) | | int8 | [`int8/content.onnx`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/int8/content.onnx) | 26.0 MB | `cc73300066f3` | WER 13.2 % / CER 6.3 %, similarity 0.752 / 0.707, DNSMOS 3.11 / 3.20; RTF 0.17 (CUDA) | | int8 | [`int8/dit.onnx`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/int8/dit.onnx) | 14.7 MB | `15f2c6c1fba1` | (the same build: numbers in its first row) | | int8 | [`int8/mel_basis.npy`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/int8/mel_basis.npy) | 0.2 MB | `50f72dcd637c` | (the same build: numbers in its first row) | | int8 | [`int8/pipeline.py`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/int8/pipeline.py) | 9.0 kB | `d7615e80b1e2` | (the same build: numbers in its first row) | | int8 | [`int8/speaker.onnx`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/int8/speaker.onnx) | 352.6 MB | `24764e4095c9` | (the same build: numbers in its first row) | | int8 | [`int8/vocoder.onnx`](https://huggingface.co/moonbox-dev/MeanVC-ONNX/blob/main/int8/vocoder.onnx) | 8.5 MB | `8f1153cee321` | (the same build: numbers in its first row) | ## How to run MeanVC (ASLP-lab: lightweight streaming zero-shot voice conversion with mean flows; re-voices a recording into the voice of a few seconds of reference audio, keeping its words and timing; 16 kHz output) as four ONNX graphs plus `pipeline.py`, a numpy runtime that reproduces the official offline conversion (`src/infer/infer_ref.py` as `scripts/infer_ref.sh` runs it: the 200 ms model, 20-frame chunks, 2 mean-flow steps) around them. Its successor is MeanVC2 (moonbox-dev/MeanVC2-ONNX). - `content.onnx`: one streaming step of the FastU2++ content encoder (the official TorchScript `fastu2++.pt`, a wenet Conformer with 7 layers; rebuilt as plain modules for the export, since its scripted `forward_encoder_chunk` does not export): 80-bin Kaldi fbank window `fbank` [1, W, 80] (23 frames, the last one shorter), `offset` [] int64, `att_cache` [7, 4, C, 128] (C = 0 on the first step, then up to 10), `cnn_cache` [7, 1, 256, 8] -> content features `bn` [1, (W - 3) / 4, 256] and the next caches. - `speaker.onnx`: WavLM-Large + ECAPA-TDNN (Microsoft UniSpeech's speaker-verification model, the one the official code loads): 16 kHz `wave` [1, N] -> speaker embedding `emb` [1, 256]. The same graph as MeanVC2's. - `dit.onnx`: one mean-flow step of the chunked DiT (with its timbre encoder over the reference mel): `x`, `cond` [1, n, 80 / 256] (a 20-frame chunk), `t`, `r` [1], `cache` [1, m, 80] (the previous chunk's output; m = 0 first), `spk` [1, 256], `prompt` [1, NT, 80] (the reference's mel spectrogram), `offset` [] int64, `k_cache`, `v_cache` [4, 1, 2, P, 64] -> velocity `u` [1, n, 80] and the next caches [4, 1, 2, P + m, 64]; the pipeline keeps the last 100 frames, as the official script does. - `vocoder.onnx`: Vocos (the official TorchScript `vocos.pt`) up to the spectrum: mel `mel` [1, 80, T] -> `real`, `imag` [1, 321, T]; the inverse STFT (640-point, hop 160) runs in numpy. `pipeline.py` does the rest in numpy: resampling to 16 kHz (soxr), the Kaldi fbank, the reference's mel spectrogram (`mel_basis.npy`), the content features' 4x linear upsampling to the 100 Hz mel rate, the chunk loop with its caches, the two flow steps (t = 1, 0.8, 0) and the inverse STFT. Each chunk's starting noise comes from numpy's generator, so a seed gives the same output every run here (not the same as PyTorch with that seed). The official real-time runner (`src/runtime/run_rt.py`, microphone streaming) is not included. It needs numpy, onnxruntime (or onnxruntime-gpu), soundfile and soxr: ```bash python int8/pipeline.py source.wav voice.wav out.wav --cuda --seed 0 ``` ```python import sys, soundfile as sf sys.path.insert(0, "int8") import pipeline vc = pipeline.MeanVC("int8", "cuda") # or "cpu" src, sr = sf.read("source.wav", dtype="float32") ref, ref_sr = sf.read("voice.wav", dtype="float32") wav, out_sr = vc(src, sr, ref, ref_sr, steps=2, seed=0) # 16 kHz ``` **Precisions.** `fp16/` (0.74 GB): every graph fp16 math with fp32 inputs and outputs. `int8/` (0.40 GB): weight-only int8 (per-output-channel, behind DequantizeLinear) for every graph. Both pass the benchmark below. No int4 or bf16 build. **Benchmark.** The lab's voice-conversion set: 4 English recordings (LibriSpeech test-clean) and 2 Chinese ones (AISHELL-1 test), each converted into the English (LibriSpeech) and the Chinese (AISHELL-1) voice of the lab's TTS prompts: 12 conversions. Each output is judged by Whisper large-v3-turbo's WER (English sources) or CER (Chinese) against the source's transcript, WavLM-base-plus-sv speaker similarity to the target voice, and DNSMOS (P.835 overall). The original is the official code (MeanVC @fe5286a, `infer_ref.py` with the 200 ms model, `--chunk-size 20 --steps 2`) on the CPU, its only device, given the same starting noise. Pass, per source language: error rate at most 2 points above the original's, similarity at most 0.03 below, DNSMOS at most 0.2 below. Real-time factor (processing time / audio time) of the whole pipeline on an RTX 3080 Laptop GPU (the original: on the CPU). | | English WER | similarity | DNSMOS | Chinese CER | similarity | DNSMOS | Real-time factor | |---|---|---|---|---|---|---|---| | original (PyTorch, CPU) | 14.2 % | 0.757 | 3.17 | 8.3 % | 0.704 | 3.14 | 0.40 | | `fp16/` (CUDA) | 13.7 % | 0.749 | 3.19 | 6.3 % | 0.700 | 3.21 | 0.18 | | `int8/` (CUDA) | 13.2 % | 0.752 | 3.11 | 6.3 % | 0.707 | 3.20 | 0.17 | The original itself loses words on this set (English WER 14 %) and its speaker similarity is well below MeanVC2's (0.93 / 0.91 on the same set): MeanVC2 is the better model. The Chinese set is small (two 4 s AISHELL-1 sources: 4 clips, about 48 characters, so one character is about 2 points). The graphs match the PyTorch modules to 1e-5 (the content encoder step by step through a real recording, against the official scripted encoder), and the fp32 graphs reproduce the original's output to 19 dB SNR on average on CUDA given the same noise; in the fp16 and int8 builds the outputs are not close sample by sample: each chunk's output and KV cache feed the next, so small numeric differences grow into a different waveform with the same words and voice. **License.** MeanVC (the DiT checkpoint, the FastU2++ content encoder and the Vocos vocoder from ASLP-lab/MeanVC, code github.com/ASLP-lab/MeanVC) is Apache-2.0. `speaker.onnx` is a derivative of Microsoft UniSpeech's WavLM-Large speaker-verification checkpoint (`wavlm_large_finetune.pth`, github.com/microsoft/UniSpeech, downstreams/speaker_verification), which is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported (`LICENSE.CC-BY-SA-3.0`): `speaker.onnx` is distributed under CC BY-SA 3.0, so adaptations of it must carry the same licence and credit Microsoft. Its WavLM-Large backbone comes from Microsoft's WavLM (github.com/microsoft/unilm, MIT, `LICENSE.MIT-WavLM`). `NOTICE` lists the changes. The original authors ask that voices be converted only with the consent of the people whose voices are used, and not for impersonation, fraud or misleading audio. **Sources.** ASLP-lab/MeanVC at revision 2e2a116 (`model_200ms.safetensors`, read with safetensors; code github.com/ASLP-lab/MeanVC @fe5286a). `fastu2++.pt` and `vocos.pt` are TorchScript archives and were read with `torch.jit.load` (there is no weights-only loader for TorchScript). The speaker encoder's weights are `wavlm_large_finetune.pth`, the Google Drive file the official README links (id 1-aE1NfzpRCLxA4GUxX9ITI3F9LlbtEGP, sha256 `51f07e3b94d9e0262a6a675ef5a087be3dd09e8c62e9d886827f44f82fe7f94b`, 1,301,926,579 bytes; the same bytes as its Hub mirror bezzam/wavlm_large_finetune_seed_tts_eval), read with `torch.load(weights_only=True)`. It holds every WavLM and ECAPA weight; WavLM-Large's configuration was read from s3prl/converted_ckpts `wavlm_large.pt` (revision 8cad0b3, the file the official code's `torch.hub.load('s3prl/s3prl', 'wavlm_large')` downloads; the hub call itself was not run, s3prl's packaged loader read the file with `weights_only=True`). ## How these were made From [MeanVC](https://huggingface.co/ASLP-lab/MeanVC) at revision `2e2a116d1b`. The graphs were exported from the original PyTorch modules with torch.onnx (opset 17 / 18) and checked against them. Weight-only quantization: int8 is a per-output-channel int8 weight behind DequantizeLinear, int4 is ONNX Runtime's MatMulNBits (block 32). Each card above says which precision every graph uses. Every precision was benchmarked against the original before upload (pass, per language: error rate at most 2 points above the original's, similarity to the target voice at most 0.03 below, DNSMOS at most 0.2 below), and 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 # MeanVC: Lightweight and Streaming Zero-Shot Voice Conversion via Mean Flows