Skip to content

feat(tts): Supertonic-3 multilingual CoreML TTS — CLI, benchmark, 10-lang results - #617

Merged
Alex-Wengg merged 5 commits into
mainfrom
feat/tts-supertonic3
May 17, 2026
Merged

Alex-Wengg merged 5 commits into
mainfrom
feat/tts-supertonic3

Conversation

@Alex-Wengg

@Alex-Wengg Alex-Wengg commented May 17, 2026 •

Copy link
Copy Markdown
Member

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).

  1. Schema fixes to align the Swift port with the published 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).

Per-backend top-line (MiniMax English, M2 Air, ANE)

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%

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.

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.

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.
@github-actions

github-actions Bot commented May 17, 2026 •

Copy link
Copy Markdown

Parakeet EOU Benchmark Results ✅

Status: Benchmark passed
Chunk Size: 320ms
Files Tested: 100/100

Performance Metrics

Metric Value Description
WER (Avg) 7.03% Average Word Error Rate
WER (Med) 4.17% Median Word Error Rate
RTFx 8.23x Real-time factor (higher = faster)
Total Audio 470.6s Total audio duration processed
Total Time 58.7s Total processing time

Streaming Metrics

Metric Value Description
Avg Chunk Time 0.059s Average chunk processing time
Max Chunk Time 0.117s Maximum chunk processing time
EOU Detections 0 Total End-of-Utterance detections

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

@github-actions

github-actions Bot commented May 17, 2026 •

Copy link
Copy Markdown

Offline VBx Pipeline Results

Speaker Diarization Performance (VBx Batch Mode)

Optimal clustering with Hungarian algorithm for maximum accuracy

Metric Value Target Status Description
DER 10.4% <20% ✅ Diarization Error Rate (lower is better)
RTFx 9.83x >1.0x ✅ Real-Time Factor (higher is faster)

Offline VBx Pipeline Timing Breakdown

Time spent in each stage of batch diarization

Stage Time (s) % Description
Model Download 14.968 14.0 Fetching diarization models
Model Compile 6.415 6.0 CoreML compilation
Audio Load 0.087 0.1 Loading audio file
Segmentation 24.513 23.0 VAD + speech detection
Embedding 106.364 99.6 Speaker embedding extraction
Clustering (VBx) 0.136 0.1 Hungarian algorithm + VBx clustering
Total 106.755 100 Full VBx pipeline

Speaker Diarization Research Comparison

Offline VBx achieves competitive accuracy with batch processing

Method DER Mode Description
FluidAudio (Offline) 10.4% VBx Batch On-device CoreML with optimal clustering
FluidAudio (Streaming) 17.7% Chunk-based First-occurrence speaker mapping
Research baseline 18-30% Various Standard dataset performance

Pipeline Details:

  • Mode: Offline VBx with Hungarian algorithm for optimal speaker-to-cluster assignment
  • Segmentation: VAD-based voice activity detection
  • Embeddings: WeSpeaker-compatible speaker embeddings
  • Clustering: PowerSet with VBx refinement
  • Accuracy: Higher than streaming due to optimal post-hoc mapping

🎯 Offline VBx Test • AMI Corpus ES2004a • 1049.0s meeting audio • 131.0s processing • Test runtime: 2m 17s • 05/17/2026, 02:26 AM EST

@github-actions

github-actions Bot commented May 17, 2026 •

Copy link
Copy Markdown

PocketTTS Smoke Test ✅

Check Result
Build ✅
Model download ✅
Model load ✅
Synthesis pipeline ✅
Output WAV ✅ (161.3 KB)

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.

@github-actions

github-actions Bot commented May 17, 2026 •

Copy link
Copy Markdown

Qwen3-ASR int8 Smoke Test ✅

Check Result
Build ✅
Model download ✅
Model load ✅
Transcription pipeline ✅
Decoder size 571 MB (vs 1.1 GB f32)

Performance Metrics

Metric CI Value Expected on Apple Silicon
Median RTFx 0.04x ~2.5x
Overall RTFx 0.04x ~2.5x

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.

@github-actions

github-actions Bot commented May 17, 2026 •

Copy link
Copy Markdown

ASR Benchmark Results ✅

Status: All benchmarks passed

Parakeet v3 (multilingual)

Dataset WER Avg WER Med RTFx Status
test-clean 0.57% 0.00% 5.35x ✅
test-other 1.75% 0.00% 3.41x ✅

Parakeet v2 (English-optimized)

Dataset WER Avg WER Med RTFx Status
test-clean 0.80% 0.00% 5.02x ✅
test-other 1.00% 0.00% 2.78x ✅

Streaming (v3)

Metric Value Description
WER 0.00% Word Error Rate in streaming mode
RTFx 0.57x Streaming real-time factor
Avg Chunk Time 1.660s Average time to process each chunk
Max Chunk Time 2.911s Maximum chunk processing time
First Token 2.136s Latency to first transcription token
Total Chunks 31 Number of chunks processed

Streaming (v2)

