kokoro_tts: skip phonemes the vocab has no id for, as KModel does - #8
Closed
christopherthompson81 wants to merge 1 commit into
Closed
christopherthompson81 wants to merge 1 commit into
christopherthompson81 wants to merge 1 commit into
Conversation
eSpeak-ng glottalises /t/ before a syllabic nasal, so the built-in G2P produces a U+0329 syllabic mark for ordinary words -- "button", "kitten", "written", "forgotten" -- and encode_input_ids_and_count then threw on the very symbol it had just produced, losing the whole request. The reference implementation does not: hexgrad/Kokoro's KModel tokenizes with filter(None, map(vocab.get, phonemes)), dropping any phoneme the 114-entry vocab has no id for. Dropping the mark gives b'V?n for "button", a correct reading; throwing gives no audio at all. Malformed UTF-8 above still throws. An unknown but well-formed phoneme does not.
Owner
Author
|
Folded into #9 as one PR, per review. Both commits are there unchanged — the bug fix is still the first commit and still reviewable on its own. The reason the split stopped being worth it: the ABI addition turned out to be completing something already half-designed rather than proposing a new concept. |
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.
Review copy on the fork. Upstream issue: 0xShug0#556.
encode_input_ids_and_countthrew on any symbol missing from Kokoro's 114-entry vocab — including symbols the model's own G2P had just produced — which aborted the whole request.The reference implementation does not. hexgrad/Kokoro's
KModeltokenizes withinput_ids = list(filter(None, map(vocab.get, phonemes))): it drops phonemes with no token id. Dropping gives a correct reading; throwing gives no audio at all.Malformed UTF-8 above still throws — that is a real error. An unknown but well-formed phoneme is not. Each skip is recorded as a debug trace (
kokoro.skipped_phoneme), so the information is kept without failing the request.What it costs today, measured
40 real corpus sentences per language through the release
kokoro_82m_q8_0, with the throw still in place:«U+00AB«U+00AB̪U+032ASo roughly 12% of Spanish and 15% of French prose failed outright — the vocab carries
(and)but not the guillemets. English is affected too, just more rarely: eSpeak glottalises /t/ before a syllabic nasal, sobutton,kitten,writtenandforgottenproduce a U+0329 the vocab lacks (100 of the first 40,000 dictionary words — but one anywhere aborts the request).Verification
Every previously-failing case renders, with durations in line with words that always worked (
button1.00 s besidehidden1.07 s), and 114/114 distinct English golden sentences render.ran=4 skipped=1 failures=0audiocpp_c_api_path/_exportsaudiocpp_c_api_modelaudiocpp_c_api_parity79800 frames at 24 kHz is 3.325 s — byte-identical to what the unpatched engine produced for that sentence, and identical between the CLI and the C API. The fix is inert on text that never had an out-of-vocab symbol.
Notes for the reviewer
3eccab5, cherry-picked ontob46fe6b. The touched file and every dependent header are byte-identical between the two bases.espeak-ng --ipaagainst the vocab. That proxy is misleading in both directions: it predicts 507 hyphen failures in French that never occur (espeak_text()ends withreplace(out, "-", "")), and misses the guillemets that actually fail.🤖 Generated with Claude Code
https://claude.ai/code/session_01EkxqpYvUbjCpRDnFiNiVfx