Skip to main content

Offline assets and storage

Preloaded bytes

const tts = await KittenTTS.create({
modelFiles: {
onnxData,
voicesData,
},
});

This is suitable for app-managed browser downloads and packaged environments.

Node paths

const tts = await KittenTTS.create({
modelFiles: {
onnxPath: './models/kitten_tts_nano_v0_8.onnx',
voicesPath: './models/voices.npz',
},
});

Path-based model files are Node-only.

Built-in storage implementations

ImplementationUse
BrowserCacheAssetStorageCache API in normal browser origins
MemoryAssetStorageTests, ephemeral sessions, and file:// fallback
NodeFileAssetStorageNode filesystem cache
defaultAssetStorage()Select appropriate runtime default

Custom storage

Implement AssetStorage for IndexedDB, a service worker, Electron, or an application download manager, then pass storage to KittenTTS.create().

You can also pass a custom fetch implementation and modelBaseURL for authenticated or self-hosted asset delivery.

Self-host ONNX Runtime assets

const tts = await KittenTTS.create({
ortWasmPath: '/vendor/onnxruntime-web/',
});

The directory or explicit {wasm, mjs} map must match the installed ONNX Runtime Web version. Pass false only when the application configures ort.env.wasm itself.