Skip to main content

Bundled offline assets

Bundled assets remove the first-run network requirement. They increase the application download size by the selected model files.

Generate an asset bundle

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

The generated layout contains a manifest, model ONNX files, voices.npz, and CE phonemizer dictionaries.

assets/kittentts/
manifest.json
kitten-tts-nano-0.8-int8/
kitten_tts_nano_v0_8.onnx
voices.npz
CEPhonemizer/
en_rules.txt
en_list.txt

Expo config plugin

Configure the package plugin so prebuild copies the files into the native projects. After assets change, rebuild the native app:

npx expo prebuild --clean
npx expo run:ios

Use the corresponding Android command for Android.

Create config from the manifest

import manifest from './assets/kittentts/manifest.json';
import {
KittenModel,
KittenTTS,
createBundledAssetConfig,
} from '@kittentts/react-native';

const config = await createBundledAssetConfig(manifest, {
model: KittenModel.NanoInt8,
});

const tts = await KittenTTS.create(config);

For normal filesystem paths, pass basePath. You can also supply modelFiles and a configured CE phonemizer directly when integrating an existing asset system.

Test offline startup on a clean installation with network access disabled; a developer device may otherwise mask missing bundle files with previously cached downloads.