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/useSpeechRecognition.md
1---2category: Sensors3---45# useSpeechRecognition67Reactive [SpeechRecognition](https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition).89> [Can I use?](https://caniuse.com/mdn-api_speechrecognitionevent)1011## Usage1213```ts14import { useSpeechRecognition } from '@vueuse/core'1516const {17isSupported,18isListening,19isFinal,20result,21start,22stop,23} = useSpeechRecognition()24```2526### Options2728The following shows the default values of the options, they will be directly passed to [SpeechRecognition API](https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition).2930```ts31import { useSpeechRecognition } from '@vueuse/core'32// ---cut---33useSpeechRecognition({34lang: 'en-US',35interimResults: true,36continuous: true,37})38```3940## Type Declarations4142```ts43export interface UseSpeechRecognitionOptions extends ConfigurableWindow {44/**45* Controls whether continuous results are returned for each recognition, or only a single result.46*47* @default true48*/49continuous?: boolean50/**51* Controls whether interim results should be returned (true) or not (false.) Interim results are results that are not yet final52*53* @default true54*/55interimResults?: boolean56/**57* Language for SpeechRecognition58*59* @default 'en-US'60*/61lang?: MaybeRefOrGetter<string>62/**63* A number representing the maximum returned alternatives for each result.64*65* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/maxAlternatives66* @default 167*/68maxAlternatives?: number69}70export interface UseSpeechRecognitionReturn extends Supportable {71isListening: ShallowRef<boolean>72isFinal: ShallowRef<boolean>73recognition: SpeechRecognition | undefined74result: ShallowRef<string>75error: ShallowRef<SpeechRecognitionErrorEvent | Error | undefined>76toggle: (value?: boolean) => void77start: () => void78stop: () => void79}80/**81* Reactive SpeechRecognition.82*83* @see https://vueuse.org/useSpeechRecognition84* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition SpeechRecognition85* @param options86*/87export declare function useSpeechRecognition(88options?: UseSpeechRecognitionOptions,89): UseSpeechRecognitionReturn90```91