Metric Value Description
WER 0.00% Word Error Rate in streaming mode
RTFx 0.61x Streaming real-time factor
Avg Chunk Time 1.497s Average time to process each chunk
Max Chunk Time 2.152s Maximum chunk processing time
First Token 1.606s Latency to first transcription token
Total Chunks 31 Number of chunks processed

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
Processing time includes: Model inference on Apple Neural Engine, audio preprocessing, state resets between files, token-to-text conversion, and file I/O
Example: RTFx of 2.0x means 10 seconds of audio processed in 5 seconds (2x faster than real-time)

Expected RTFx Performance on Physical M1 Hardware:

• M1 Mac: ~28x (clean), ~25x (other)
• CI shows ~0.5-3x due to virtualization limitations

Testing methodology follows HuggingFace Open ASR Leaderboard

@github-actions

github-actions Bot commented May 17, 2026 •

Copy link
Copy Markdown

VAD Benchmark Results

Performance Comparison

Dataset Accuracy Precision Recall F1-Score RTFx Files
MUSAN 92.0% 86.2% 100.0% 92.6% 657.0x faster 50
VOiCES 92.0% 86.2% 100.0% 92.6% 729.7x faster 50

Dataset Details

  • MUSAN: Music, Speech, and Noise dataset - standard VAD evaluation
  • VOiCES: Voices Obscured in Complex Environmental Settings - tests robustness in real-world conditions

✅: Average F1-Score above 70%

@github-actions

github-actions Bot commented May 17, 2026 •

Copy link
Copy Markdown

Sortformer High-Latency Benchmark Results

ES2004a Performance (30.4s latency config)

Metric Value Target Status
DER 30.3% <35% ✅
Miss Rate 28.2% - -
False Alarm 0.9% - -
Speaker Error 1.2% - -
RTFx 13.0x >1.0x ✅
Speakers 4/4 - -

Sortformer High-Latency • ES2004a • Runtime: 2m 16s • 2026-05-17T06:29:37.393Z

@github-actions

github-actions Bot commented May 17, 2026 •

Copy link
Copy Markdown

Speaker Diarization Benchmark Results

Speaker Diarization Performance

Evaluating "who spoke when" detection accuracy

Metric Value Target Status Description
DER 15.1% <30% ✅ Diarization Error Rate (lower is better)
JER 24.9% <25% ✅ Jaccard Error Rate
RTFx 20.32x >1.0x ✅ Real-Time Factor (higher is faster)

Diarization Pipeline Timing Breakdown

Time spent in each stage of speaker diarization

Stage Time (s) % Description
Model Download 11.105 21.5 Fetching diarization models
Model Compile 4.759 9.2 CoreML compilation
Audio Load 0.112 0.2 Loading audio file
Segmentation 15.483 30.0 Detecting speech regions
Embedding 25.806 50.0 Extracting speaker voices
Clustering 10.322 20.0 Grouping same speakers
Total 51.651 100 Full pipeline

Speaker Diarization Research Comparison

Research baselines typically achieve 18-30% DER on standard datasets

Method DER Notes
FluidAudio 15.1% On-device CoreML
Research baseline 18-30% Standard dataset performance

Note: RTFx shown above is from GitHub Actions runner. On Apple Silicon with ANE:

  • M2 MacBook Air (2022): Runs at 150 RTFx real-time
  • Performance scales with Apple Neural Engine capabilities

🎯 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

@beta-devin-ai-integration beta-devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

View 6 additional findings in Devin Review.

Open in Devin Review (Beta)

