Skip to main content

Generate speech

Generate audio in memory

from kittentts import KittenTTS

tts = KittenTTS("KittenML/kitten-tts-mini-0.8")
audio = tts.generate(
"This high-quality model runs locally.",
voice="Jasper",
speed=1.0,
clean_text=True,
)

audio is a NumPy array containing mono samples. Write it at 24 kHz:

import soundfile as sf

sf.write("speech.wav", audio, 24_000)

Write directly to a file

tts.generate_to_file(
"Save this sentence directly.",
"speech.wav",
voice="Luna",
speed=1.1,
sample_rate=24_000,
)

The model output is natively 24 kHz. Passing another sample_rate changes the file metadata; it does not resample the generated array.

Voice identifiers

Display names such as "Bella" and "Jasper" are accepted through the model's alias table. Raw embedding identifiers such as "expr-voice-2-f" are also valid.

print(tts.available_voices)
# ['Bella', 'Jasper', 'Luna', 'Bruno', 'Rosie', 'Hugo', 'Kiki', 'Leo']

Speed

speed=1.0 is the user multiplier. Model configuration may also apply a voice-specific speed prior. Test each voice rather than assuming the same value sounds identical across voices.

Clean text

generate() currently defaults clean_text to False on the public wrapper. Set it explicitly when input can contain numbers, abbreviations, money, times, or URLs. The lower-level model defaults to cleaning, so explicit values avoid ambiguity.

audio = tts.generate(
"The total is $12.50 at 3:05 p.m.",
voice="Rosie",
clean_text=True,
)