speaker_helper.voices module
Curated preset voices, keyed by language and gender.
Module summary
Auto-picking a voice from the engine’s presets (see resolution by language) is convenient but blind to gender: it takes the first voice whose language matches. When an application needs a specific male or female voice per language — a two-speaker dialogue, a role-played call — it should not have to hard-code raw engine ids.
This module names that choice. PRESET_VOICES is a small, curated set of
real kokoro voices (the ids the kokoro backend actually serves),
and voice_for() resolves a (language, gender) pair to one of them.
Notes on coverage
kokoro ships several English voices of each gender and one French voice,
ff_siwis (female). It has no native French male voice, so the French male
slot maps to a real male voice id (bm_george) that renders French text with a
male timbre. Every id here is a genuine kokoro preset; none is a placeholder.
Usage example
>>> from speaker_helper.voices import voice_for
>>> voice_for("fr", "female")
'ff_siwis'
>>> voice_for("en", "male")
'am_michael'
- speaker_helper.voices.voice_for(language, gender='', *, index=0)[source]
Resolve a
(language, gender)pair to a concrete kokoro voice id.- Parameters:
- Returns:
A real kokoro
voice_id. Falls back to the first voice of the language (ignoring gender), then toff_siwis/am_michael-style defaults, so the result is always a usable id.- Return type: