File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
packages/core/useSpeechRecognition Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ export function useSpeechRecognition(options: UseSpeechRecognitionOptions = {})
5656 const isListening = shallowRef ( false )
5757 const isFinal = shallowRef ( false )
5858 const result = shallowRef ( '' )
59- const error = shallowRef < SpeechRecognitionErrorEvent | undefined > ( undefined )
59+ const error = shallowRef < SpeechRecognitionErrorEvent | Error | undefined > ( undefined )
6060
6161 let recognition : SpeechRecognition | undefined
6262
@@ -120,10 +120,17 @@ export function useSpeechRecognition(options: UseSpeechRecognitionOptions = {})
120120 if ( newValue === oldValue )
121121 return
122122
123- if ( newValue )
124- recognition ! . start ( )
125- else
126- recognition ! . stop ( )
123+ try {
124+ if ( newValue ) {
125+ recognition ! . start ( )
126+ }
127+ else {
128+ recognition ! . stop ( )
129+ }
130+ }
131+ catch ( err ) {
132+ error . value = err as unknown as Error
133+ }
127134 } )
128135 }
129136
You can’t perform that action at this time.
0 commit comments