fn
useSpeechSynthesis
v0.0.15testeddemoReactive 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
| Parameter | Type | Description |
|---|---|---|
text | MaybeRefOrGetter<string> | The text to speak; rebuilds the utterance reactively |
options? | UseSpeechSynthesisOptions | Configuration options |
Returns
UseSpeechSynthesisReturnSupport flag, playing/status/error state, the reactive utterance, and speak/stop/toggle actions