Question · Dictation on phones and tablets
How do you add speech to text to an Android or iOS app?
Use the speech recognizer your phone system already provides. On iPhone and iPad, add Apple's Speech framework, ask for permission, and request on-device recognition when audio must stay on the phone. On Android, use SpeechRecognizer, check for an on-device recognizer first, and test each language, because offline support depends on the device and the language.
Updated October 17, 20265 min read8 cited facts, each traced to its source
Use the speech recognizer that ships with each phone system. On iOS, that is Apple's Speech framework. On Android, it is the SpeechRecognizer class. Both turn microphone audio into text through a few calls, once the user grants permission. The decision that matters is where the audio goes, and that depends on the API you pick, the language and the device. Choose the route your privacy rule allows first, then write the code.
On iPhone, the Speech framework does the recognition
Apple offers two routes. The older SFSpeechRecognizer class handles live audio and audio files. The newer SpeechAnalyzer class, which Apple's reference lists for iOS 26 and later, adds on-device transcription through its transcriber module. Use SpeechAnalyzer when your minimum iOS version allows it. Use SFSpeechRecognizer when you must support earlier versions.
For SFSpeechRecognizer, the steps are these.
- Add NSSpeechRecognitionUsageDescription to your Info.plist. Apple's key reference says the key is required when an app uses APIs that send user data to Apple's speech recognition servers. If the app also records from the microphone, add NSMicrophoneUsageDescription as well.
- Call requestAuthorization before any other speech work. The system shows the prompt, using the text you wrote in the key.
- Create an SFSpeechRecognizer for one language and check its isAvailable value before you start a task.
- If audio must stay on the phone, check supportsOnDeviceRecognition, then set requiresOnDeviceRecognition on the request. Apple says that without on-device support the recognizer needs a connection 1. Apple also says on-device requests are less accurate 2.
- Start a task with an audio buffer request for live microphone audio, or a URL request for a file. Apple says the framework stops tasks that run longer than one minute 3, so plan for a task that ends and restart it cleanly.
The newer SpeechAnalyzer keeps transcription on the phone, after a download
SpeechAnalyzer is the better fit for private dictation, because transcription runs on the device once the language models are downloaded 4. Apple's guide also separates the two routes on privacy. It says the permission process covers SFSpeechRecognizer, and that transcriber modules do not send voice audio to Apple's servers 5. Expect a first-run delay while the models download, and show the user a progress message.
On Android, the standard recognizer may use a server
The standard Android route is the SpeechRecognizer class. The Android reference warns that the implementation of the API is likely to stream audio to remote servers 6. A default recognizer is therefore not an offline choice, so do not assume the audio stays on the device.
The steps, in order, are these.
- Request the RECORD_AUDIO permission at run time. The SpeechRecognizer reference says the app must have that permission to use the class.
- Call SpeechRecognizer.isOnDeviceRecognitionAvailable first. It reports whether an on-device speech recognition service is available on the system 7.
- If the check returns true, create the recognizer with createOnDeviceSpeechRecognizer. The reference says that factory method throws an UnsupportedOperationException when the check returns false, so never call it without the check.
- If the check returns false, tell the user that the audio may go to a server, or use an offline engine.
- Set a RecognitionListener on the main application thread, and call destroy() when the session ends, as the reference requires.
If you start recognition from an intent rather than the class, the EXTRA_PREFER_OFFLINE extra asks the recognizer to use only an offline engine. By default, either network or offline engines may be used, and depending on the recognizer, the extra may have no effect 8. When offline matters, rely on the on-device check, not the extra.
Offline engines and cloud APIs are the fallbacks
When the platform service cannot give you the behavior you need, two options remain. Vosk is an open-source engine whose homepage says it works offline on lightweight devices, including Android and iOS. Your app ships the model, so you trade app size for control over the languages you cover. A cloud speech API sends audio to a server, which means a network connection and an account with the provider. Compare accuracy and price on our speech-to-text API comparison before you choose one.
Where the audio goes depends on the route, the language and the device
The table compares the routes. Read it as a checklist, because support depends on the language and the device, so test each one rather than trust a row.
| Route | Works without a connection? | Where the audio goes | What to check |
|---|---|---|---|
| SFSpeechRecognizer with on-device requested (iOS) | Only when the recognizer supports on-device recognition 1 | Stays on the phone when the setting is honored | Lower accuracy 2 and a time limit 3 |
| SpeechAnalyzer transcriber (iOS 26 and later) | Yes, after the language models download 4 | Not sent to Apple's servers 5 | The first-run model download |
| SpeechRecognizer default (Android) | Not assured | May be streamed to remote servers 6 | Whether an on-device service exists |
| On-device SpeechRecognizer (Android) | Yes, where the availability check is true 7 | On the device | Each language you need |
| Vosk or another offline engine | Yes, once the model is in the app | On the device | Model size and language coverage |
| Cloud speech API | No | On the provider's servers | Provider terms and retention |
Test the build offline before you ship it
Test on real devices, not only in the simulator. Use this sequence.
- Turn on airplane mode, with Wi-Fi off, on a test phone.
- Run recognition in each language your app supports, with a sentence that has a number, a name and a comma.
- Record a long passage to see where the time limit ends the task, and show the user what happens next.
- Deny the permission once, and check that the app explains the problem and turns off the microphone button.
A consumer can run the same airplane test on a phone without writing code, using the steps in our offline voice typing guide.
Choose the route your privacy rule allows, then test it
Start with the rule, not the API you know best. If audio must never leave the phone, use SpeechAnalyzer on iOS 26 and later, and an on-device recognizer on Android where the check passes. If a cloud service is acceptable, say so in your privacy notice. For the user side of these questions, read whether iPhone dictation is private and whether iPhone dictation works offline. For a list of offline apps on Android, see the best offline speech to text app for Android.
The terms used here are explained in our entries on on-device speech recognition and automatic speech recognition. For the wider overview, see dictation on phones and tablets.
Evidence
Every number on this page, with where it comes from. Open a fact to see the exact words in its source.
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
Go deeper
Related questions
- Does iPhone dictation work offline?
- Is iPhone dictation private?
- What is the best offline speech to text app for Android?
- Can iPhone dictation understand two languages at once?
- Can you dictate in Hindi and other Indian languages on iPhone?
- Can you dictate in Microsoft Word on iPhone, iPad or Android?
- Can you use Gboard voice typing on iPhone?
- Can you use talk to text on a flip phone?