Your browser does not support SpeechRecognition API, more details

useSpeechRecognition

Reactive SpeechRecognition.

Can I use?

Usage

import { useSpeechRecognition } from '@vueuse/core'

const {
  isSupported,
  isListening,
  isFinal,
  result,
  start,
  stop
} = useSpeechRecognition()

Options

The following shows the default values of the options, they will be directly passed to SpeechRecognition API.

{
  lang: 'en-US',
  interimResults: true,
  continuous: true,
}

Type Declarations

export interface SpeechRecognitionOptions extends ConfigurableWindow {
  /**
   * Controls whether continuous results are returned for each recognition, or only a single result.
   *
   * @default true
   */
  continuous?: boolean
  /**
   * Controls whether interim results should be returned (true) or not (false.) Interim results are results that are not yet final
   *
   * @default true
   */
  interimResults?: boolean
  /**
   * Langauge for SpeechRecognition
   *
   * @default 'en-US'
   */
  lang?: string
}
/**
 * Reactive SpeechRecognition.
 *
 * @link /useSpeechRecognition
 * @link https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition|SpeechRecognition
 * @param options
 */
export declare function useSpeechRecognition(
  options?: SpeechRecognitionOptions
): {
  isSupported: boolean
  isListening: Ref<boolean>
  isFinal: Ref<boolean>
  recognition: SpeechRecognition | undefined
  result: Ref<string>
  error: Ref<SpeechRecognitionErrorEvent | undefined>
  toggle: (value?: boolean) => void
  start: () => void
  stop: () => void
}

Source

SourceDemoDocs