possible fix for speech recognition on android

main
Cogent Apps 2023-03-20 08:36:20 -07:00 committed by GitHub
parent ac2a40f382
commit 1917bc19e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -137,8 +137,10 @@ export default function MessageInput(props: MessageInputProps) {
speechRecognition.onresult = (event) => { speechRecognition.onresult = (event) => {
let transcript = ''; let transcript = '';
for (let i = 0; i < event.results.length; ++i) { for (let i = 0; i < event.results.length; i++) {
transcript += event.results[i][0].transcript; if (event.results[i].isFinal && event.results[i][0].confidence) {
transcript += event.results[i][0].transcript;
}
} }
dispatch(setMessage(initialMessage + ' ' + transcript)); dispatch(setMessage(initialMessage + ' ' + transcript));
}; };