R
fn

useSpeechSynthesis

v0.0.15testeddemo

Reactive wrapper around the Web Speech `SpeechSynthesis` API for text-to-speech.

Examples

ts
const { speak, stop, isPlaying } = useSpeechSynthesis('Hello world', { lang: 'en-US', rate: 1.2 });
speak();
ts
// Reactive text and voice
const text = ref('Initial');
const { speak, status } = useSpeechSynthesis(text, { pitch: 1.5 });
text.value = 'Updated';
speak();

Demo

Loading demo…

Signature

ts
export function useSpeechSynthesis(
  text: MaybeRefOrGetter<string>,
  options: UseSpeechSynthesisOptions ={ ... }

Parameters

ParameterTypeDescription
textMaybeRefOrGetter<string>The text to speak; rebuilds the utterance reactively
options?UseSpeechSynthesisOptionsConfiguration options

Returns

UseSpeechSynthesisReturnSupport flag, playing/status/error state, the reactive utterance, and speak/stop/toggle actions