Summary
The current IndexTTS2Tokenizer normalization handles Latin text, but continuous Mandarin input can remain in the form ▁你好.... With the published aufklarer/IndexTTS2-MLX-fp16 bundle, this can leave no valid SentencePiece path and produce IndexTTS2TokenizerError.unencodableText.
I encountered this while integrating the existing speech-swift IndexTTS2 runtime into a desktop dubbing pipeline. Applying CJK character pre-tokenization allowed real Mandarin synthesis to complete successfully.
Environment
- speech-swift:
7984666dd7dc9233132c57a09bd9bf490a2ae448
- model:
aufklarer/IndexTTS2-MLX-fp16
- model revision:
208b3d6ea53a119f3501b3bfd8e666b9b5e8c705
- Apple M2, 24 GB RAM
- macOS 26.5
- Swift 6.3.2
Current behavior
normalizedPieceText(for:) currently:
- applies compatibility normalization;
- collapses whitespace;
- uppercases the full string;
- inserts
▁ only at whitespace boundaries.
For Mandarin without spaces, multiple CJK scalars therefore remain one continuous segment. This does not mirror the upstream IndexTTS2 text front end, which pre-tokenizes CJK characters before BPE lookup.
Example input:
The model-compatible pre-tokenized shape is approximately:
▁你▁好▁,▁这▁是▁一▁个▁中▁文▁合▁成▁测▁试▁.
Local fix evaluated
The local integration currently applies:
- per-scalar CJK pre-tokenization;
- IndexTTS2-compatible punctuation normalization;
- locale-aware number expansion;
- an unknown-token fallback so one unsupported scalar does not invalidate the entire path.
This was enough to run real Mandarin synthesis through the Swift/MLX runtime and a persistent JSONL bridge. The surrounding desktop integration has 22 runtime checks, but the tokenizer change itself still needs focused speech-swift regression tests before a PR.
Proposed upstream scope
If this approach matches the intended text front end, I can prepare a focused PR containing only:
- the tokenizer normalization fix;
- regression tests for Mandarin, mixed Chinese/English, punctuation, numbers, and unknown scalars;
- no application-specific bridge or dependency pinning.
Would you prefer the PR to mirror the upstream Python normalizer closely, or keep the Swift implementation limited to the minimum CJK boundary fix?
Summary
The current
IndexTTS2Tokenizernormalization handles Latin text, but continuous Mandarin input can remain in the form▁你好.... With the publishedaufklarer/IndexTTS2-MLX-fp16bundle, this can leave no valid SentencePiece path and produceIndexTTS2TokenizerError.unencodableText.I encountered this while integrating the existing speech-swift IndexTTS2 runtime into a desktop dubbing pipeline. Applying CJK character pre-tokenization allowed real Mandarin synthesis to complete successfully.
Environment
7984666dd7dc9233132c57a09bd9bf490a2ae448aufklarer/IndexTTS2-MLX-fp16208b3d6ea53a119f3501b3bfd8e666b9b5e8c705Current behavior
normalizedPieceText(for:)currently:▁only at whitespace boundaries.For Mandarin without spaces, multiple CJK scalars therefore remain one continuous segment. This does not mirror the upstream IndexTTS2 text front end, which pre-tokenizes CJK characters before BPE lookup.
Example input:
The model-compatible pre-tokenized shape is approximately:
Local fix evaluated
The local integration currently applies:
This was enough to run real Mandarin synthesis through the Swift/MLX runtime and a persistent JSONL bridge. The surrounding desktop integration has 22 runtime checks, but the tokenizer change itself still needs focused speech-swift regression tests before a PR.
Proposed upstream scope
If this approach matches the intended text front end, I can prepare a focused PR containing only:
Would you prefer the PR to mirror the upstream Python normalizer closely, or keep the Swift implementation limited to the minimum CJK boundary fix?