Skip to main content

Installation

Requirements​

Tool or platformMinimum
iOS16.0
macOS14.0
Swift5.9
Xcode15

Xcode​

Choose File → Add Package Dependencies, then enter:

https://github.com/KittenML/KittenTTS-swift

Add the KittenTTS library product to the app target.

Package.swift​

dependencies: [
// Pin the public package to a compatible semantic version.
.package(
url: "https://github.com/KittenML/KittenTTS-swift",
from: "0.1.0"
),
],
targets: [
.target(
name: "YourApp",
dependencies: [
// Link the KittenTTS library product into this app target.
.product(name: "KittenTTS", package: "KittenTTS-swift")
]
),
]

The package brings ONNX Runtime through Microsoft's Swift Package Manager package and compiles the CE phonemizer bridge as C++17.

First initialization​

let tts = try await KittenTTS { progress in
print("Download: \(Int(progress * 100))%")
}

Initialization downloads phonemizer dictionaries, the ONNX model, and voices.npz if they are not cached. It then creates the inference engine off the calling actor.

Use KittenTTS.isModelCached() to choose whether the UI should present a download step.