Skip to content

Commit

Permalink
feat(useSpeechRecognition): support maxAlternatives option (#4067)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkc918 authored Jul 17, 2024
1 parent 5f58470 commit 9eda885
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/core/useSpeechRecognition/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export interface UseSpeechRecognitionOptions extends ConfigurableWindow {
* @default 'en-US'
*/
lang?: MaybeRefOrGetter<string>
/**
* A number representing the maximum returned alternatives for each result.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/maxAlternatives
* @default 1
*/
maxAlternatives?: number
}

/**
Expand All @@ -42,6 +49,7 @@ export function useSpeechRecognition(options: UseSpeechRecognitionOptions = {})
const {
interimResults = true,
continuous = true,
maxAlternatives = 1,
window = defaultWindow,
} = options

Expand Down Expand Up @@ -74,6 +82,7 @@ export function useSpeechRecognition(options: UseSpeechRecognitionOptions = {})
recognition.continuous = continuous
recognition.interimResults = interimResults
recognition.lang = toValue(lang)
recognition.maxAlternatives = maxAlternatives

recognition.onstart = () => {
isFinal.value = false
Expand Down

0 comments on commit 9eda885

Please sign in to comment.