Skip to main content

API reference

Construction

KittenTTS.create(options?, onProgress?): Promise<KittenTTS>

Progress is between 0 and 1; stage metadata identifies downloads and cached assets.

Instance methods

MethodResultDescription
generate(text, voice?, speed?)Promise<KittenTTSResult>Generate without playback
generateStreaming(text, voice?, speed?)AsyncIterable<KittenTTSResult>Yield sentence-group results
speak(text, voice?, speed?)Promise<KittenTTSResult>Generate and play
play(result, options?)Promise<void>Play an existing result
dispose()Promise<void>Release engine resources

Result

Field or methodType
samplesFloat32Array
sampleRate24000
durationnumber seconds
voiceKittenVoice
effectiveSpeednumber
inputTextstring
wordTimingsKittenWordTiming[]
wavData()Uint8Array
wavBase64()string

Static cache methods

isModelCached, isModelDownloaded, getModelCacheInfo, predownload, redownloadModel, and clearModelCache accept optional model configuration.

Errors

Use isKittenTTSError(error) and inspect error.code.

CodeMeaning
EMPTY_INPUTInput is blank
DOWNLOAD_FAILEDAn asset could not be downloaded
INVALID_MODEL_DATACached or bundled model data is invalid
PHONEMIZER_FAILEDText-to-phoneme conversion failed
INFERENCE_FAILEDONNX setup or inference failed
PLAYBACK_FAILEDThe configured player failed

TypeScript declarations in the published package are the authoritative signature source.