fix(tts/pockettts): per-language mimi encoders for non-English voice cloning (#793) - #871
Conversation
…cloning (#793) Root cause of the residual flaky/garbled non-English cloning: every pocket-tts language pack ships its OWN mimi codec weights (all 87 mimi state-dict keys differ across languages, including the 43 encoder-side keys). The shared root mimi_encoderv2 was traced from the English model, so live-clone conditioning for non-English packs was built from the wrong codec's latents. The #797 reprojection corrected the projection but not the latents — Swift conditioning differed from the reference _encode_audio output by ~140% relative, and injecting it into the PyTorch reference reproduced the exact failure signature (no-EOS runaway noise at low temperature, wrong-voice timbre), while native conditioning was 16/16 clean with the same 5s reference clip. Fix: prefer a pack-local per-language encoder (v2.1/<lang>/mimi_encoderv3.mlmodelc, that pack's mimi + speaker_proj baked in, published on FluidInference/pocket-tts-coreml) fetched lazily on first clone. Its output is already in the pack's own conditioning space, so no host-side reprojection is applied. The shared root encoder + reprojection remains the fallback (English, stale caches, offline). Swift e2e with the issue #793 reporter's reference on spanish_24l goes from 7/16 intelligible (4 pure-noise runaways at temperature 0.15) to 15/16 — on par with the PyTorch reference under the same seeds. 6-layer spanish cloning goes from always-garbled to 3/4 (upstream-level), so the 6L warn-and-steer now only fires on the fallback path. Also adds a --temperature flag to the tts CLI (PocketTTS path) to make reliability matrices reproducible.
Supertonic3 Smoke Test ✅
Runtime: 0m30s Note: CI VMs lack a physical Neural Engine; the ANE-bucketed VectorEstimator falls back to CPU here. This validates download + variant resolution + synthesis, not ANE residency/perf. |
Parakeet EOU Benchmark Results ✅Status: Benchmark passed Performance Metrics
Streaming Metrics
Test runtime: 0m55s • 08/19/2026, 03:13 PM EST RTFx = Real-Time Factor (higher is better) • Processing includes: Model inference, audio preprocessing, state management, and file I/O |
Offline VBx Pipeline ResultsSpeaker Diarization Performance (VBx Batch Mode)Optimal clustering with Hungarian algorithm for maximum accuracy
Offline VBx Pipeline Timing BreakdownTime spent in each stage of batch diarization
Speaker Diarization Research ComparisonOffline VBx achieves competitive accuracy with batch processing
Pipeline Details:
🎯 Offline VBx Test • AMI Corpus ES2004a • 1049.0s meeting audio • 134.9s processing • Test runtime: 2m 22s • 08/19/2026, 03:16 PM EST |
Sortformer High-Latency Benchmark ResultsES2004a Performance (30.4s latency config)
Sortformer High-Latency • ES2004a • Runtime: 3m 9s • 2026-08-19T19:09:33.560Z |
PocketTTS Smoke Test ✅
Runtime: 0m20s Note: PocketTTS uses CoreML MLState (macOS 15) KV cache + Mimi streaming state. CI VM lacks physical GPU — audio quality and performance may differ from Apple Silicon. |
VAD Benchmark ResultsPerformance Comparison
Dataset Details
✅: Average F1-Score above 70% |
Speaker Diarization Benchmark ResultsSpeaker Diarization PerformanceEvaluating "who spoke when" detection accuracy
Diarization Pipeline Timing BreakdownTime spent in each stage of speaker diarization
Speaker Diarization Research ComparisonResearch baselines typically achieve 18-30% DER on standard datasets
Note: RTFx shown above is from GitHub Actions runner. On Apple Silicon with ANE:
🎯 Speaker Diarization Test • AMI Corpus ES2004a • 1049.0s meeting audio • 38.2s diarization time • Test runtime: 2m 6s • 08/19/2026, 03:14 PM EST |
ASR Benchmark Results ✅Status: All benchmarks passed Parakeet v3 (multilingual)
Parakeet v2 (English-optimized)
Streaming (v3)
Streaming (v2)
Streaming tests use 5 files with 0.5s chunks to simulate real-time audio streaming 25 files per dataset • Test runtime: 12m15s • 08/19/2026, 03:18 PM EST RTFx = Real-Time Factor (higher is better) • Calculated as: Total audio duration ÷ Total processing time Expected RTFx Performance on Physical M1 Hardware:• M1 Mac: ~28x (clean), ~25x (other) Testing methodology follows HuggingFace Open ASR Leaderboard |
…tion Review fixes for ensurePackMimiEncoder: - Cache acceptance now goes through ModelCache.isCacheComplete instead of bare directory existence. An interrupted download deliberately leaves *.partial staging files for byte-range resume; accepting such a bundle failed MLModel(contentsOf:) later without ever taking the shared-encoder fallback (same class as #819). A bundle still incomplete after the resume attempt is cleared and re-downloaded once from scratch (stale staging file next to complete weights — resume can't repair it), mirroring ModelHub.loadWithRecovery semantics; verified locally by planting a weight.bin.partial: detect -> clear -> re-download -> clone proceeds pack-local, warm cache stays a no-network fast path. - Cancellation is no longer swallowed as an optional-download failure: the helper is throwing and rethrows via RetryPolicy.isCancellation, so a cancelled caller propagates instead of continuing into the fallback (or kicking off another download). Genuine availability/network failures still return nil and fall back.
Summary
Fixes the residual flaky/garbled non-English voice cloning reported in #793 (still present after #797).
Root cause
Every pocket-tts language pack ships its own mimi codec weights — all 87 mimi state-dict keys differ across languages, including all 43 encoder-side keys. The shared root
mimi_encoderv2.mlmodelcwas traced from the English model, so live-clone conditioning for non-English packs was built from the wrong codec's latents. The #797 reprojection corrected the projection, not the latents:_encode_audiooutput: ~140% relative error (mean|diff| 0.149 vs signal 0.107), uniform across frames.Fix
Prefer a pack-local per-language encoder
v2.1/<lang>/mimi_encoderv3.mlmodelc(that pack's mimi +speaker_projbaked in; published for all 9 non-English packs on FluidInference/pocket-tts-coreml), fetched lazily on first clone. Its output is already in the pack's own conditioning space → no host-side reprojection. The shared root encoder + #797 reprojection remains the fallback (English, stale caches, offline).PocketTtsResourceDownloader.ensurePackMimiEncoder— lazy, best-effort fetch; pack downloads for synthesis-only users stay lean (filter test added).PocketTtsModelStore— pack-local-first encoder load;cloneProjection()skips reprojection for the pack-local encoder; 6L warning now scoped to the fallback path.--temperatureflag on the PocketTTS path (used to reproduce the reporter's matrix).Validation (reporter's exact 5.15 s English reference, spanish_24l, 8 seeds × temp {0.15, 0.7})
Conditioning error vs PyTorch native: 140% → 0.06% relative. 6-layer spanish cloning goes from always-garbled to 3/4 intelligible (upstream-level — the earlier "6L broken upstream" verdict was an artifact of injecting English-mimi latents).
german_24lverified through the real HF lazy-download path end-to-end.Conversion script: mobius
convert_mimi_encoder_lang.py(companion PR).Fixes #793
🤖 Generated with Claude Code