Repository navigation
feat(tts): Supertonic-3 multilingual CoreML TTS — CLI, benchmark, 10-lang results - #617
Conversation
Ports the upstream Supertonic-3 TTS v1.7.3 (31 languages, 44.1 kHz, flow-matching diffusion) from ONNX to CoreML and wires it into FluidAudio as a sibling of KokoroAneManager / StyleTTS2Manager / PocketTtsSynthesizer. Components added under Sources/FluidAudio/TTS/Supertonic3/: - Supertonic3Manager: public facade, model lifecycle, lazy load - Supertonic3Synthesizer: orchestrates the 4-stage CoreML pipeline (duration_predictor -> text_encoder -> N x vector_estimator -> vocoder) - Supertonic3UnicodeProcessor: NFKD normalize + emoji strip + <lang>...</lang> wrap + 65536-entry codepoint -> token-id lookup - Supertonic3TextChunker: sentence-aware chunking (300 chars en, 120 chars ko/ja) for pseudo-streaming - Supertonic3LatentSampler: noisy-latent sampling for flow-matching - Supertonic3MultiArray: numpy-equivalent ML multi-array helpers - Supertonic3ModelStore / Supertonic3ResourceDownloader: HuggingFace asset management ModelNames.swift: new Repo.supertonic3 case + ModelNames.Supertonic3 enum listing the 4 mlmodelc bundles + tts.json + unicode_indexer.json that the downloader fetches. Models hosted at FluidInference/supertonic-3-coreml (4 .mlpackage bundles, ~380 MB total, FP32, CPU+ANE compute units, iOS 18+ deploy target). Conversion recipe + trial log live in the mobius repo at models/tts/supertonic-3/coreml/.
…c-3-coreml schema End-to-end synthesis was broken before this — three schema mismatches between the Swift port and the published HF assets prevented any prediction from succeeding: - ModelNames.Supertonic3: bundle filenames are UpperCamelCase on HF (TextEncoder.mlmodelc, DurationPredictor.mlmodelc, VectorEstimator.mlmodelc, Vocoder.mlmodelc), not snake_case. The ModelStore was searching for files that don't exist in the repo. - Supertonic3Synthesizer: vocoder output feature is named "wav", not "wav_tts". The previous lookup raised a "missing output" error every call. - Supertonic3UnicodeProcessor: the text_encoder + duration_predictor graphs pin the T axis at 128 codepoints; padding to a per-batch maxLen produced shape mismatches at predict time. Truncate or zero-pad every input row to Supertonic3Constants.textTFixed (128). Also tighten the chunker caps so a single pass actually fits inside the 128-token window after NFKD expansion + <lang> tag overhead — 110 chars for Latin scripts, 90 for CJK (was 300 / 120, which silently overflowed the encoder before reaching it).
…lang benchmark
Wires Supertonic-3 into the public CLI surface and the existing
quantitative TTS benchmark harness, and documents the backend
alongside KokoroAne / PocketTTS / Magpie / StyleTTS2.
CLI:
- TtsBackend: new `.supertonic3` case (variant of TTS backend enum).
- fluidaudiocli tts: --backend supertonic3 with --lang / --voice-style
/ --total-steps / --speed flags; runSupertonic3 mirrors the existing
per-backend runners (timing + RMS metrics + optional --output WAV).
- fluidaudiocli tts-benchmark: new Backend case + driver, --voice-style
required, --total-steps / --speed optional, language inferred from
the `minimax-<lang>` corpus or overridden via --language. Supertonic-3
is one-shot per phrase so ttft_ms == synth_ms == time-to-complete-wav.
Docs:
- Documentation/TTS/Supertonic3.md: new page mirroring the StyleTTS2 /
KokoroAne layout — overview, pipeline diagram, per-file role table,
text preprocessing rules, voice-style schema, languages, models,
known issues, license.
- Documentation/TTS/Benchmarks.md:
* Add Supertonic-3 (en, M1 voice) to the per-backend top-line
table: 100 phrases @ MiniMax-English, M2 (2022), default
compute units, Parakeet TDT roundtrip — 479 / 6491 ms p50/p95,
5.55x agg RTFx, 679 MB peak RSS, 0.84% WER, 0.32% CER.
* Add a Supertonic-3 per-language breakdown subsection covering
all 10 user-requested languages (en, ar, fr, de, it, ja, ko,
ru, es, vi). Each row is a full 100-phrase MiniMax run with
the M1 voice style; non-English rows use --skip-asr because
Parakeet is English-only. Spanish hits 354/583 ms p50/p95 and
15.90x RTFx; Korean hits 11.36x; German hits 8.75x. Peak RSS
lands at 292-486 MB for the non-en rows (English row is
inflated by Parakeet held in-process for the ASR roundtrip).
* Update the corpus → backend matrix to list Supertonic-3's 31
supported MiniMax languages (zh deliberately excluded — use
KokoroAne --variant mandarin instead).
* Reproduction snippet for `tts-benchmark --backend supertonic3`.
Cross-checked against M2 (2022) MacBook Air, 8C CPU / 8C GPU / 16C ANE,
16 GB unified memory, macOS 26 (Mac14,2, on AC), --compute-units
default. JSON reports under /tmp/sup3_bench*.json and
/tmp/sup3_bench_results/<lang>.json.
Parakeet EOU Benchmark Results ✅Status: Benchmark passed Performance Metrics
Streaming Metrics
Test runtime: 1m6s • 05/17/2026, 02:19 AM 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 • 131.0s processing • Test runtime: 2m 17s • 05/17/2026, 02:26 AM EST |
PocketTTS Smoke Test ✅
Runtime: 0m22s 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. |
Qwen3-ASR int8 Smoke Test ✅
Performance Metrics
Runtime: 5m59s Note: CI VM lacks physical GPU — CoreML MLState (macOS 15) KV cache produces degraded results on virtualized runners. On Apple Silicon: ~1.3% WER / 2.5x RTFx. |
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: 5m57s • 05/17/2026, 02:24 AM 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 |
VAD Benchmark ResultsPerformance Comparison
Dataset Details
✅: Average F1-Score above 70% |
Sortformer High-Latency Benchmark ResultsES2004a Performance (30.4s latency config)
Sortformer High-Latency • ES2004a • Runtime: 2m 16s • 2026-05-17T06:29:37.393Z |
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 • 51.6s diarization time • Test runtime: 2m 28s • 05/17/2026, 02:30 AM EST |
| /// style: style) | ||
| /// // `audio.samples` is 44.1 kHz mono Float32 PCM. | ||
| /// ``` | ||
| public actor Supertonic3Manager { |
There was a problem hiding this comment.
🔴 No unit tests added for any Supertonic-3 code, violating AGENTS.md rule
AGENTS.md mandates "Add unit tests when writing new code." This PR adds 10+ new source files (Supertonic3Manager, Supertonic3Synthesizer, Supertonic3TextChunker, Supertonic3UnicodeProcessor, Supertonic3LatentSampler, Supertonic3MultiArray, Supertonic3ModelStore, Supertonic3ResourceDownloader, Supertonic3Types, Supertonic3Constants, Supertonic3Error) with zero accompanying tests. Every other TTS backend in the repo has test coverage — StyleTTS2 has 5 test files (Tests/FluidAudioTests/TTS/StyleTTS2/), Magpie has 6, PocketTTS has 6. The new Supertonic-3 code has pure-function components (text chunker, unicode preprocessor, latent sampler, multi-array helpers) that are straightforwardly unit-testable without requiring model downloads.
Prompt for agents
AGENTS.md requires "Add unit tests when writing new code." Add test files under Tests/FluidAudioTests/TTS/Supertonic3/ covering at least the pure-function components that do not require CoreML model downloads:
1. Supertonic3TextChunkerTests — test paragraph/sentence/comma/word splitting, abbreviation awareness, edge cases (empty input, single-word, maxLen boundary).
2. Supertonic3UnicodeProcessorTests — test preprocess() for emoji stripping, symbol replacement, period appending, lang tag wrapping. The encode() path needs an indexer JSON, but preprocess() and mask() are static/pure.
3. Supertonic3LatentSamplerTests — test sampleNoisyLatent with a seeded RNG closure, verify mask shapes, verify zero-padding of noisy latent beyond valid length.
4. Supertonic3MultiArrayTests — test makeFloat32/makeInt32/extractFloats round-trip.
5. Supertonic3TypesTests — test Supertonic3Config.defaults, Supertonic3VoiceStyleData decoding from a minimal JSON fixture, flatten() correctness.
Follow the existing test patterns in Tests/FluidAudioTests/TTS/StyleTTS2/ and Tests/FluidAudioTests/TTS/Magpie/.
Was this helpful? React with 👍 or 👎 to provide feedback.
| /// cap is 300 characters for Latin-script input and 120 characters for CJK | ||
| /// (Korean / Japanese), matching what the upstream Swift CLI ships. |
There was a problem hiding this comment.
🟡 Doc comment claims 300/120-char chunk caps but code uses 110/90
The Supertonic3TextChunker doc comment at line 9 states "The default cap is 300 characters for Latin-script input and 120 characters for CJK" but the actual constants consumed by the synthesizer are Supertonic3Constants.maxChunkLengthLatin = 110 (Supertonic3Constants.swift:80) and Supertonic3Constants.maxChunkLengthCJK = 90 (Supertonic3Constants.swift:85). A developer reading the chunker doc would believe inputs up to 300 chars pass through un-chunked, when in reality anything over 110 (Latin) or 90 (CJK) is split.
| /// cap is 300 characters for Latin-script input and 120 characters for CJK | |
| /// (Korean / Japanese), matching what the upstream Swift CLI ships. | |
| /// so individual chunks never exceed the configured `maxLen`. The default | |
| /// cap is 110 characters for Latin-script input and 90 characters for CJK | |
| /// (Korean / Japanese), matching the constants in `Supertonic3Constants`. |
Was this helpful? React with 👍 or 👎 to provide feedback.
| "ru", "sk", "sl", "sv", "tr", "uk", "vi", "na", | ||
| ] | ||
|
|
||
| /// Languages that should use the tighter 120-char chunker. |
There was a problem hiding this comment.
🟡 Doc comment on cjkLanguages says '120-char' but actual CJK chunk cap is 90
The comment on cjkLanguages says "Languages that should use the tighter 120-char chunker" but the actual constant maxChunkLengthCJK defined 11 lines above is 90, not 120. This misleads anyone reading the constant's intent.
| /// Languages that should use the tighter 120-char chunker. | |
| /// Languages that should use the tighter 90-char chunker. |
Was this helpful? React with 👍 or 👎 to provide feedback.
…arge-v3-turbo Re-synthesized the 9 non-English `minimax-<lang>` corpora with --audio-dir so the WAVs persist, then transcribed each phrase offline with `mlx-community/whisper-large-v3-turbo` and computed WER / CER against the reference text with `jiwer` (NFKC + lowercase + punctuation-strip normalization). Results (100 phrases per language): ar 3.81% WER / 1.16% CER fr 3.32% WER / 1.13% CER de 0.66% WER / 0.45% CER <- best it 0.64% WER / 0.29% CER <- best ja 98.3% WER / 9.30% CER (WER meaningless on whitespace-free script) ko 11.5% WER / 4.23% CER ru 4.06% WER / 1.30% CER es 1.28% WER / 0.57% CER vi 9.60% WER / 8.33% CER European languages (de, it, es) hit < 1.5% WER. Korean & Vietnamese sit in the 10% range. Japanese WER is reported as 98% because jiwer.wer splits on whitespace and the script has none — the 9.3% CER is the right metric there. This is the same pattern the existing harness uses for English (in-process Parakeet TDT), just done with an external mlx-whisper script because the harness's ASR fallback is currently English-only.
|
@claude review |
|
Claude finished @Alex-Wengg's task in 3m 22s —— View job PR #617 Review — Supertonic-3 Multilingual TTS
SummarySolid landing of the Supertonic-3 pipeline. The actor-based concurrency model is correct, there are no Issues🔴 No unit tests (CLAUDE.md violation)Zero test files under
🟡 Stale doc comment in
|
Tests (Tests/FluidAudioTests/TTS/Supertonic3/):
- Supertonic3TextChunkerTests: empty / boundary / sentence packing /
abbreviation awareness / comma + word fallback / paragraph split.
- Supertonic3UnicodeProcessorTests: lang-tag wrap, period append,
emoji strip, smart-quote / dash replacement, abbreviation expand,
decorative symbol drop, whitespace collapse, mask shape.
- Supertonic3LatentSamplerTests: mask shape, dim math, deterministic
output from seeded RNG, padding-zero invariant, empty-batch.
- Supertonic3MultiArrayTests: Float32 / Int32 round-trip, extractFloats
across Float32 / Int32 / Double (Float16 on arm64), and the new
shape-mismatch throw paths.
- Supertonic3TypesTests: Config.defaults + JSON decode, VoiceStyle.load
round-trip (full 50x256 / 8x16 fixture), shape-mismatch rejection,
cjkLanguages ⊂ availableLanguages, maxChunkLengthCJK < Latin.
Source fixes (all flagged by Devin + Claude review on PR #617):
- Supertonic3TextChunker: doc said "300 Latin / 120 CJK" but
actual caps are 110 / 90 (from Supertonic3Constants).
- Supertonic3Constants.cjkLanguages: doc said "120-char chunker",
actual is 90 (maxChunkLengthCJK).
- Supertonic3Synthesizer: doc said "vocoder(latent) → wav_tts" but
the schema fix in 55fe56d switched the output key to "wav".
- Supertonic3VoiceStyle.load(): now validates style_ttl dims against
[1, ttlStyleTokens, ttlStyleDim] and style_dp against
[1, dpStyleTokens, dpStyleDim], throwing
voiceStyleShapeMismatch instead of letting the bad shape fall
through to a MultiArray precondition crash.
- Supertonic3MultiArray.makeFloat32 / makeInt32: replace `precondition`
with a throwing `guard` that surfaces invalidTensorShape, so the
synthesizer's existing do/catch can report the failure instead of
crashing the process.
- TTSCommand: rename `styletts2CpuOnly` → `cpuOnly`. The flag was
already shared across StyleTTS2 / PocketTTS / Supertonic-3 driven
by `--cpu-only`; the StyleTTS2 prefix made the Supertonic-3 branch
read wrong.
…lang results (FluidInference#617) Lands [supertone-inc/supertonic](https://github.com/supertone-inc/supertonic) v1.7.3 in FluidAudio as a 4-stage CoreML pipeline (TextEncoder → DurationPredictor → VectorEstimator ×8 denoising → Vocoder, 44.1 kHz Float32 mono, 31 ISO codes, voice styling via per-speaker JSON tensors). 1. **Schema fixes** to align the Swift port with the published [`FluidInference/supertonic-3-coreml`](https://huggingface.co/FluidInference/supertonic-3-coreml) bundle — mlmodelc filename casing (UpperCamelCase), vocoder output key (`wav`, not `wav_tts`), `text_ids`/`text_mask` padding to fixed T=128, chunker caps (110 char Latin / 90 CJK to fit inside the 128-token window). 2. **`fluidaudiocli tts --backend supertonic3`** end-to-end command with `--voice-style`, `--total-steps`, `--speed` flags. 3. **`fluidaudiocli tts-benchmark --backend supertonic3`** wired into the shared harness — emits TTFT p50/p95, agg RTFx, peak RSS, WER, CER, JSON report. 4. **`Documentation/TTS/Supertonic3.md`** doc page mirroring the StyleTTS2 page layout. 5. **`Documentation/TTS/Benchmarks.md`** updated with the per-backend top-line row + a new per-language breakdown subsection (10 languages on MiniMax-100, full WER/CER for all 10). | Backend | TTFT p50 / p95 | Agg RTFx | Peak RSS | WER | CER | |---|---|---|---|---|---| | Supertonic-3 (M1 voice) | **479 / 6491 ms** | **5.55×** | 679 MB | **0.84%** | **0.32%** | WER / CER on non-English rows is scored offline against the saved WAVs with `mlx-community/whisper-large-v3-turbo` + `jiwer` (NFKC + lowercase + punctuation-strip), since the in-harness Parakeet TDT roundtrip is English-only. | Lang | Synth p50 / p95 | RTFx | Peak RSS | WER | CER | |---|---|---|---|---|---| | en | 479 / 6491 ms | 5.55× | 679 MB‡ | 0.84% | 0.32% | | ar | 427 / 5827 ms | 6.76× | 396 MB | 3.81% | 1.16% | | fr | 926 / 5897 ms | 5.58× | 292 MB | 3.32% | 1.13% | | de | 313 / 2318 ms | 8.75× | 345 MB | **0.66%** | **0.45%** | | it | 691 / 4626 ms | 11.05× | 486 MB | **0.64%** | **0.29%** | | ja | 643 / 2058 ms | 8.69× | 329 MB | 98.3%§ | 9.30% | | ko | 438 / 1599 ms | 11.36× | 370 MB | 11.5%§ | 4.23% | | ru | 321 / 6563 ms | 7.97× | 356 MB | 4.06% | 1.30% | | es | 354 / 583 ms | **15.90×** | 351 MB | 1.28% | 0.57% | | vi | 776 / 3934 ms | 7.02× | 440 MB | 9.60% | 8.33% | ‡ English RSS is higher because the in-process Parakeet TDT is loaded for the WER/CER roundtrip; non-English runs use `--skip-asr` so RSS reflects only the four Supertonic-3 graphs + indexer. § Japanese / Korean have no whitespace word boundaries, so `jiwer.wer` (whitespace-split) gives a misleading WER — the **CER** is the right metric for those rows.
Summary
Lands supertone-inc/supertonic v1.7.3 in FluidAudio as a 4-stage CoreML pipeline (TextEncoder → DurationPredictor → VectorEstimator ×8 denoising → Vocoder, 44.1 kHz Float32 mono, 31 ISO codes, voice styling via per-speaker JSON tensors).
FluidInference/supertonic-3-coremlbundle — mlmodelc filename casing (UpperCamelCase), vocoder output key (wav, notwav_tts),text_ids/text_maskpadding to fixed T=128, chunker caps (110 char Latin / 90 CJK to fit inside the 128-token window).fluidaudiocli tts --backend supertonic3end-to-end command with--voice-style,--total-steps,--speedflags.fluidaudiocli tts-benchmark --backend supertonic3wired into the shared harness — emits TTFT p50/p95, agg RTFx, peak RSS, WER, CER, JSON report.Documentation/TTS/Supertonic3.mddoc page mirroring the StyleTTS2 page layout.Documentation/TTS/Benchmarks.mdupdated with the per-backend top-line row + a new per-language breakdown subsection (10 languages on MiniMax-100, full WER/CER for all 10).Per-backend top-line (MiniMax English, M2 Air, ANE)
10-language MiniMax breakdown (ANE, 100 phrases each)
WER / CER on non-English rows is scored offline against the saved WAVs with
mlx-community/whisper-large-v3-turbo+jiwer(NFKC + lowercase + punctuation-strip), since the in-harness Parakeet TDT roundtrip is English-only.‡ English RSS is higher because the in-process Parakeet TDT is loaded for the WER/CER roundtrip; non-English runs use
--skip-asrso RSS reflects only the four Supertonic-3 graphs + indexer.§ Japanese / Korean have no whitespace word boundaries, so
jiwer.wer(whitespace-split) gives a misleading WER — the CER is the right metric for those rows.