Skip to main content

Crate loqui_kokoro

Crate loqui_kokoro 

Source
Expand description

Kokoro-82M text-to-speech, in process.

Text goes through loqui_g2p (misaki’s English G2P, GPL-free), is cut into chunks of at most 510 phonemes exactly as Kokoro’s own KPipeline cuts it, and each chunk runs through the ONNX export of Kokoro on ONNX Runtime. The result is 24 kHz mono f32, trimmed of edge silence and peak-normalised the way open-speech delivers it.

Weights are not bundled. Point KokoroModel::load at onnx/model.onnx and Kokoro::new at the voices/ directory of onnx-community/Kokoro-82M-v1.0-ONNX (Apache-2.0).

Modules§

post
open-speech’s output post-processing (src/audio/postprocessing.py): drop leading and trailing near-silence, then scale to a fixed peak.

Structs§

Blend
A voice to speak in: one or more voice packs whose weights sum to one.
Kokoro
Text in, audio out. Send + Sync: share one per process.
KokoroModel
Voice

Enums§

Device
Where inference runs.
Error
Non-exhaustive so that a new failure need not be a breaking change.

Constants§

DEFAULT_VOICE
Kokoro’s default voice, and what OpenAI’s alloy maps to.
ENGLISH_VOICES
Kokoro v1.0’s American (a*) and British (b*) voices: the ones this crate can phonemize for. f/m in the second letter is the speaker’s voice type as Kokoro labels it.
MAX_PHONEMES
Rows in a pack, and so the longest phoneme sequence Kokoro accepts.
SAMPLE_RATE
Output sample rate.
STYLE_DIM

Functions§

chunks
KPipeline.en_tokenize: the phoneme string of each chunk, in order. Empty chunks are dropped, as generate_from_tokens skips them.
resolve_alias
OpenAI’s voice names, mapped the way open-speech maps them, so a client written against OpenAI keeps working. Blend applies this to each part of a spec.
tokens_to_ps
KPipeline.tokens_to_ps: each token’s phonemes, a space after those followed by whitespace, trimmed.