Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useSpeechSynthesis.md
1---2category: Sensors3---45# useSpeechSynthesis67Reactive [SpeechSynthesis](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis).89> [Can I use?](https://caniuse.com/mdn-api_speechsynthesis)1011## Usage1213```ts14import { useSpeechSynthesis } from '@vueuse/core'1516const {17isSupported,18isPlaying,19status,20voiceInfo,21utterance,22error,23stop,24toggle,25speak,26} = useSpeechSynthesis()27```2829### Options3031The following shows the default values of the options, they will be directly passed to [SpeechSynthesis API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis).3233```ts34import { useSpeechSynthesis } from '@vueuse/core'35// ---cut---36useSpeechSynthesis({37lang: 'en-US',38pitch: 1,39rate: 1,40volume: 1,41})42```4344## Type Declarations4546```ts47export type UseSpeechSynthesisStatus = "init" | "play" | "pause" | "end"48export interface UseSpeechSynthesisOptions extends ConfigurableWindow {49/**50* Language for SpeechSynthesis51*52* @default 'en-US'53*/54lang?: MaybeRefOrGetter<string>55/**56* Gets and sets the pitch at which the utterance will be spoken at.57*58* @default 159*/60pitch?: MaybeRefOrGetter<SpeechSynthesisUtterance["pitch"]>61/**62* Gets and sets the speed at which the utterance will be spoken at.63*64* @default 165*/66rate?: MaybeRefOrGetter<SpeechSynthesisUtterance["rate"]>67/**68* Gets and sets the voice that will be used to speak the utterance.69*/70voice?: MaybeRef<SpeechSynthesisVoice>71/**72* Gets and sets the volume that the utterance will be spoken at.73*74* @default 175*/76volume?: MaybeRefOrGetter<SpeechSynthesisUtterance["volume"]>77/**78* Callback function that is called when the boundary event is triggered.79*/80onBoundary?: (event: SpeechSynthesisEvent) => void81}82export interface UseSpeechSynthesisReturn extends Supportable {83isPlaying: ShallowRef<boolean>84status: ShallowRef<UseSpeechSynthesisStatus>85utterance: ComputedRef<SpeechSynthesisUtterance>86error: ShallowRef<SpeechSynthesisErrorEvent | undefined>87stop: () => void88toggle: (value?: boolean) => void89speak: () => void90}91/**92* Reactive SpeechSynthesis.93*94* @see https://vueuse.org/useSpeechSynthesis95* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis SpeechSynthesis96*/97export declare function useSpeechSynthesis(98text: MaybeRefOrGetter<string>,99options?: UseSpeechSynthesisOptions,100): UseSpeechSynthesisReturn101```102