mstar.model.kokoro.voices#

Voice registry: the bundled Kokoro voice packs and blends of them.

A voice pack is a [510, 1, 256] tensor with one style vector per phoneme count; a request’s style is the row for its chunk’s phoneme-string length. A blend is a weighted sum of packs, spelled af_bella+af_sky (equal weights), af_bella(2)+af_sky(1) or af_bella-am_adam(0.5) (Kokoro-FastAPI’s syntax; weights are normalized by their absolute sum), or af_bella,af_sky (the kokoro package’s comma mean). Subtraction only steers a blend: the positive weights must outweigh the negative ones, since a negated or cancelled style decodes to loud noise.

Classes

VoiceRegistry(voices_dir, pack_rows, style_dim)

class mstar.model.kokoro.voices.VoiceRegistry(voices_dir, pack_rows, style_dim)[source]#

Bases: object

Parameters:
  • voices_dir (str | Path)

  • pack_rows (int)

  • style_dim (int)

language_of(spec)[source]#

Kokoro voice names start with their language code (af_heart -> a).

Parameters:

spec (str)

Return type:

str

property names: list[str]#

The bundled voices, sorted.

pack(name)[source]#

[pack_rows, 2 * style_dim] style table of one bundled voice.

Parameters:

name (str)

Return type:

Tensor

static parse_blend(spec)[source]#

"af_bella(2)+af_sky-am_adam(0.5)" -> [(af_bella, 2), (af_sky, 1), (am_adam, -0.5)].

Parameters:

spec (str)

Return type:

list[tuple[str, float]]

resolve(spec)[source]#

Style table for a voice or blend spec; blends are cached by spec string.

Parameters:

spec (str)

Return type:

Tensor

style(spec, num_phonemes)[source]#

[2 * style_dim] style vector for a chunk of num_phonemes phoneme characters.

Parameters:
  • spec (str)

  • num_phonemes (int)

Return type:

Tensor