This page covers the smallest useful setup: install the SDK, create a TTS instance, and generate speech.
| Requirement | Version |
|---|---|
| React Native | >= 0.72 |
| iOS | 15.1+ |
| Android | API 24+ |
| Web | modern browser with WebAssembly support |
| Node.js | 20+ recommended for examples |
Expo Go will not work. KittenTTS depends on native modules:
onnxruntime-react-nativereact-native-fs
Use a bare React Native app, an Expo development build, or a prebuilt Expo app.
React Native Web builds use onnxruntime-web and do not require those native
modules at runtime.
npm install @kittentts/react-nativeDo not install or register onnxruntime-react-native manually. The SDK depends
on it and registers the Android package it needs.
npx expo install expo-audio expo-dev-client
npx expo prebuild
npx expo run:iosFor Android:
npx expo run:androidAfter the development build is installed, keep using that app with:
npx expo start --dev-clientFor playback with speak(), install a player:
npm install react-native-sound
cd ios && pod install && cd ..React Native Web builds resolve the package's browser entrypoint. The web
runtime uses onnxruntime-web, Cache API storage for downloaded model files,
and the same JavaScript CE phonemizer.
import {
KittenTTS,
createBrowserAudioPlayer,
} from '@kittentts/react-native';
const tts = await KittenTTS.create({
player: createBrowserAudioPlayer(),
});
await tts.speak('Hello from KittenTTS on web.');
await tts.dispose();The browser path also supports generate(), wordTimings, wavData(), and
wavBase64(). Pass ortWasmPath if your app needs to self-host ONNX Runtime
WASM assets instead of using the SDK defaults.
By default, browser builds load the pinned ONNX Runtime Web script and WASM
assets from jsDelivr. That keeps the SDK simple to drop into React Native Web,
but production apps that require tighter supply-chain control or CDN outage
isolation should self-host those files and set ortWasmPath to that directory.
Use generate() when you want audio data back without playing it immediately.
import { KittenTTS } from '@kittentts/react-native';
const tts = await KittenTTS.create(undefined, (progress, info) => {
if (info?.stage === 'cached') {
console.log('model is already cached');
return;
}
console.log(`setup ${Math.round(progress * 100)}%`);
});
const result = await tts.generate('Hello from KittenTTS on React Native.');
console.log(result.duration);
console.log(result.wordTimings);
console.log(result.wavBase64());
await tts.dispose();result.wavBase64() returns a complete WAV file encoded as base64. You can save
it, upload it, or hand it to your own audio pipeline.
import * as ExpoAudio from 'expo-audio';
import { KittenTTS, createExpoAudioPlayer } from '@kittentts/react-native';
const tts = await KittenTTS.create({
player: createExpoAudioPlayer(ExpoAudio),
});
await tts.speak('This plays through expo-audio.');
await tts.dispose();import Sound from 'react-native-sound';
import { KittenTTS, createRNSoundPlayer } from '@kittentts/react-native';
const tts = await KittenTTS.create({
player: createRNSoundPlayer(Sound),
});
await tts.speak('This plays through react-native-sound.');
await tts.dispose();The first KittenTTS.create() downloads the selected model, voices.npz, and
phonemizer files. Later calls reuse the device cache.
On web, the cache is stored through the browser Cache API when available and
falls back to memory storage.
Default model cache:
<DocumentDirectory>/KittenTTS/<model>/
Default phonemizer cache:
<DocumentDirectory>/KittenTTS/CEPhonemizer/
To avoid a first-run download, see bundled offline assets.