Getting started
-
Install it.
Terminal window npx expo install expo-sttOn iOS it compiles, but speech recognition has not been tested on a device yet.
-
Add the config plugin. Both texts are optional.
app.json {"expo": {"plugins": [["expo-stt", {"microphonePermission": "Dictate notes","speechRecognitionPermission": "Turn speech into text"}]]}} -
Build the app. The module has native code, so it does not run in Expo Go.
Terminal window npx expo run:iosnpx expo run:android -
Listen.
import { listen, SpeechError } from 'expo-stt';try {const { transcript } = await listen();} catch (error) {console.warn(SpeechError.from(error).code);}
Requirements
Section titled “Requirements”Expo SDK 58 or newer: iOS 16.4, Android 7, or a browser with the Web Speech API.
Bare React Native
Section titled “Bare React Native”Install Expo modules, add NSMicrophoneUsageDescription and NSSpeechRecognitionUsageDescription to Info.plist, and run npx pod-install. Android needs no configuration.
Which API to use
Section titled “Which API to use”| You want | Use |
|---|---|
| One phrase: a search, an answer | listen() |
| A screen that shows what is said | useSpeechRecognition() |
| A button to hold while talking | useHoldToTalk() |
| Full control outside of React | start(), addListener() |