Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/KittenML/KittenTTS/llms.txt

Use this file to discover all available pages before exploring further.

Signature

KittenTTS.generate_to_file(
    text,
    output_path,
    voice="expr-voice-5-m",
    speed=1.0,
    sample_rate=24000,
) -> None
This is a convenience wrapper around generate() that writes the resulting audio to disk using soundfile. Use it when you don’t need to manipulate the audio array in memory.

Parameters

text
str
required
The input text to synthesize.
output_path
str
required
File path where the audio will be saved. The file format is inferred from the extension.Supported formats: .wav, .flac, .ogg.
voice
str
default:"\"expr-voice-5-m\""
Voice to use for synthesis. Accepts any friendly name from available_voices: Bella, Jasper, Luna, Bruno, Rosie, Hugo, Kiki, Leo.The default "expr-voice-5-m" is the internal ID for Leo. You can pass either the friendly name or the internal ID.
speed
float
default:"1.0"
Speech speed multiplier.
  • 1.0 — normal speed
  • Values below 1.0 slow down speech
  • Values above 1.0 speed it up
sample_rate
int
default:"24000"
Audio sample rate in Hz. The model produces audio at 24 kHz. Change this only if you need to resample the output for a specific downstream use case.
Use generate_to_file() when you only need the saved file and don’t need to manipulate the audio array in your code. It is equivalent to calling generate() and then soundfile.write().

Usage examples

from kittentts import KittenTTS

tts = KittenTTS()
tts.generate_to_file(
    "Hello, this is KittenTTS.",
    "output.wav",
)