expand_to_segments (en/acronym.rs)

kesha-voice-kit · rust/src/tts/en/acronym.rs · rust · MIT
voice, Voice / Speech

Tokenizes English text into segments with IPA overrides for TTS.

// Source: https://github.com/drakulavich/kesha-voice-kit | License: MIT | Copyright 2026 drakulavich
// Provided via justclaw.it.com; keep this notice with the code.
//! Tokenize English plain text and emit a segment list with two kinds of
//! pronunciation overrides:
//!
//! - **`IPA_LEXICON`** — case-sensitive token → IPA-phoneme map. Covers
//!   all-caps acronyms with industry pronunciations AND mixed-case proper
//!   nouns Kokoro mispronounces. IPA hits fire even when `auto_expand=false`
//!   (intent-explicit, parallel to `<say-as>`).
//! - **Letter-spell rule** — uppercase 2..=5 tokens NOT on `STOP_LIST` and
//!   NOT in `IPA_LEXICON` get expanded letter-by-letter; gated by `auto_expand`.
//! - **`STOP_LIST`** — natural-English caps words Kokoro handles via training;
//!   passed 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key