From 1917bc19e0cb2be8903a70f6751378525a7a3e49 Mon Sep 17 00:00:00 2001 From: Cogent Apps <127109874+cogentapps@users.noreply.github.com> Date: Mon, 20 Mar 2023 08:36:20 -0700 Subject: [PATCH] possible fix for speech recognition on android --- app/src/components/input.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/components/input.tsx b/app/src/components/input.tsx index 1fe52c4..e41dd77 100644 --- a/app/src/components/input.tsx +++ b/app/src/components/input.tsx @@ -137,8 +137,10 @@ export default function MessageInput(props: MessageInputProps) { speechRecognition.onresult = (event) => { let transcript = ''; - for (let i = 0; i < event.results.length; ++i) { - transcript += event.results[i][0].transcript; + for (let i = 0; i < event.results.length; i++) { + if (event.results[i].isFinal && event.results[i][0].confidence) { + transcript += event.results[i][0].transcript; + } } dispatch(setMessage(initialMessage + ' ' + transcript)); }; @@ -279,4 +281,4 @@ export default function MessageInput(props: MessageInputProps) { ; -} \ No newline at end of file +}