jamsch/expo-speech-recognition

Speech Recognition for React Native Expo projects

What is this?

expo-speech-recognition is a library that lets React Native apps (built with Expo) understand spoken words. It works on iOS, Android, and web by tapping into each platform's built-in speech recognition system:

  • iOS: SFSpeechRecognizer
  • Android: SpeechRecognizer
  • Web: the standard Web Speech API

The main goal is code reuse — you write your speech-recognition logic once, and it works across all three platforms without rewriting it for each one.

How do you use it?

  1. Install it with npm (the README shows commands for different Expo SDK versions).
  2. Configure a plugin in your app.json file. This plugin automatically adds the required permissions to your Android and iOS apps (microphone access, speech recognition access, and Android package visibility for Google's speech service).
  3. Create a development build — if you're new to Expo and haven't generated native ios/ and android/ folders yet, you'll need to run npx expo run:android and npx expo run:ios once.

Core usage patterns

1. Hooks (easiest)

The library provides a React hook called useSpeechRecognitionEvent that lets you listen to events like:

  • start — recognition began
  • end — recognition stopped
  • result — a word or phrase was recognized (you get the transcript)
  • error — something went wrong

You start recognition with ExpoSpeechRecognitionModule.start({ lang: "en-US", interimResults: true, continuous: false }) and stop it with .stop().

2. Permissions

Before starting, you should request permissions using requestPermissionsAsync(). If the user denies, you'll get an error event with code not-allowed. You can also check current permission status with getPermissionsAsync().

3. Direct module API

For more control, you can use the module directly:

  • addListener("eventName", callback) — register event listeners
  • start(options) — begin recognition with many configurable options
  • stop() — stop and get a final result
  • abort() — cancel immediately without processing

What can you configure when starting?

The start() method accepts a rich options object, including:

  • Language (lang) — e.g., "en-US"
  • Interim results — show partial results as you speak
  • Continuous mode — keep listening until you stop (vs. stopping after a pause)
  • On-device recognition — don't send audio over the network (if supported)
  • Punctuation — add commas and full stops automatically
  • Contextual strings — custom words unique to your app (e.g., chess player names)
  • Android-specific options — like silence length, offensive-word masking, and which recognition service to use
  • iOS-specific options — like audio session category and voice-processing settings
  • Recording options — save the audio to a file (useful for later transcription)
  • Audio source — transcribe an existing audio file instead of live microphone input
  • Volume change events — get notified when input volume changes

Events you can listen to

The library fires events similar to the Web Speech API:

Event What it means
start Recognition started — tell the user to speak
audiostart / audioend Audio capture began / ended (includes file URI if recording was persisted)
speechstart / speechend Sound / speech detected / stopped
result A word or phrase was recognized (includes transcript, confidence, segments)
nomatch No significant recognition happened
error An error occurred (includes error code and message)
end Service disconnected — always the last event
volumechange Input volume changed (value between -2 and 10; below 0 is inaudible)
languagedetection Language detection results (Android 14+ only)

Other notable features

  • Persisting audio recordings — save the microphone input to a file (Android 13+ and iOS)
  • Transcribing audio files — pass a local audio file URI to audioSource and get a transcript
  • Volume metering — enable volumeChangeEventOptions to get volume updates
  • Polyfilling the Web SpeechRecognition API — can act as a drop-in replacement for the web API
  • Muting the beep sound on Android — suppress the default beep
  • Improving accuracy of single-word prompts — options to help with short commands
  • Language detection — Android 14+ with Google's assistant service

API methods (summary)

The README lists many methods, including:

  • start(), stop(), abort() — control recognition
  • requestPermissionsAsync(), getPermissionsAsync() — permission handling (plus separate microphone and speech-recognizer variants)
  • getStateAsync() — current recognition state
  • getSupportedLocales() — available languages
  • getSpeechRecognitionServices(), getDefaultRecognitionService(), getAssistantService() — Android-only service discovery
  • isRecognitionAvailable(), supportsOnDeviceRecognition(), supportsRecording() — capability checks
  • androidTriggerOfflineModelDownload() — download offline models on Android
  • iOS audio session methods — setCategoryIOS(), getAudioSessionCategoryAndOptionsIOS(), setAudioSessionActiveIOS()

Platform compatibility

The README includes a platform compatibility table (not shown in full here), but the library explicitly targets iOS, Android, and web. Some features are platform-specific — for example, languagedetection is Android 14+ only, and speechend is not yet supported on iOS.

Troubleshooting

The README has sections for common Android and iOS issues, but the details aren't included in the excerpt.


In short: This is a cross-platform speech recognition library for React Native/Expo apps. It wraps each platform's native speech APIs behind a unified JavaScript interface, so you can add voice input to your app once and have it work everywhere.

Related

  • Project
  • Project
  • Project
  • Project
  • Project