Commit 38b352e
feat: add OpenMOSS XY-Tokenizer (16 kHz → 24 kHz neural codec)
XY-Tokenizer is a Whisper-style audio codec from OpenMOSS-Team / MOSS-TTSD.
End-to-end pipeline:
16 kHz mono PCM
→ Whisper-style mel-fbank (n_fft=400, hop=160, 80 mels, Slaney scale)
→ parallel semantic + acoustic OmniAudioEncoder (2× conv stride-2 + 12-layer
Whisper transformer with q/v/out biases, k bias-free, sinusoidal PE)
→ semantic_encoder_adapter (4-layer Whisper transformer)
→ concat[sem_adapter, acoust] (1536 ch)
→ pre_rvq_adapter (Linear 1536→768 + 4-layer transformer)
→ ResidualDownConv (conv-gated SiLU pool, avg=4) → 3072 ch
→ quantizer.input_proj (1×1 WNConv, weight-norm baked at convert)
→ 8-level Euclidean-NN Residual VQ (1024×512 codebook with pre-baked
`codebook_sq_norm` so `argmin ||z - cb[i]||^2` becomes one matmul + bias)
→ quantizer.output_proj
→ post_rvq_adapter (Linear 3072→768 + 4 layers + Linear 768→3072)
→ UpConv (ConvTranspose1d stride=4)
→ 12-layer Whisper-style mel decoder + deconv1 (s=2) + deconv2 (s=1)
→ enhanced Vocos backbone (embed conv 80→512 k=7, initial LN,
30 ConvNeXt blocks, final LN, head Linear 512→962)
→ CPU iSTFT (n_fft=960, hop=240, periodic Hann) → 24 kHz mono audio
Encoder threads `n_valid` through every transformer block to mirror HF's
`attention_mask`-based SDPA bias, and uses GELU-erf (matching `F.gelu`)
throughout — without those two pieces the encoder body diverges from HF
and codes drift. `tests/e2e/xy_tokenizer_decode_smoke.py` verifies all
three parts: cpp decode of HF codes ≥ 0.95 corr, cpp encode codes ≥ 95 %
match HF, cpp e2e ≥ 0.95 corr vs HF reconstruction. On the smoke clip:
- cpp decode(HF codes) vs HF rec: corr 0.97
- cpp encode codes vs HF codes: 100 % match
- cpp e2e vs HF e2e: corr 0.97
On a longer (3 s) clip the encoder hits 295/296 = 99.66 % code match and
the e2e hits corr 0.975 against the HF reference.
Mel-fbank is computed CPU-side (Slaney triangular filterbank, log10 +
global max-clamp + (x+4)/4 normalize, reflection-padded center-True STFT
to match HF's WhisperFeatureExtractor). Everything else runs as a single
ggml graph per public call.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7d68473 commit 38b352e
10 files changed
Lines changed: 1953 additions & 0 deletions
File tree
- include
- scripts
- converters
- src
- models
- runtime
- tests/e2e
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| 98 | + | |
| 99 | + | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
| |||
126 | 130 | | |
127 | 131 | | |
128 | 132 | | |
| 133 | + | |
| 134 | + | |
129 | 135 | | |
130 | 136 | | |
131 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
136 | 140 | | |
137 | 141 | | |
138 | 142 | | |
| |||
165 | 169 | | |
166 | 170 | | |
167 | 171 | | |
| 172 | + | |
| 173 | + | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
| |||
186 | 192 | | |
187 | 193 | | |
188 | 194 | | |
| 195 | + | |
189 | 196 | | |
190 | 197 | | |
191 | 198 | | |
| |||
0 commit comments