mstar.model.kokoro.config

Contents

mstar.model.kokoro.config#

Kokoro-82M configuration, built from the checkpoint’s config.json.

The upstream kokoro package hard-codes a handful of architecture constants outside its config (the 24 kHz sample rate and the harmonic source parameters of the iSTFTNet generator, the 1024-wide decoder trunk, the 64-channel ASR residual). They are fields here so nothing else in the package carries a magic number.

Classes

KokoroBertConfig([hidden_size, ...])

PL-BERT: an ALBERT encoder over phoneme tokens (plbert in config.json).

KokoroISTFTNetConfig([...])

The iSTFTNet generator (istftnet in config.json).

KokoroModelConfig([n_token, hidden_dim, ...])

Everything the M* Kokoro integration reads.

class mstar.model.kokoro.config.KokoroBertConfig(hidden_size=768, num_attention_heads=12, intermediate_size=2048, max_position_embeddings=512, num_hidden_layers=12, dropout=0.1, embedding_size=128, layer_norm_eps=1e-12)[source]#

Bases: object

PL-BERT: an ALBERT encoder over phoneme tokens (plbert in config.json).

embedding_size and layer_norm_eps are ALBERT defaults the checkpoint relies on without stating them.

Parameters:
  • hidden_size (int)

  • num_attention_heads (int)

  • intermediate_size (int)

  • max_position_embeddings (int)

  • num_hidden_layers (int)

  • dropout (float)

  • embedding_size (int)

  • layer_norm_eps (float)

dropout: float = 0.1#
embedding_size: int = 128#
property head_dim: int#
hidden_size: int = 768#
intermediate_size: int = 2048#
layer_norm_eps: float = 1e-12#
max_position_embeddings: int = 512#
num_attention_heads: int = 12#
num_hidden_layers: int = 12#
class mstar.model.kokoro.config.KokoroISTFTNetConfig(upsample_kernel_sizes=<factory>, upsample_rates=<factory>, gen_istft_hop_size=5, gen_istft_n_fft=20, resblock_dilation_sizes=<factory>, resblock_kernel_sizes=<factory>, upsample_initial_channel=512)[source]#

Bases: object

The iSTFTNet generator (istftnet in config.json).

Parameters:
  • upsample_kernel_sizes (list[int])

  • upsample_rates (list[int])

  • gen_istft_hop_size (int)

  • gen_istft_n_fft (int)

  • resblock_dilation_sizes (list[list[int]])

  • resblock_kernel_sizes (list[int])

  • upsample_initial_channel (int)

gen_istft_hop_size: int = 5#
gen_istft_n_fft: int = 20#
resblock_dilation_sizes: list[list[int]]#
resblock_kernel_sizes: list[int]#
property upsample_factor: int#

Waveform samples per generator input frame (60 * 5 = 300).

upsample_initial_channel: int = 512#
upsample_kernel_sizes: list[int]#
upsample_rates: list[int]#
class mstar.model.kokoro.config.KokoroModelConfig(n_token=178, hidden_dim=512, style_dim=128, n_layer=3, max_dur=50, dropout=0.2, n_mels=80, text_encoder_kernel_size=5, dim_in=64, max_conv_dim=512, multispeaker=True, vocab=<factory>, plbert=<factory>, istftnet=<factory>, sample_rate=24000, decoder_hidden=1024, asr_res_dim=64, source_harmonics=8, source_sine_amp=0.1, source_noise_std=0.003, source_voiced_threshold=10.0, weights_file='kokoro-v1_0.pth', voices_dir='voices', default_voice='af_heart', default_speed=1.0, min_speed=0.25, max_speed=4.0, first_chunk_target_phonemes=80, chunk_target_phonemes=200, max_chunks=512, text_buckets=<factory>, frame_buckets=<factory>, capture_batch_sizes=<factory>, max_batch_frames=16384, frame_grouping='bucket', decoder_dtype='float32', compile_decoder=True)[source]#

Bases: object

Everything the M* Kokoro integration reads.

The top block mirrors config.json; the serving block has M*-side defaults that a deployment can change through model kwargs.

Parameters:
asr_res_dim: int = 64#
capture_batch_sizes: list[int]#
chunk_target_phonemes: int = 200#
compile_decoder: bool = True#
property context_length: int#
decoder_dtype: str = 'float32'#
decoder_hidden: int = 1024#
default_speed: float = 1.0#
default_voice: str = 'af_heart'#
dim_in: int = 64#
dropout: float = 0.2#
first_chunk_target_phonemes: int = 80#
frame_buckets: list[int]#
frame_grouping: str = 'bucket'#
classmethod from_dict(data)[source]#
Parameters:

data (dict[str, Any])

Return type:

KokoroModelConfig

classmethod from_pretrained(local_dir)[source]#
Parameters:

local_dir (str | Path)

Return type:

KokoroModelConfig

hidden_dim: int = 512#
istftnet: KokoroISTFTNetConfig#
max_batch_frames: int = 16384#
max_chunks: int = 512#
max_conv_dim: int = 512#
max_dur: int = 50#
property max_phonemes: int#

Phonemes per chunk, leaving room for the <bos>/<eos> pair.

max_speed: float = 4.0#
min_speed: float = 0.25#
multispeaker: bool = True#
n_layer: int = 3#
n_mels: int = 80#
n_token: int = 178#
plbert: KokoroBertConfig#
sample_rate: int = 24000#
property samples_per_frame: int#

the prosody predictor doubles the frame rate, the generator upsamples by 300.

Type:

Waveform samples per predicted duration unit

source_harmonics: int = 8#
source_noise_std: float = 0.003#
source_sine_amp: float = 0.1#
source_voiced_threshold: float = 10.0#
style_dim: int = 128#
property style_pack_rows: int#

A voice pack holds one style vector per phoneme count.

property style_vector_dim: int#

A pack row is [decoder style, predictor style].

text_buckets: list[int]#
text_encoder_kernel_size: int = 5#
vocab: dict[str, int]#
voices_dir: str = 'voices'#
weights_file: str = 'kokoro-v1_0.pth'#