from kittentts import KittenTTSimport soundfile as sf# Load the model (downloads automatically from Hugging Face)model = KittenTTS("KittenML/kitten-tts-mini-0.8")# Generate audio — returns a numpy array at 24 kHzaudio = model.generate("Hello, world!", voice="Bella")# Save to WAV filesf.write("output.wav", audio, 24000)print("Saved to output.wav")
The generate method returns a NumPy array sampled at 24,000 Hz. You can pass it directly to soundfile, scipy, or any other audio library.
from kittentts import KittenTTSimport soundfile as sfmodel = KittenTTS("KittenML/kitten-tts-mini-0.8")text = "One day, a little girl named Lily found a needle in her room."audio = model.generate(text=text, voice="Bruno")sf.write("output.wav", audio, 24000)