Skip to content

Commit 9eda885

Browse files
authored
feat(useSpeechRecognition): support maxAlternatives option (#4067)
1 parent 5f58470 commit 9eda885

File tree

1 file changed

+9
-0
lines changed
  • packages/core/useSpeechRecognition

1 file changed

+9
-0
lines changed

packages/core/useSpeechRecognition/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ export interface UseSpeechRecognitionOptions extends ConfigurableWindow {
2929
* @default 'en-US'
3030
*/
3131
lang?: MaybeRefOrGetter<string>
32+
/**
33+
* A number representing the maximum returned alternatives for each result.
34+
*
35+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition/maxAlternatives
36+
* @default 1
37+
*/
38+
maxAlternatives?: number
3239
}
3340

3441
/**
@@ -42,6 +49,7 @@ export function useSpeechRecognition(options: UseSpeechRecognitionOptions = {})
4249
const {
4350
interimResults = true,
4451
continuous = true,
52+
maxAlternatives = 1,
4553
window = defaultWindow,
4654
} = options
4755

@@ -74,6 +82,7 @@ export function useSpeechRecognition(options: UseSpeechRecognitionOptions = {})
7482
recognition.continuous = continuous
7583
recognition.interimResults = interimResults
7684
recognition.lang = toValue(lang)
85+
recognition.maxAlternatives = maxAlternatives
7786

7887
recognition.onstart = () => {
7988
isFinal.value = false

0 commit comments

Comments
 (0)