Adding voice input to Android apps with SpeechRecognizer

Android's SpeechRecognizer converts microphone audio into text using the platform's own speech services, so a team can add dictation, search-by-voice and hands-free commands without buying a commercial SDK. The API has belonged to the framework for years, it handles Australian English, and a clean implementation fits comfortably inside a single Activity or Fragment. Learn more about Androidtutorialpoint.com.

Australian conditions make that capability unusually useful. A courier crossing the harbour in Sydney, a tradie working a dusty site outside Wagga Wagga, or a nurse charting between rooms all benefit from speaking instead of typing. The country also has uneven mobile coverage, a famously warm conversational style and a wide spread of regional accents, all of which shape how a voice feature should be tested and tuned.

Why voice input suits Australian apps

Android's share of the Australian handset market runs higher than in most countries because cheaper devices from Samsung, Motorola and Google ship with Google services preinstalled, and Google Play is the default storefront. There is no meaningful alternative channel to publish into, so when a local delivery, ride-hailing or trades app adds a microphone feature, the audience is overwhelmingly Android users.

Daily routines reward hands-free input. Melbourne tram corridors, Brisbane bus routes and Sydney train lines run through crowded platforms where typing a suburb name is awkward; capturing "Paddington" in one breath turns a five-second task into two. Regional workers feel the same benefit, since at a cattle station near Moree or a mine site close to Kalgoorlie, gloves and dust make touching a screen unpleasant.

Competition adds the commercial case. Local apps compete against established operators on the same Play charts, and smaller teams often ship features faster. Voice can differentiate ordering, check-in and search flows, provided accuracy is honest and a typed fallback stays available whenever the microphone fails.

Preparing the project and permissions

The recogniser ships with Android, so dependencies stay light. Create a Kotlin project in Android Studio, add the usual AppCompat and material libraries, and target a recent API level. The framework imports are android.speech.SpeechRecognizer and RecognizerIntent.ACTION_RECOGNIZE_SPEECH, both stable for years and available without a third-party package.

Permissions are where first attempts break. INTERNET belongs in the manifest because recognition normally runs on Google's servers, and RECORD_AUDIO needs a runtime request before the microphone opens. On Android 11 and later, a queries entry for android.speech.RecognitionService is also required, otherwise the system can hide recognition entirely.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

<queries>
    <intent>
        <action android:name="android.speech.RecognitionService" />
    </intent>
</queries>

Treat the microphone as a sensitive capability: ask for permission in context, explain that audio is processed by a speech service, and never record outside the recognition session. Keep transcripts on infrastructure you control, such as a DigitalOcean Droplet with phpMyAdmin for MySQL, rather than loose files on the handset.

Connecting the recogniser to your activity

Create and drive the recogniser on the main thread, because calls from background workers throw exceptions. Attach a RecognitionListener, start listening with an intent that sets EXTRA_LANGUAGE_MODEL to LANGUAGE_MODEL_FREE_FORM, and pass en-AU through EXTRA_LANGUAGE so Australian English is preferred over an American voice.

The listener delivers five callbacks: onBeginningOfSpeech, onRmsChanged, onBufferReceived, onEndOfSpeech and onResults, with failures arriving through onError as codes such as ERROR_NO_MATCH, ERROR_SPEECH_TIMEOUT, ERROR_RECOGNIZER_BUSY and ERROR_NETWORK. Handling only the happy path is the classic mistake; a timeout on a windy Gold Coast beach should offer a retry, not a crash.

private val speech = SpeechRecognizer.createSpeechRecognizer(this)

private val listener = object : RecognitionListener {
    override fun onResults(results: Bundle?) {
        val spoken = results
            ?.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)
            ?.firstOrNull().orEmpty()
        if (spoken.isNotBlank()) handleUtterance(spoken)
    }

    override fun onError(error: Int) {
        showRetry(error)
    }
    // remaining callbacks omitted
}

Manage the lifecycle carefully: release the recogniser in onDestroy, cancel pending calls in onPause, and stop any existing session before starting a new one. The AndroidTutorialPoint walkthrough shows a minimal activity with the listener wired end to end for comparison.

Turning spoken words into actions

Recognition returns a ranked list of hypotheses, and the first entry is usually, but not always, correct. Read the top result, then fall back to the remaining entries when your matcher rejects it. Lower-case the text and strip punctuation so variations in phrasing still hit the same command.

Exact comparisons fail quickly here. People say "veggies", "sunnies", "bathers", "arvo" and "reckon" in daily conversation, so a command set written in tidy American English misses them. Maintain a synonym list or use edit distance with a small threshold, letting "yeah nah" resolve to a negative response and "g'day" to a greeting.

Confidence scores help you decide. The results bundle exposes a confidence value for each hypothesis on most devices, so accept a low-confidence result only when it matches a known command, and ask for clarification otherwise. Keep a typed fallback for accessibility and for locked-down corporate handsets with no working microphone.

Handling accents, slang and noisy streets

Australian English is non-rhotic, so "farm" and "film" sound different from US recordings, and regional varieties diverge further: a Darwin drawl, a Gold Coast weekend voice and Adelaide's clipped vowels are not interchangeable. Place names such as Woolloongabba, Toowoomba and Waterhouse often fail because they rarely appear in general training data.

Test with phrases that resemble real bookings: "Take me to the MCG for the footy", "flat white from Hoddle Street", "skip bin for a bathroom renovation in Geelong". Include local slang in the fixture list, along with cricket vocabulary such as "howzat", and measure accuracy against your own users rather than a synthetic reading.

Noise is the other half. Friday arvo chatter in a Brisbane pub, a tram bell in Melbourne and coastal wind all test a tolerant recogniser. Use the volume callback to show that the microphone is live, offer tap-to-stop for when the listener mishears, and capture a small set of real phrases each release to track accuracy.

Comparing speech input approaches

Recognition quality depends on the engine, so choose per use case. The options below differ in accuracy, latency and data use.

Approach Accuracy Latency Network Best for
SpeechRecognizer with free-form intent Good for Australian English Medium, network round trip Usually required Dictation, search, notes
SpeechRecognizer with on-device preference Moderate and improving Low once downloaded Download first, then offline Short commands, weak coverage areas
Platform voice assistant intents High for known actions Low Often online Navigation, media, timers
Commercial speech API or SDK Highest, with domain tuning Low to medium Required Call logging, regulated workflows
Typed fallback Exact for known values None Not needed Accessibility, silent places

A practical mix wins: free-form recognition for open input, an assistant intent for known actions, and a typed fallback for confirmation. Log anonymised results to your backend, where a phpMyAdmin view over the Droplet database makes it easy to spot the Australian words your matcher still misses.

Launching the feature with confidence

Build the smallest useful version first: one voice field, one command set, one screen. Test on handsets used in a regional suburb and on a busy city street, confirm the permission prompt appears only after a microphone tap, and run an internal build with a handful of testers before going wide.

Publish on Google Play with a plain-English privacy note covering microphone access and audio processing, and keep the typed fallback visible with an obvious way to cancel. Start from the sample activity, record your first hundred test phrases in Brisbane, Melbourne and Perth, and put one working voice flow in front of real users this month.