Run this model with HF Jobs

Run moonbox-dev/MeanVC2-MLX on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/moonbox-dev/MeanVC2-MLX. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/moonbox-dev/MeanVC2-MLX on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
File size: 23,562 Bytes
7d8a6c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d9304fc
 
 
 
 
 
 
0308cd8
 
 
 
 
 
 
d2be46f
 
 
 
 
 
 
3ea4fcd
 
 
 
 
 
 
7d8a6c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
---
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

<div align="center">

[![Paper](https://img.shields.io/badge/arXiv-Paper-b31b1b.svg)](https://arxiv.org/)
[![Github](https://img.shields.io/badge/Github-ASLP--lab/MeanVC2-green)](https://github.com/ASLP-lab/MeanVC2)
[![Demo Page](https://img.shields.io/badge/Demo-Audio%20Samples-green)](https://aslp-lab.github.io/MeanVC2/)

</div>

**MeanVC2** is a robust, low-latency streaming zero-shot voice conversion (VC) system built upon the diffusion-based conditional flow matching (CFM) framework. By introducing **Future-Receptive Chunking (FRC)** and a **Universal Timbre Token Encoder (UTTE)**, MeanVC2 achieves high-fidelity voice conversion with an end-to-end pipeline latency of only **110 ms** while maintaining superior speaker similarity and audio naturalness even with a **40 ms chunk size**.

![img](https://huggingface.co/ASLP-lab/MeanVC2/resolve/main/figs/model.png)

## ✨ Key Features

- **πŸš€ Ultra-Low Latency Streaming**: 110 ms end-to-end first-packet latency with 40 ms chunk size; full pipeline RTF < 0.633 on single CPU core.
- **⚑ Single-Step Generation**: Mean flows + 1-NFE ODE solving for high-quality mel-spectrogram synthesis.
- **🎯 Zero-Shot Capability**: Convert to any unseen target speaker without re-training, robust under low-quality reference audio.
- **πŸ’Ύ Lightweight**: Only 18M parameters β€” far smaller than competing streaming VC systems.
- **πŸ”Š High Fidelity**: Future-Receptive Chunking (FRC) with Universal Timbre Token Encoder (UTTE) for pronunciation-aware timbre modeling.

## πŸ“ Model Checkpoints

This repository hosts all pretrained models for MeanVC2:

### Voice Conversion Models

| File | Description |
|------|-------------|
| `meanvc2_120ms_40ms.safetensors` | 120ms chunk + 40ms future (recommended for quality) |
| `meanvc2_40ms_40ms.safetensors` | 40ms chunk + 40ms future (lower latency) |

### Vocoder (JIT)

| File | Description |
|------|-------------|
| `vocos.pt` | Vocos JIT-traced vocoder |

### ASR Encoder (Fast-U2++ JIT)

| File | Description |
|------|-------------|
| `fastu2pp_80ms.pt` | 80ms chunk JIT model (11-frame window, stride=8) |
| `fastu2pp_160ms.pt` | 160ms chunk JIT model (19-frame window, stride=16) |

## πŸ’» Quick Start

### 1. Clone and Install

```bash
git clone https://github.com/ASLP-lab/MeanVC2.git
cd MeanVC2

conda create -n meanvc2 python=3.11 -y
conda activate meanvc2

pip install torch==2.5.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
```

### 2. Download Pretrained Models

```bash
python initialization.py --task all
```

Or download selectively:

```bash
python initialization.py --task preprocess   # BN + SpkEmb extraction only
python initialization.py --task train_120ms  # preprocess + 120ms VC + vocoder
python initialization.py --task train_40ms   # preprocess + 40ms VC + vocoder
```

### 3. End-to-End Voice Conversion

No pre-extracted features needed β€” input two wavs, output converted audio:

```bash
# 120ms+40ms model (recommended for quality)
python src/infer/infer_e2e.py \
    --source-wav /path/to/source.wav \
    --target-wav /path/to/target.wav \
    --ckpt-path ckpts/pretrained_models/meanvc2_120ms_40ms.safetensors \
    --model-config src/config/config_120ms_40ms.json \
    --vocoder-ckpt-path ckpts/vocos/vocos.pt \
    --chunk-size 12 --steps 3 \
    --output-wav output.wav

# 40ms+40ms model (lower latency)
python src/infer/infer_e2e.py \
    --source-wav /path/to/source.wav \
    --target-wav /path/to/target.wav \
    --ckpt-path ckpts/pretrained_models/meanvc2_40ms_40ms.safetensors \
    --model-config src/config/config_40ms_40ms.json \
    --vocoder-ckpt-path ckpts/vocos/vocos.pt \
    --chunk-size 4 --steps 3 \
    --output-wav output.wav
```

### 4. Real-Time Streaming

```bash
cd runtime

# File mode
python run_rt.py --mode file --input in.wav --output out.wav --model 120ms

# Microphone mode
python run_rt.py --mode realtime --model 40ms
```

## πŸ—οΈ Model Architecture

| Component | Description |
|-----------|-------------|
| **Streaming ASR Encoder** | Fast-U2++ (WeNet) extracts bottleneck features (BNFs) from source waveform |
| **Speaker Encoder** | ECAPA-TDNN + WavLM upstream extracts global speaker embedding from reference audio |
| **Universal Timbre Token Encoder (UTTE)** | Transforms speaker embedding into K key-value UTT pairs; BNFs serve as queries in cross-attention for fine-grained, pronunciation-aware timbre cues |
| **DiT-based CFM Decoder** | 4-layer DiT (hidden dim 512, 2 heads) with Future-Receptive Chunking (FRC); trained with mean flows objective for 1-NFE mel-spectrogram generation |
| **Vocoder** | Vocos converts mel-spectrograms to 16 kHz high-fidelity speech waveforms |

**Total parameters**: ~18M

## πŸ“œ License & Disclaimer

MeanVC2 is released under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0). This open-source license allows you to freely use, modify, and distribute the model, as long as you include the appropriate copyright notice and disclaimer.

MeanVC2 is designed for research and legitimate applications in voice conversion technology. Users must obtain proper consent from individuals whose voices are being converted or used as references. We strongly discourage malicious use including impersonation, fraud, or creating misleading audio content. Users are solely responsible for ensuring compliance with ethical standards and legal requirements.

## πŸ“„ Citation

If you find our work helpful, please cite:

```bibtex
@article{ma2026meanvc2,
  title={MeanVC2: Robust Low-Latency Streaming Zero-Shot Voice Conversion},
  author={Ma, Guobin and Xia, Yuxuan and Jiang, Yuepeng and Guo, Dake and Xie, Hanke and Hu, Jingbin and Wang, Yanbo and Xie, Lei and Zhu, Pengcheng},
  journal={arXiv preprint arXiv:2606.09050},
  year={2026}
}
```

## πŸ“§ Contact

For questions or collaborations, please contact: guobin.ma@mail.nwpu.edu.cn

<p align="center">
    <img src="https://huggingface.co/ASLP-lab/MeanVC2/resolve/main/figs/npu@aslp.jpeg" width="500"/>
</p>