Expo
Speech Recognition
Setting up expo-speech-recognition for useSpeechRecognition and the DocyrusAgent microphone button.
iOSAndroid
Overview
useSpeechRecognition and the DocyrusAgent mic button (DocyrusAgentChatInputMicButton / DocyrusAgentChatInputMic) use expo-speech-recognition. It is an optional peer: without it (and always in Expo Go, which cannot load its native code) the hook reports isSupported: false and the mic button is hidden, so the rest of the chat keeps working.
Installation
npx expo install expo-speech-recognitionRequired Packages(1 package)
pnpm add expo-speech-recognitionExpo Configuration
Add the config plugin, then create a development build (npx expo run:ios / eas build --profile development):
{
plugins: [
[
'expo-speech-recognition',
{
microphonePermission: 'Allow $(PRODUCT_NAME) to use the microphone for voice prompts.',
speechRecognitionPermission: 'Allow $(PRODUCT_NAME) to transcribe your voice prompts.'
}
]
]
}The plugin writes NSMicrophoneUsageDescription / NSSpeechRecognitionUsageDescription on iOS and RECORD_AUDIO on Android. Permissions are requested on the first start().
Behaviour
| Situation | isSupported | Mic button |
|---|---|---|
| Dev / production build with the module | true | Visible |
| Expo Go | false | Hidden |
| Module not installed | false | Hidden |
| Device reports recognition unavailable | false | Hidden |
| Permission denied | true (error = 'not-allowed') | Visible, recording doesn't start |