#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Using AI to Power Voice Assistants in Mobile Apps

Say "remind me to pay the electricity bill on Friday" to a banking or utility app, and five things happen in a second or two: the app records audio, converts it to text, works out what you want and the details (a reminder, the bill, Friday), performs the action, and replies in a spoken voice. Each of those steps uses a different kind of AI, and each can run on the phone or in the cloud. Following that one request through the app is the clearest way to see how voice assistants are built.

Using AI to Power Voice Assistants in Mobile Apps

Using AI to Power Voice Assistants in Mobile Apps

Step 1: capture audio

The app needs the microphone permission (RECORD_AUDIO on Android, a microphone and speech-recognition usage description on iOS) and a clear way to start listening, usually a mic button. Always-on wake words such as "Hey Google" are handled by the operating system; third-party apps normally use push-to-talk, which is also better for privacy and battery.

Step 2: speech to text (ASR)

Automatic speech recognition turns audio into text. You have three broad choices:

OptionExamplesTrade-offs
Built-in platform recognisersAndroid SpeechRecognizer; iOS Speech frameworkFree to call, easy to add; limited control; language support depends on the device
Cloud APIsGoogle Cloud Speech-to-Text, Azure AI Speech, Amazon Transcribe, OpenAI's transcription APIStrong accuracy and many languages; costs per minute; audio leaves the device
Open models on device or your serverOpenAI Whisper and its smaller variants; Indian-language models from AI4BharatFull control and privacy; you handle performance, model size and updates

For Indian users, test with real accents, background noise and code-mixed speech ("kal ka reminder set karo for 9 am"). The Government of India's Bhashini platform and AI4Bharat's open models are worth evaluating for Hindi and other Indian languages.

Here is the built-in Android route in Kotlin:

class VoiceActivity : AppCompatActivity() {
    private lateinit var recognizer: SpeechRecognizer

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        recognizer = SpeechRecognizer.createSpeechRecognizer(this)
        recognizer.setRecognitionListener(object : RecognitionListener {
            override fun onResults(results: Bundle?) {
                val text = results
                    ?.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION)
                    ?.firstOrNull() ?: return
                handleCommand(text)
            }
            override fun onError(error: Int) {
                speak("Sorry, I didn't catch that.")
            }
            override fun onReadyForSpeech(params: Bundle?) {}
            override fun onBeginningOfSpeech() {}
            override fun onRmsChanged(rmsdB: Float) {}
            override fun onBufferReceived(buffer: ByteArray?) {}
            override fun onEndOfSpeech() {}
            override fun onPartialResults(partialResults: Bundle?) {}
            override fun onEvent(eventType: Int, params: Bundle?) {}
        })
    }

    // Call after the RECORD_AUDIO permission is granted
    fun startListening() {
        val intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
            putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                     RecognizerIntent.LANGUAGE_MODEL_FREE_FORM)
            putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-IN")
        }
        recognizer.startListening(intent)
    }

    override fun onDestroy() {
        recognizer.destroy()
        super.onDestroy()
    }
}

On Android 12 and later, SpeechRecognizer.createOnDeviceSpeechRecognizer() requests recognition without sending audio to a server, where the device supports it. On iOS, SFSpeechRecognizer has a requiresOnDeviceRecognition option for the same purpose.

Step 3: understand the request

Text is not yet an action. The app must find the intent (what the user wants) and the slots (the details). For "remind me to pay the electricity bill on Friday": intent = create_reminder, task = "pay the electricity bill", date = next Friday.

Approach A: rules or a small classifier

For an app with a handful of commands, simple matching is fast, free and predictable:

fun handleCommand(raw: String) {
    val text = raw.lowercase()
    val reminder = Regex("""remind me to (.+?) (?:on|at|by) (.+)""").find(text)
    when {
        "balance" in text -> showBalance()
        reminder != null -> {
            val (task, time) = reminder.destructured
            createReminder(task, time)   // parse "friday" or "9 am" separately
        }
        else -> speak("You can say: check balance, or remind me to ...")
    }
}

For more commands and varied phrasing, train a small intent classifier on example sentences, or use a dialogue framework such as Rasa.

Approach B: a language model with tool calling

Large language models handle open-ended phrasing well. You describe the actions your app supports as "tools" (functions with a JSON schema), and the model returns which tool to call with which arguments:

{
  "name": "create_reminder",
  "description": "Create a reminder for the user",
  "parameters": {
    "type": "object",
    "properties": {
      "task": { "type": "string" },
      "datetime": { "type": "string", "description": "ISO 8601 date-time" }
    },
    "required": ["task", "datetime"]
  }
}

Your app, not the model, then runs create_reminder after validating the arguments. Never let a model trigger payments or other sensitive actions without an explicit on-screen confirmation, and keep the API key on your server, not inside the app.

Step 4: perform the action and reply

After the action, give a short confirmation: "Done. I'll remind you on Friday at 9 a.m. to pay the electricity bill." Read the important details back so the user can catch recognition errors. For speech output, Android provides TextToSpeech and iOS provides AVSpeechSynthesizer; cloud neural voices sound more natural but add cost and latency.

Step 5: connect to the system assistant (optional)

Instead of, or as well as, an in-app mic, you can let users reach your app through the phone's assistant. On Android this is done with App Actions declared in shortcuts.xml; on iOS with the App Intents framework, which exposes actions to Siri and Shortcuts.

Design rules for voice in apps

  • Show what was heard. Display the recognised text so users can see mistakes.
  • Keep a screen fallback. Voice should be a shortcut, never the only way to do something.
  • Handle silence and noise. Time out politely and suggest example commands.
  • Confirm before irreversible steps such as sending money or deleting data.
  • Be clear about privacy. Say whether audio is processed on the device or sent to a server, and do not store recordings by default.

Measuring quality

Track word error rate on a test set of real recordings, the share of requests that map to the right intent, and how often users give up and switch to typing. Test on low-cost phones and slow networks, not only on a flagship device.

To build a prototype quickly, try making your own voice assistant in Python first, then move the ideas to mobile. For browser-based apps, see how to add AI voice features to web applications. A related project is a voice translation mobile app, and if you plan to run models on the phone, compare lightweight AI models for mobile.

Sources: Android Developers (SpeechRecognizer, RecognizerIntent, TextToSpeech, App Actions); Apple Developer (Speech framework, AVSpeechSynthesizer, App Intents); OpenAI Whisper repository; Bhashini (Government of India); AI4Bharat (IIT Madras).

Placed Students

Our Clients

Partners

...