From 75471d0c6e146b1bf55917885d681d53ac6ff7ee Mon Sep 17 00:00:00 2001 From: STECHNO Date: Tue, 17 Sep 2024 23:56:38 +0500 Subject: [PATCH 1/2] Fix errors in speech recognition example code --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f091fe0..2eacfb2 100644 --- a/README.md +++ b/README.md @@ -103,14 +103,16 @@ function App() { console.log("error code:", event.error, "error messsage:", event.message); }); - const handleStart = () => { - ExpoSpeechRecognitionModule.requestPermissionsAsync().then((result) => { + const handleStart = async () => { + try { + const result = + await ExpoSpeechRecognitionModule.requestPermissionsAsync(); if (!result.granted) { console.warn("Permissions not granted", result); return; } // Start speech recognition - ExpoSpeechRecognitionModule.start({ + await ExpoSpeechRecognitionModule.start({ lang: "en-US", interimResults: true, maxAlternatives: 1, @@ -119,12 +121,14 @@ function App() { addsPunctuation: false, contextualStrings: ["Carlsen", "Nepomniachtchi", "Praggnanandhaa"], }); - }); + } catch (error) { + console.error("Error starting speech recognition:", error); + } }; return ( - {recognizing ? ( + {!recognizing ? (