File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -103,14 +103,16 @@ function App() {
103
103
console .log (" error code:" , event .error , " error messsage:" , event .message );
104
104
});
105
105
106
- const handleStart = () => {
107
- ExpoSpeechRecognitionModule .requestPermissionsAsync ().then ((result ) => {
106
+ const handleStart = async () => {
107
+ try {
108
+ const result =
109
+ await ExpoSpeechRecognitionModule .requestPermissionsAsync ();
108
110
if (! result .granted ) {
109
111
console .warn (" Permissions not granted" , result );
110
112
return ;
111
113
}
112
114
// Start speech recognition
113
- ExpoSpeechRecognitionModule .start ({
115
+ await ExpoSpeechRecognitionModule .start ({
114
116
lang: " en-US" ,
115
117
interimResults: true ,
116
118
maxAlternatives: 1 ,
@@ -119,12 +121,14 @@ function App() {
119
121
addsPunctuation: false ,
120
122
contextualStrings: [" Carlsen" , " Nepomniachtchi" , " Praggnanandhaa" ],
121
123
});
122
- });
124
+ } catch (error ) {
125
+ console .error (" Error starting speech recognition:" , error );
126
+ }
123
127
};
124
128
125
129
return (
126
130
<View >
127
- { recognizing ? (
131
+ { ! recognizing ? (
128
132
<Button title = " Start" onPress = { handleStart } />
129
133
) : (
130
134
<Button title = " Stop" onPress = { ExpoSpeechRecognitionModule .stop } />
You can’t perform that action at this time.
0 commit comments