Skip to content

Add opt-in Kokoro phoneme rewrite rules - #1360

Merged
0xShug0 merged 1 commit into
mainfrom
fix/kokoro-leading-i-stress
Nov 21, 2026
Merged

0xShug0 merged 1 commit into
mainfrom
fix/kokoro-leading-i-stress

Conversation

@0xShug0

@0xShug0 0xShug0 commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Kokoro’s eSpeak frontend can leave standalone “I” unstressed, making it nearly inaudible in phrases such as “I foo.” Add an opt-in phoneme_rules request option so applications can correct pronunciation without changing existing pipelines.

Rules are an ordered JSON array of ECMAScript regex patterns and replacements applied to generated English phonemes before tokenization. Supplied phonemes bypass rewriting, invalid rules return explicit errors, and rules participate in the frontend cache key. Existing GGUF packages work without repacking. No default correction, framework changes, weight changes or inference-math changes.

For the reported case:

--request-option 'phoneme_rules=[{"pattern":"(^|\\s)I(?=\\s|$)","replacement":"$1ˌI"}]'

Validation

Debug build, CPU, eight threads, Kokoro 82M Q8_0, Kore voice, US English, seed 42:

  • Six default WAVs are byte-identical to main, including the reported short phrase and longer sentence.
  • Enabled rules reproduce the secondary-stressed correction. Twelve requests in one session cover defaults, on→off→on reuse, empty rules and ordered replacements.
  • A separate dog→cat rule makes “The dog ran.” byte-identical to literal “The cat ran.” with the same voice and seed.
  • The documented CLI command works with the existing GGUF. Malformed JSON, invalid regex and missing fields fail explicitly.
  • The focused unit test for defaults, parsing and supplied-phoneme bypass passed; model-spec checks passed.

Closes #1357.

@0xShug0
0xShug0 merged commit cf49294 into main Nov 21, 2026
7 checks passed
@0xShug0
0xShug0 deleted the fix/kokoro-leading-i-stress branch November 21, 2026 04:27
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.

Kokoro makes the initial ‘I’ in ‘I foo.’ nearly inaudible

1 participant