Skip to main content

Bundled offline assets

Set modelFiles to bypass model downloads:

let files = KittenTTSModelFiles(
onnxURL: Bundle.main.url(forResource: "model", withExtension: "onnx")!,
voicesURL: Bundle.main.url(forResource: "voices", withExtension: "npz")!
)

let config = KittenTTSConfig(model: .nanoInt8, modelFiles: files)

The phonemizer must also use local dictionary files for a fully offline first launch.

Shared asset manifest

The Swift SDK reads manifests generated by the React Native asset bundler:

npx @kittentts/react-native bundle-assets \
--models nano-int8 \
--out assets/kittentts

Add the generated directory to the Xcode target as folder resources, then load it:

let config = try KittenTTSBundledAssets.configFromBundle(
.main,
assetRoot: "kittentts",
model: .nanoInt8,
defaultVoice: .bella
)

let tts = try await KittenTTS(config)

loadManifest(from:) and config(from:baseURL:...) support non-bundle locations. Manifest versions 1 and 2 are decoded; version 2 can contain multiple models.

Bundled models increase app size. Include only the variants your product actually exposes and test a clean offline installation.