--- 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: mlx tags: - mlx - moonbox - mlx - meanvc2 - voice-conversion - zero-shot - streaming - wavlm - multilingual - apple-silicon --- # MeanVC2 MLX MLX builds of [MeanVC2](https://huggingface.co/ASLP-lab/MeanVC2), made by Moonbox for Apple Silicon Macs. Each precision is a folder; keep a folder's files together. Only the parts listed below are converted: the rest of the pipeline comes from the original repository unless the section below says otherwise. ## Files The last column is how far each build is from the original PyTorch model on the same inputs (see the section below for what was measured). | Precision | File | Size | sha256 | Checked against the original | |---|---|---|---|---| | bf16 | [`bf16/config.json`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/bf16/config.json) | 1.2 kB | `904a52da90da` | below threshold: 120ms: WER 3.16 % / CER 25.0 %, similarity 0.932 / 0.904, DNSMOS 3.36 / 3.22, RTF 0.066. 40ms: WER 5.26 % / CER 18.8 %, similarity 0.924 / 0.870, DNSMOS 3.00 / 3.12, RTF 0.12 | | bf16 | [`bf16/content.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/bf16/content.safetensors) | 35.3 MB | `be3981159455` | (the same build: numbers in its first row) | | bf16 | [`bf16/dit_120ms.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/bf16/dit_120ms.safetensors) | 35.4 MB | `b292ce1df1b6` | (the same build: numbers in its first row) | | bf16 | [`bf16/dit_40ms.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/bf16/dit_40ms.safetensors) | 35.4 MB | `834cdeaf6f92` | (the same build: numbers in its first row) | | bf16 | [`bf16/mlx_model.py`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/bf16/mlx_model.py) | 32.6 kB | `e4ccae098f02` | (the same build: numbers in its first row) | | bf16 | [`bf16/speaker.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/bf16/speaker.safetensors) | 647.8 MB | `47f663f81c5d` | (the same build: numbers in its first row) | | bf16 | [`bf16/vocoder.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/bf16/vocoder.safetensors) | 16.6 MB | `e2f0fac649e9` | (the same build: numbers in its first row) | | fp16 | [`fp16/config.json`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/fp16/config.json) | 1.2 kB | `598610b86d52` | 120ms: WER 3.16 % / CER 22.9 %, similarity 0.930 / 0.906, DNSMOS 3.33 / 3.27, RTF 0.063. 40ms: WER 4.21 % / CER 10.4 %, similarity 0.919 / 0.882, DNSMOS 3.06 / 3.08, RTF 0.12 | | fp16 | [`fp16/content.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/fp16/content.safetensors) | 35.3 MB | `97a8e12b005f` | (the same build: numbers in its first row) | | fp16 | [`fp16/dit_120ms.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/fp16/dit_120ms.safetensors) | 35.4 MB | `fcf408d57320` | (the same build: numbers in its first row) | | fp16 | [`fp16/dit_40ms.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/fp16/dit_40ms.safetensors) | 35.4 MB | `5073551645a5` | (the same build: numbers in its first row) | | fp16 | [`fp16/mlx_model.py`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/fp16/mlx_model.py) | 32.6 kB | `e4ccae098f02` | (the same build: numbers in its first row) | | fp16 | [`fp16/speaker.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/fp16/speaker.safetensors) | 647.8 MB | `dbbed5823a2e` | (the same build: numbers in its first row) | | fp16 | [`fp16/vocoder.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/fp16/vocoder.safetensors) | 16.6 MB | `a20193a7cfcb` | (the same build: numbers in its first row) | | 8bit | [`8bit/config.json`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/8bit/config.json) | 2.2 kB | `224ec74e5d78` | 120ms: WER 3.16 % / CER 22.9 %, similarity 0.929 / 0.905, DNSMOS 3.33 / 3.25, RTF 0.055. 40ms: WER 4.21 % / CER 10.4 %, similarity 0.921 / 0.881, DNSMOS 3.10 / 3.06, RTF 0.11 | | 8bit | [`8bit/content.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/8bit/content.safetensors) | 35.3 MB | `93988628c9eb` | (the same build: numbers in its first row) | | 8bit | [`8bit/dit_120ms.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/8bit/dit_120ms.safetensors) | 35.4 MB | `e640fd177010` | (the same build: numbers in its first row) | | 8bit | [`8bit/dit_40ms.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/8bit/dit_40ms.safetensors) | 35.4 MB | `6e88b899d442` | (the same build: numbers in its first row) | | 8bit | [`8bit/mlx_model.py`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/8bit/mlx_model.py) | 32.6 kB | `e4ccae098f02` | (the same build: numbers in its first row) | | 8bit | [`8bit/speaker.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/8bit/speaker.safetensors) | 364.2 MB | `22d0731bf9f6` | (the same build: numbers in its first row) | | 8bit | [`8bit/vocoder.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/8bit/vocoder.safetensors) | 16.6 MB | `de48a2e3e547` | (the same build: numbers in its first row) | | 6bit | [`6bit/config.json`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/6bit/config.json) | 2.2 kB | `662608ca8503` | 120ms: WER 3.16 % / CER 22.9 %, similarity 0.930 / 0.901, DNSMOS 3.36 / 3.25, RTF 0.057. 40ms: WER 4.21 % / CER 10.4 %, similarity 0.922 / 0.879, DNSMOS 3.08 / 3.04, RTF 0.12 | | 6bit | [`6bit/content.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/6bit/content.safetensors) | 35.3 MB | `616b834cf243` | (the same build: numbers in its first row) | | 6bit | [`6bit/dit_120ms.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/6bit/dit_120ms.safetensors) | 35.4 MB | `16bcf3e4d7a0` | (the same build: numbers in its first row) | | 6bit | [`6bit/dit_40ms.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/6bit/dit_40ms.safetensors) | 35.4 MB | `0a68bb5057a6` | (the same build: numbers in its first row) | | 6bit | [`6bit/mlx_model.py`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/6bit/mlx_model.py) | 32.6 kB | `e4ccae098f02` | (the same build: numbers in its first row) | | 6bit | [`6bit/speaker.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/6bit/speaker.safetensors) | 288.6 MB | `48c226863248` | (the same build: numbers in its first row) | | 6bit | [`6bit/vocoder.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/6bit/vocoder.safetensors) | 16.6 MB | `a79d9138715b` | (the same build: numbers in its first row) | | 4bit | [`4bit/config.json`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/4bit/config.json) | 2.2 kB | `635c2d90fad8` | below threshold (experimental): 120ms: WER 3.16 % / CER 29.2 %, similarity 0.931 / 0.904, DNSMOS 3.37 / 3.23, RTF 0.058. 40ms: WER 4.74 % / CER 18.8 %, similarity 0.923 / 0.883, DNSMOS 3.05 / 3.14, RTF 0.12 | | 4bit | [`4bit/content.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/4bit/content.safetensors) | 35.3 MB | `1d7c05a39028` | (the same build: numbers in its first row) | | 4bit | [`4bit/dit_120ms.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/4bit/dit_120ms.safetensors) | 35.4 MB | `882d39d33409` | (the same build: numbers in its first row) | | 4bit | [`4bit/dit_40ms.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/4bit/dit_40ms.safetensors) | 35.4 MB | `35a28c4a5b0d` | (the same build: numbers in its first row) | | 4bit | [`4bit/mlx_model.py`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/4bit/mlx_model.py) | 32.6 kB | `e4ccae098f02` | (the same build: numbers in its first row) | | 4bit | [`4bit/speaker.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/4bit/speaker.safetensors) | 213.0 MB | `61b612b3b862` | (the same build: numbers in its first row) | | 4bit | [`4bit/vocoder.safetensors`](https://huggingface.co/moonbox-dev/MeanVC2-MLX/blob/main/4bit/vocoder.safetensors) | 16.6 MB | `a06b4fad1328` | (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) on [MLX](https://github.com/ml-explore/mlx). Each folder is the whole pipeline for `mlx_model.py`, the one-file runtime that sits in it (mlx, numpy, soxr; no PyTorch). It reproduces the official end-to-end conversion (`src/infer/infer_e2e.py`, 3 mean-flow steps per chunk) for both 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). | File | What | |---|---| | `speaker.safetensors` | WavLM-Large + ECAPA-TDNN (Microsoft UniSpeech's speaker-verification model, the one the official code loads): reference audio -> 256-value speaker embedding. 324 M parameters, 93 % of the folder | | `content.safetensors` | FastU2++ streaming content encoder (the official `fastu2pp_160ms.pt` / `fastu2pp_80ms.pt`, which hold the same weights; the preset sets the window): 17.6 M | | `dit_120ms.safetensors`, `dit_40ms.safetensors` | the chunked mean-flow converter (DiT with global timbre memory, KV cache across chunks), one per preset: 17.7 M each | | `vocoder.safetensors` | Vocos (8 ConvNeXt blocks + ISTFT head, inverse STFT 640 / 160): 8.3 M | | `config.json`, `mlx_model.py` | precision, quantization, sources; the runtime | ```bash pip install mlx numpy soxr soundfile hf download moonbox-dev/MeanVC2-MLX --include "8bit/*" --local-dir meanvc2 python meanvc2/8bit/mlx_model.py source.wav voice.wav out.wav --preset 120ms --seed 0 ``` ```python import sys, soundfile as sf sys.path.insert(0, "meanvc2/8bit") from mlx_model import MeanVC2 vc = MeanVC2("meanvc2/8bit", preset="120ms") # or "40ms" 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) # numpy float32, 16 kHz ``` The flow's starting noise comes from numpy's generator, so a seed gives the same output every run (the same draw as the ONNX build's `pipeline.py`; not the same as PyTorch with that seed). It converts whole files; the official real-time microphone runner (`runtime/run_rt.py`) is not included, but `MeanVC2.content` / `convert` are the same streaming steps it calls. **Precision.** `fp16/` and `bf16/` (0.77 GB) hold every weight in float16 / bfloat16. `8bit/` (0.49 GB), `6bit/` (0.41 GB) and `4bit/` (0.34 GB) quantize the speaker encoder's Linear layers (WavLM-Large's attention, feed-forward and input projections; MLX affine, group size 64); everything else stays float16: the content encoder, the converter and the vocoder are 44 M parameters together, and quantizing them saved 40 MB but cost Chinese characters (6-bit: CER 33 % against the original's 23 % on the 120ms preset). The convolutions (WavLM's feature extractor and positional convolution, ECAPA, Vocos' depthwise convolutions), the ECAPA head and WavLM's 64->8 attention gates are never quantized (float16; bfloat16 in `bf16/`). **`4bit/` and `bf16/` are experimental**: they miss the Chinese error-rate mark below on both presets (`bf16/` by one character; its bfloat16 activations are less precise than float16's). Use `fp16/` for half precision. **How they were checked.** 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`, `--steps 3`) in PyTorch on the CPU in float32, 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. The Chinese set is small (about 48 characters per preset, so one character is about 2 points). Real-time factor = processing time / audio length for the whole pipeline (speaker embedding of the reference included), on an Apple M5 with 24 GB. | Build | Size (folder) | English WER | similarity | DNSMOS | Chinese CER | similarity | DNSMOS | Real-time factor | | |---|---|---|---|---|---|---|---|---|---| | 120ms original (PyTorch fp32, CPU) | - | 3.2 % | 0.929 | 3.34 | 22.9 % | 0.906 | 3.26 | 0.66 | | | 120ms `fp16/` | 0.77 GB | 3.2 % | 0.930 | 3.33 | 22.9 % | 0.906 | 3.27 | 0.063 | passes | | 120ms `8bit/` | 0.49 GB | 3.2 % | 0.929 | 3.33 | 22.9 % | 0.905 | 3.25 | 0.055 | passes | | 120ms `6bit/` | 0.41 GB | 3.2 % | 0.930 | 3.36 | 22.9 % | 0.901 | 3.25 | 0.057 | passes | | 120ms `4bit/` | 0.34 GB | 3.2 % | 0.931 | 3.37 | **29.2 %** | 0.904 | 3.23 | 0.058 | experimental | | 120ms `bf16/` | 0.77 GB | 3.2 % | 0.932 | 3.36 | **25.0 %** | 0.904 | 3.22 | 0.066 | experimental | | 40ms original (PyTorch fp32, CPU) | - | 4.2 % | 0.921 | 3.10 | 14.6 % | 0.879 | 3.09 | 1.33 | | | 40ms `fp16/` | 0.77 GB | 4.2 % | 0.919 | 3.06 | 10.4 % | 0.882 | 3.08 | 0.12 | passes | | 40ms `8bit/` | 0.49 GB | 4.2 % | 0.921 | 3.10 | 10.4 % | 0.881 | 3.06 | 0.11 | passes | | 40ms `6bit/` | 0.41 GB | 4.2 % | 0.922 | 3.08 | 10.4 % | 0.879 | 3.04 | 0.12 | passes | | 40ms `4bit/` | 0.34 GB | 4.7 % | 0.923 | 3.05 | **18.8 %** | 0.883 | 3.14 | 0.12 | experimental | | 40ms `bf16/` | 0.77 GB | 5.3 % | 0.924 | 3.00 | **18.8 %** | 0.870 | 3.12 | 0.12 | experimental | A folder holds both presets (the content encoder, vocoder and speaker encoder are shared; one converter per preset). Peak memory for a whole conversion: 1.4 GB (`fp16/`, `bf16/`), 1.06 GB (`8bit/`), 0.98 GB (`6bit/`), 0.90 GB (`4bit/`). The original's real-time factor is on the CPU, its default device. The float32 port matches the original part by part to 1e-5 (content features, speaker embedding, converter output, vocoder) and its output to 61-68 dB SNR on 3 of 4 checked clips (34 dB on the fourth, as for the ONNX build), when MLX runs exact float32 matrix products. On an M5 MLX's float32 matrix products go through the GPU's neural accelerators at reduced precision (about 1e-3 relative); each chunk's KV cache feeds the next, so these small differences, like the half-precision and quantized builds' own, grow into a different waveform with the same words and voice: outputs are not close sample by sample to the original's, and the table, not waveform SNR, is the test. **License.** MeanVC2 (the converter checkpoints, the FastU2++ content encoder and the Vocos vocoder from ASLP-lab/MeanVC2) is Apache-2.0. `speaker.safetensors` is a derivative of Microsoft UniSpeech's WavLM-Large speaker-verification checkpoint (`wavlm_large_finetune.pth`, github.com/microsoft/UniSpeech, downstreams/speaker_verification), licensed under Creative Commons Attribution-ShareAlike 3.0 Unported (`LICENSE.CC-BY-SA-3.0`): `speaker.safetensors` 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); the converter checkpoints are 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`), read with `torch.load(weights_only=True)`; it holds every WavLM and ECAPA weight. WavLM-Large's configuration is fixed in `mlx_model.py` (24 layers, 1024 wide, 16 heads, 320 relative-position buckets, gated relative position bias, layer-norm feature extractor), as in s3prl/converted_ckpts `wavlm_large.pt`, the file UniSpeech's code loads. ## How these were made From [MeanVC2](https://huggingface.co/ASLP-lab/MeanVC2) at revision `39cdd19522`: the original weights loaded in MLX and stored as bf16 or fp16, or quantized with MLX's affine quantization (`8bit`, `6bit`, `4bit`, group size 64; layers MLX can't quantize, such as convolutions and norms, stay bf16). Every build was checked against the original before upload; 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