Playback controls
Speak text and control synthesis with stop, pause, resume, and isSpeaking.
Speaking text
Speak a given text using the current global settings, or provide per-utterance options:
Speech.speak(text: string): Promise<string>
Speech.speak(text: string, options: VoiceOptions): Promise<string>The promise resolves with a unique utterance ID (string) as soon as the utterance is queued. Use it to filter events for this specific speech operation.
const id = await Speech.speak('Hello, world!');
// Track events specific to this utterance
Speech.onFinish(({id: eventId}) => {
if (eventId === id) {
console.log('Speech finished');
}
});Per-utterance options override the global configuration for that utterance only:
const id2 = await Speech.speak('Hello!', {
language: 'en-US',
pitch: 1.5,
rate: 0.8,
});
// Track events specific to this utterance
Speech.onProgress(({id: eventId, location, length}) => {
if (eventId === id2) {
console.log(`Progress: ${location}/${length}`);
}
});Text length limit
The Speech.maxInputLength constant is the maximum number of characters allowed in a single call to the speak methods. Android enforces this limit (determined by TextToSpeech.getMaxSpeechInputLength); iOS has no synthesis system limit, so the speech class returns Number.MAX_VALUE there.
If your text exceeds this limit, you must manually split it into smaller utterances on the JavaScript side. Calls that exceed the limit are rejected — see Troubleshooting.
Speaking text with custom options (deprecated)
Speech.speakWithOptions(text: string, options: VoiceOptions): Promise<string>speakWithOptions is deprecated. Use Speech.speak(text, options) instead.
Controlling speech
Stop speech
Immediately stops any ongoing or queued speech synthesis:
Speech.stop(): Promise<void>Speech.stop().then(() => console.log('Speech stopped'));Pause speech
Pauses the current speech at the next word boundary. On Android, API 26+ (Android 8+) is required.
Speech.pause(): Promise<boolean>Speech.pause().then(isPaused => {
console.log(isPaused ? 'Speech paused' : 'Nothing to pause');
});Resume speech
Resumes previously paused speech. On Android, API 26+ (Android 8+) is required.
Speech.resume(): Promise<boolean>Speech.resume().then(isResumed => {
console.log(isResumed ? 'Speech resumed' : 'Nothing to resume');
});Check if speaking
Determine if speech synthesis is currently active:
Speech.isSpeaking(): Promise<boolean>Speech.isSpeaking().then(isSpeaking => {
console.log(isSpeaking ? 'Currently speaking or paused' : 'Not speaking');
});