This commit is contained in:
n4ze3m
2024-05-25 13:46:42 +05:30
parent f9f48109c2
commit d5f7d0a470
6 changed files with 30 additions and 26 deletions

View File

@@ -48,6 +48,7 @@ type SpeechRecognitionHook = {
stop: () => void
supported: boolean
transcript: string
resetTranscript: () => void
}
const useEventCallback = <T extends (...args: any[]) => any>(
@@ -88,6 +89,10 @@ export const useSpeechRecognition = (
}
}, [])
const resetTranscript = () => {
setLiveTranscript("")
}
const processResult = (event: SpeechRecognitionEvent) => {
const transcript = Array.from(event.results)
.map((result) => result[0])
@@ -167,6 +172,7 @@ export const useSpeechRecognition = (
isListening: listening,
stop,
supported,
transcript: liveTranscript
transcript: liveTranscript,
resetTranscript
}
}