Skip to main content

API reference

KittenTTS

public actor KittenTTS
APIPurpose
init(_:downloadProgressHandler:) async throwsPrepare assets and ONNX session
generate(_:voice:speed:) async throwsReturn one result
generateStreaming(_:voice:speed:)Return an AsyncThrowingStream
speak(_:voice:speed:) async throwsGenerate and play
stopSpeaking()Stop current playback
isModelCached(for:)Check one configuration
isModelCached(_:)Check one model
prewarm(config:) async throwsDownload and initialize early

KittenTTSConfig

PropertyDefault
model.nano
defaultVoice.bella
speed1.0, clamped to 0.5–2.0
phonemizer.builtin
storageDirectoryApplication Support
modelFilesnil
ortNumThreads4
maxTokensPerChunk400, minimum 50

KittenTTSResult

Contains [Float] samples, a 24 kHz sample rate, computed duration, voice, effective speed, original text, word timings, wavData(), and writeWAV(to:).

Error cases

emptyInput, engineNotReady, modelFileNotFound, voicesFileNotFound, noVoiceEmbedding, inferenceFailed, emptyOutput, downloadFailed, invalidModelData, espeakNotInstalled, phonemizerLoadFailed, audioSessionFailed, and playbackFailed.

Use error.localizedDescription for user-facing diagnostic text and switch on KittenTTSError when recovery differs by case.