--- base_model: ASLP-lab/MeanVC2 base_model_relation: quantized license: other license_name: apache-2.0-and-cc-by-sa-3.0 license_link: https://huggingface.co/moonbox-dev/MeanVC2-ONNX/blob/main/NOTICE pipeline_tag: audio-to-audio library_name: onnx tags: - onnx - moonbox - onnxruntime - meanvc2 - voice-conversion - zero-shot - streaming - wavlm - multilingual --- # MeanVC2 ONNX ONNX builds of [MeanVC2](https://huggingface.co/ASLP-lab/MeanVC2), 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 | |---|---|---|---|---| | int8 | [`int8/content_160ms.onnx`](https://huggingface.co/moonbox-dev/MeanVC2-ONNX/blob/main/int8/content_160ms.onnx) | 75.8 MB | `b0fbc32e871e` | content fp32, rest int8. 120ms: WER 3.2 % / CER 22.9 % (original 3.2 / 22.9, CPU), similarity 0.929 / 0.914 (0.929 / 0.906), DNSMOS 3.36 / 3.26 (3.34 / 3.26), RTF 0.32 (CUDA). 40ms: WER 4.2 % / CER 10.4 % (4.2 / 10.4), similarity 0.922 / 0.886 (0.921 / 0.879), DNSMOS 3.03 / 3.06 (3.10 / 3.09), RTF 0.89 (CUDA) | | int8 | [`int8/content_80ms.onnx`](https://huggingface.co/moonbox-dev/MeanVC2-ONNX/blob/main/int8/content_80ms.onnx) | 75.8 MB | `74466705219e` | (the same build: numbers in its first row) | | int8 | [`int8/dit_120ms.onnx`](https://huggingface.co/moonbox-dev/MeanVC2-ONNX/blob/main/int8/dit_120ms.onnx) | 18.4 MB | `1d2bb292220a` | (the same build: numbers in its first row) | | int8 | [`int8/dit_40ms.onnx`](https://huggingface.co/moonbox-dev/MeanVC2-ONNX/blob/main/int8/dit_40ms.onnx) | 18.4 MB | `ae5ecb1c244f` | (the same build: numbers in its first row) | | int8 | [`int8/pipeline.py`](https://huggingface.co/moonbox-dev/MeanVC2-ONNX/blob/main/int8/pipeline.py) | 8.6 kB | `a17bfee18db7` | (the same build: numbers in its first row) | | int8 | [`int8/speaker.onnx`](https://huggingface.co/moonbox-dev/MeanVC2-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/MeanVC2-ONNX/blob/main/int8/vocoder.onnx) | 8.5 MB | `8f1153cee321` | (the same build: numbers in its first row) | ## How to run MeanVC2 (ASLP-lab: streaming zero-shot voice conversion; re-voices a recording into the voice of a few seconds of reference audio, keeping its words and timing; 16 kHz output) as six ONNX graphs plus `pipeline.py`, a numpy runtime that reproduces the official end-to-end conversion (`src/infer/infer_e2e.py`: 3 mean-flow steps per chunk) around them, for both of the official presets: `120ms` (120 ms chunks + 40 ms look-ahead, the official recommendation for quality) and `40ms` (40 ms chunks + 40 ms look-ahead, lower latency). - `content_160ms.onnx` / `content_80ms.onnx`: one streaming step of the FastU2++ content encoder (the official TorchScript `fastu2pp_160ms.pt` / `fastu2pp_80ms.pt`): 80-bin Kaldi fbank window `fbank` [1, 19, 80] ([1, 11, 80]), `offset` [] int64, `att_cache` [6, 4, 8, 128] ([6, 4, 4, 128]), `cnn_cache` [6, 1, 256, 8] -> content features `bn` [1, 4, 256] ([1, 2, 256]) and the next caches. The pipeline starts from zero caches and steps 16 (8) fbank frames at a time, as the official script does. - `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]. - `dit_120ms.onnx` / `dit_40ms.onnx`: one mean-flow step of the chunked DiT (18M parameters, with its timbre memory): `x`, `cond` [1, L, 80 / 256] (a chunk and its look-ahead frames), `t`, `r` [1], `spk` [1, 256], `offset` [] int64, `k_cache`, `v_cache` [4, 1, 2, P, 64] -> velocity `u` [1, L, 80] and the next caches [4, 1, 2, P + L - 4, 64] (the look-ahead frames are not cached). - `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 content features' 4x linear upsampling to the 100 Hz mel rate, the chunk loop with its KV cache, the three flow steps (t = 1, 2/3, 1/3, 0) and the inverse STFT. The flow'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). It converts whole files; the official real-time runner (`runtime/run_rt.py`: microphone streaming with 2 flow steps and a cross-faded chunked vocoder) is not included, but the graphs are the same step functions it calls. It needs numpy, onnxruntime (or onnxruntime-gpu), soundfile and soxr: ```bash python int8/pipeline.py source.wav voice.wav out.wav --preset 120ms --cuda --seed 0 ``` ```python import sys, soundfile as sf sys.path.insert(0, "int8") import pipeline vc = pipeline.MeanVC2("int8", "120ms", "cuda") # or "40ms"; "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=3, seed=0) # 16 kHz ``` **Precision.** `int8/` (0.55 GB): weight-only int8 (per-output-channel, behind DequantizeLinear) for the speaker encoder, both DiTs and the vocoder; the two content encoders stay fp32, because int8 content weights cost 3 characters of Chinese CER on the 120ms preset (29.2 % against the original's 22.9 %). Both presets use the same folder. No fp16 build: fp16 passes the 120ms preset (WER 3.2 % / CER 22.9 %, similarity 0.933 / 0.903, DNSMOS 3.29 / 3.29) but misses the 40ms preset's Chinese error rate by one character (12.5 % against 10.4 %, with or without fp32 content encoders). 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 per preset. 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 (MeanVC2 @13acf84, `infer_e2e.py` with `--steps 3`) on the CPU, its default 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 | |---|---|---|---|---|---|---|---| | 120ms original (PyTorch, CPU) | 3.2 % | 0.929 | 3.34 | 22.9 % | 0.906 | 3.26 | 0.79 | | 120ms `int8/` (CUDA) | 3.2 % | 0.929 | 3.36 | 22.9 % | 0.914 | 3.26 | 0.32 | | 40ms original (PyTorch, CPU) | 4.2 % | 0.921 | 3.10 | 10.4 % | 0.879 | 3.09 | 1.65 | | 40ms `int8/` (CUDA) | 4.2 % | 0.922 | 3.03 | 10.4 % | 0.886 | 3.06 | 0.89 | The Chinese set is small (two 4 s AISHELL-1 sources: 4 clips, about 48 characters, so one character is about 2 points), and the 120ms original itself loses about a fifth of the Chinese characters. The 40ms preset makes three DiT calls per 40 ms chunk: on a GPU its speed is bound by call overhead, not arithmetic. The fp32 graphs match the PyTorch modules to 1e-5 on test inputs, and on the CPU they reproduce the original's output to 66 dB SNR on average (34 dB worst clip) given the same noise. On CUDA, and in the int8 build, the outputs are not close sample by sample: each chunk's KV cache feeds the next, so small numeric differences grow into a different waveform with the same words and voice. **License.** MeanVC2 (the DiT checkpoints, the FastU2++ content encoders and the Vocos vocoder from ASLP-lab/MeanVC2) 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/MeanVC2 at revision 39cdd19 (code github.com/ASLP-lab/MeanVC2 @13acf84). `fastu2pp_*.pt` and `vocos.pt` are TorchScript archives and were read with `torch.jit.load` (there is no weights-only loader for TorchScript); every other checkpoint was read with `torch.load(weights_only=True)` or safetensors. The speaker encoder's weights are `wavlm_large_finetune.pth` from bezzam/wavlm_large_finetune_seed_tts_eval (revision f127f69, a byte-for-byte mirror of the Google Drive file that the official `initialization.py` links; sha256 `51f07e3b94d9e0262a6a675ef5a087be3dd09e8c62e9d886827f44f82fe7f94b`, 1,301,926,579 bytes; downloaded from Google Drive as well on 2026-11-30, identical bytes). It holds every WavLM and ECAPA weight; WavLM-Large's configuration was read from s3prl/converted_ckpts `wavlm_large.pt` (revision 8cad0b3, sha256 `6fb4b3c3e6aa…`, the file UniSpeech's code loads through s3prl's hub; the official `initialization.py` points at a GitHub release URL that no longer exists). ## How these were made From [MeanVC2](https://huggingface.co/ASLP-lab/MeanVC2) at revision `39cdd19522`. 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 # MeanVC2: Robust Low-Latency Streaming Zero-Shot Voice Conversion