fn
useSpeechRecognition
v0.0.14testeddemoReactive wrapper around the Web Speech API SpeechRecognition for transcribing speech to text.
Examples
ts
const { isSupported, isListening, result, start, stop } = useSpeechRecognition({ lang: 'en-US' });
start();ts
// Toggle from a button, read the live transcript
const { result, isFinal, toggle } = useSpeechRecognition({ continuous: true });
watch(result, transcript => console.log(transcript));Demo
Loading demo…
Signature
ts
export function useSpeechRecognition(options: UseSpeechRecognitionOptions ={ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
options? | UseSpeechRecognitionOptions | Configuration options |
Returns
UseSpeechRecognitionReturnSupport flag, reactive listening/result/error state, and start/stop/toggle controls| Property | Type | Description |
|---|---|---|
isSupported | ComputedRef<boolean> | Whether the SpeechRecognition API is supported in the current environment. |
isListening | ShallowRef<boolean> | Whether recognition is currently active. Writable: setting it starts/stops
the recognizer, mirroring start() / stop(). |
isFinal | Readonly<ShallowRef<boolean>> | Whether the latest result is final (true) or interim (false). |
result | Readonly<ShallowRef<string>> | Transcript of the most recent recognition result. |
confidence | Readonly<ShallowRef<number>> | Confidence (0-1) the engine has in the most recent result. |
error | ShallowRef<SpeechRecognitionErrorEvent | Error | undefined> | The most recent error, or undefined when none. |
recognition | SpeechRecognition | undefined | The underlying SpeechRecognition instance, or undefined when unsupported. |
start | () => void | Start listening. |
stop | () => void | Stop listening. |
toggle | (value?: boolean) => void | Toggle listening. Pass a boolean to force a state. |