Generation and streaming
Generate one result
final result = await tts.generate(
'Small models can still have a big voice.',
voice: 'luna',
speed: 1.05,
);
print(result.samples); // Float32List
print(result.sampleRate); // 24000
print(result.duration);
print(result.wordTimings);
Export a complete 16-bit WAV:
final bytes = result.wavData();
final base64 = result.wavBase64();
mp3Data() and mp3Base64() currently throw UnsupportedError; the Flutter package intentionally does not bundle a GPL/LGPL MP3 encoder.
Stream long text
await for (final chunk in tts.stream(
articleText,
voice: 'jasper',
speed: 1.0,
)) {
await tts.play(chunk);
}
The stream yields sentence-sized KittenTTSResult objects. It is local incremental generation, not a network protocol.
Analytics
The SDK sends anonymous generation metadata but not input text or generated audio. One stream event is sent per stream invocation, not per output chunk.
final tts = await KittenTTS.create(
config: const KittenTTSConfig(analytics: false),
);
Reuse the initialized object and call dispose() after its owning application service is finished.