/// style: style)
/// // `audio.samples` is 44.1 kHz mono Float32 PCM.
/// ```
public actor Supertonic3Manager {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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/.
Open in Devin Review (Beta)

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +9 to +10
/// cap is 300 characters for Latin-script input and 120 characters for CJK
/// (Korean / Japanese), matching what the upstream Swift CLI ships.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Suggested change
/// 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`.
Open in Devin Review (Beta)

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Suggested change
/// Languages that should use the tighter 120-char chunker.
/// Languages that should use the tighter 90-char chunker.
Open in Devin Review (Beta)

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.
@Alex-Wengg

Copy link
Copy Markdown
Member Author

@claude review

@claude

claude Bot commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @Alex-Wengg's task in 3m 22s —— View job


PR #617 Review — Supertonic-3 Multilingual TTS

  • Read PR context and changed files list
  • Read new Supertonic-3 source files
  • Review CLI and benchmark changes
  • Post complete review

Summary

Solid landing of the Supertonic-3 pipeline. The actor-based concurrency model is correct, there are no @unchecked Sendable usages, the 4-stage CoreML wiring matches the published bundle schema, and the benchmark numbers are convincing. A few issues need attention before merge.


Issues

🔴 No unit tests (CLAUDE.md violation)

Zero test files under Tests/FluidAudioTests/TTS/Supertonic3/. CLAUDE.md mandates "Add unit tests when writing new code." Every other TTS backend has coverage — StyleTTS2 has 5 files, Magpie 4+, PocketTTS 6. Several components here are pure-function and require no CoreML models:

  • Supertonic3TextChunker — chunk(), packSentences(), packCommas(), packWords(), abbreviation detection
  • Supertonic3UnicodeProcessor — preprocess(), mask() (both are static, no indexer needed)
  • Supertonic3LatentSampler — sampleNoisyLatent() accepts an injectable rng closure for determinism
  • Supertonic3MultiArray — makeFloat32/makeInt32/extractFloats round-trip

Fix this →


🟡 Stale doc comment in Supertonic3TextChunker (confirmed by Devin)

Supertonic3TextChunker.swift:9 says "The default cap is 300 characters for Latin-script input and 120 characters for CJK" — but the actual constants are maxChunkLengthLatin = 110 and maxChunkLengthCJK = 90. These limits come from the 128-token window, not the upstream reference CLI's 300/120.

Fix this →


🟡 cjkLanguages doc says "120-char" (confirmed by Devin)

Supertonic3Constants.swift:96:

/// Languages that should use the tighter 120-char chunker.
public static let cjkLanguages: Set<String> = ["ko", "ja"]

The actual cap is 90 (maxChunkLengthCJK = 90), not 120.

Fix this →


🟡 Synthesizer doc comment references old wav_tts output key

Supertonic3Synthesizer.swift:15:

///   5. `vocoder(latent) → wav_tts` (44.1 kHz Float32 PCM).

The schema fix in commit 55fe56d changed the output key to "wav", which is what the code at line 177 correctly uses. The doc comment is a leftover from before the fix.

Fix this →


🟡 voiceStyleShapeMismatch error is defined but never thrown

Supertonic3Error.voiceStyleShapeMismatch(component:expected:got:) exists but nowhere validates the loaded style dims against the expected model shapes ([bsz, ttlStyleTokens, ttlStyleDim] = [1, 50, 256] and [bsz, dpStyleTokens, dpStyleDim] = [1, 8, 16]). A voice JSON with wrong dims will reach makeFloat32's precondition, which crashes instead of throwing a meaningful error.

Either throw voiceStyleShapeMismatch from Supertonic3VoiceStyle.load() after validating dims, or remove the dead error case.


🟡 precondition in makeFloat32/makeInt32 crashes rather than throws

Supertonic3MultiArray.swift:13,24:

precondition(values.count == shape.reduce(1, *), "shape product must match buffer length")

The calling synthesizer wraps makeFloat()/makeInt32() in a do/catch that converts to Supertonic3Error.invalidTensorShape. If the precondition fires, the process crashes before the catch sees anything. For internal functions this is acceptable, but it means the shape guard at the call site in Supertonic3Synthesizer is dead code. Using guard … else { throw … } or moving the check into the throwing wrapper would be more consistent.


⚪ --cpu-only variable named styletts2CpuOnly for Supertonic-3

TTSCommand.swift:277:

await runSupertonic3(
    ...
    cpuOnly: styletts2CpuOnly)  // confusing variable name

styletts2CpuOnly is set by the shared --cpu-only flag so it works correctly, but the naming is misleading for anyone reading the Supertonic-3 branch. A rename to cpuOnly would make the switch-case branches self-explanatory.


What's good

  • Actor isolation is correct throughout — Supertonic3Manager, Supertonic3ModelStore, and Supertonic3Synthesizer all handle concurrency properly with no @unchecked Sendable.
  • Text chunking hierarchy (paragraph → sentence → comma → word) faithfully mirrors the upstream reference and the abbreviation list is comprehensive.
  • Box-Muller sampling in sampleNoisyLatent correctly avoids log(0) with the max(rng(), 1e-4) guard, and masks padding positions to zero afterward.
  • extractFloats handles Float16/Float32/Double/Int32 transparently, which is the right defensive posture for CoreML graph outputs.
  • Model config fallback — Supertonic3ModelStore logs a warning and falls back to compile-time defaults if tts.json decoding fails, rather than hard-crashing.
  • Schema alignment: the PR description clearly documents the wav_tts→wav and UpperCamelCase mlmodelc filename fixes relative to the initial commit.
  • Benchmark wiring — Supertonic-3 integrates cleanly into TtsBenchmarkCommand's existing runPhraseLoop abstraction.

Blocking before merge: unit tests (CLAUDE.md requirement) and the three doc-comment corrections.
Non-blocking but worth fixing: voiceStyleShapeMismatch gap, precondition vs. throw, styletts2CpuOnly rename.

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.
@Alex-Wengg
Alex-Wengg enabled auto-merge (squash) May 17, 2026 06:16
@Alex-Wengg
Alex-Wengg disabled auto-merge May 17, 2026 06:25
@Alex-Wengg
Alex-Wengg merged commit 364d839 into main May 17, 2026
11 checks passed
@Alex-Wengg
Alex-Wengg deleted the feat/tts-supertonic3 branch May 17, 2026 06:25
Gaozhongpai pushed a commit to Gaozhongpai/FluidAudio that referenced this pull request Jun 1, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant