Repository navigation
fix(irodori_tts): normalize input text like Python normalize_text - #1164
Merged
Merged
Conversation
audio.cpp applied only the literal replacements of Python Irodori-TTS's normalize_text. The rest was missing, so text with these characters reached the tokenizer differently from Python: - REGEX_REPLACE_MAP: drop `;▼♀♂《》≪≫①-⑥` and dash-like characters (U+02D7, U+2010-2015, U+2043, U+2212, U+23AF, U+23E4, U+2500, U+2501, U+2E3A, U+2E3B), map `~` / `〜` to `ー`, collapse 3+ `…` to `……` - strip_outer_brackets: remove 「」『』()【】() that enclose the whole text - NFKC (utf8proc, already vendored): half-width katakana, full-width Latin letters and digits, compatibility characters - strip(): Python whitespace, not only space / CR / LF The steps run in Python's order. Text without these characters is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
|
@KKTTSPJ One minor omission: upstream removes U+E63E (), but the PR retains it.
|
Python's first REGEX_REPLACE_MAP class holds U+E63E, a private-use character between the double angle brackets and the circled digits that renders as nothing, and the port missed it. Checked against every code point: the 32 characters the Python classes match are now exactly the ones this function drops or maps. Also keep session.cpp ASCII (the ellipsis comment). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
Thanks, you're right: Python's first class has U+E63E between To make sure nothing else is hidden, I tested every code point against Python's
The commit also replaces the |
Owner
|
@KKTTSPJ Thanks for the quick turnaround! PR merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
irodori_ttsnormalizes input text with a port of Python Irodori-TTS'snormalize_text, but only its literal replacements were ported. The regex rules,strip_outer_bracketsand NFKC were missing, so text with common Japanese characters reached the tokenizer differently from Python: half-width katakana, full-width Latin letters and digits, wave dashes (〜/~), dash-like characters, and brackets around the whole line. The tokenizers have no normalizer of their own (v4 Small'stokenizer.jsonhasnormalizer: null), so this is the only place where it can happen.This PR completes the port in Python's order:
REGEX_REPLACE_MAP: drop;▼♀♂《》≪≫①②③④⑤⑥and the dash-like characters (U+02D7, U+2010–2015, U+2043, U+2212, U+23AF, U+23E4, U+2500, U+2501, U+2E3A, U+2E3B), map~/〜toー, collapse three or more…to……strip_outer_brackets: remove「」『』()【】()that enclose the whole textomnivoice,plapreandfish_drama3do);irodori_ttsnow linksutf8proc_vendor...and..to…(unchanged)strip()with Python's whitespace set, instead of space / CR / LF onlyInvalid UTF-8 input is now rejected as an invalid request at this step.
Validation
Python reference: Aratako/Irodori-TTS
89f9d8f(irodori_tts/text_normalization.pyis the same on its currentmain).Normalized text (30 sentences covering each rule: half-width katakana with dakuten, full-width Latin and digits,
〜/~, every dash and symbol in the regex, ellipsis runs of 2 to 5, each bracket pair, nested and partial brackets,?!♥●◯〇, tab /[n]/ full-width space, leading and trailing ASCII, NBSP and full-width spaces, compatibility characters like㍻㌔㈱Ⅰ㎝, emoji and surrogate-pair kanji):normalize_text(text).strip()mainText without these characters is unchanged.
mainand this PR give byte-identical WAVs on CUDA for v4 Small, v4.1 Small, 500M v3 and 600M v3 VoiceDesign (no reference, reference audio, and caption where supported; 11 cases).Audio for affected sentences (v4 Small Q8_0, CUDA, no reference, seed 42, 40 steps; log-mel frame cosine against Python fp32):
main「カタカナで書いた〜、テストの文章です。」ABC社の新製品は1230円〜です。えーと~、それは――つまり、その…………そういうこと。For the second sentence, the normalized text and the token ids now match Python exactly. The remaining difference comes from Q8_0: the F16 package gives 0.9997 with this PR.
The same gap showed up while validating #1163 (v4 Large), whose Gemma tokenizer turned two of twelve test sentences into different token ids. This PR is independent of #1163; the two touch different files.
🤖 Generated with Claude Code