Skip to content

Commit f2bc688

Browse files
authored
docs: convert handleStart to async function
* Fix errors in speech recognition example code * Implement feedback: Remove unnecessary try-catch, adjust async handling for speech recognition
1 parent 960d403 commit f2bc688

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

README.md

+15-16
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,21 @@ function App() {
103103
console.log("error code:", event.error, "error messsage:", event.message);
104104
});
105105

106-
const handleStart = () => {
107-
ExpoSpeechRecognitionModule.requestPermissionsAsync().then((result) => {
108-
if (!result.granted) {
109-
console.warn("Permissions not granted", result);
110-
return;
111-
}
112-
// Start speech recognition
113-
ExpoSpeechRecognitionModule.start({
114-
lang: "en-US",
115-
interimResults: true,
116-
maxAlternatives: 1,
117-
continuous: false,
118-
requiresOnDeviceRecognition: false,
119-
addsPunctuation: false,
120-
contextualStrings: ["Carlsen", "Nepomniachtchi", "Praggnanandhaa"],
121-
});
106+
const handleStart = async () => {
107+
const result = await ExpoSpeechRecognitionModule.requestPermissionsAsync();
108+
if (!result.granted) {
109+
console.warn("Permissions not granted", result);
110+
return;
111+
}
112+
// Start speech recognition
113+
ExpoSpeechRecognitionModule.start({
114+
lang: "en-US",
115+
interimResults: true,
116+
maxAlternatives: 1,
117+
continuous: false,
118+
requiresOnDeviceRecognition: false,
119+
addsPunctuation: false,
120+
contextualStrings: ["Carlsen", "Nepomniachtchi", "Praggnanandhaa"],
122121
});
123122
};
124123

0 commit comments

Comments
 (0)