Android Speech to Text - Androhub

Speech To Text

Android Speech to Text

Android comes with an inbuilt feature speech to text through which you can provide speech input to your app. With this you can add some of the cool features to your app like adding voice navigation(Helpful when you are targeting disabled people), filling a form with voice input etc.,

In the background how voice input works is, the speech input will be streamed to a server, on the server voice will be converted to text and finally text will be sent back to our app.

If you want to do the other way i.e converting text to speech, follow my tutorial Android Text to Speech

Example

In this tutorial, we are going to learn how to use convert Speech/Voice to Text.

Video Demo

1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details. By default my activity is MainActivity.java.

2. First create a layout in xml file naming activity_main.xml that contains Button for starting voice recognition and a ListView to display the result.

3. Now open your MainActivity.java and add the following lines. There are only two steps by which we can achieve our goal :

Step 1: Starting RecognizerIntent

First we need to create a RecognizerIntent by setting necessary flags such as :

  • ACTION_RECOGNIZE_SPEECH – Simply takes user’s speech input and returns it to same activity.
  • LANGUAGE_MODEL_FREE_FORM – Considers input in free form English.
  • EXTRA_PROMPT – Text prompt to show to the user when asking them to speak.

Step 2: Receiving the speech response
Once the speech input is done we have to catch the response in onActivityResult and take appropriate action needed.

Note : Before doing anything we have to check if the device support Speech Reocgnizer or not.

4. Now, you are all done, run your app and you will get the output as shown in video.

Thanks. :)

 

1 Comment

cabot
Sunday, August 26th, 2018

Thanks for this helpful tutorial it was very detailed and to the point.
Here is a related video you can take a look at it to see how you can turn text to video: https://youtu.be/L94717pI14M

Post comment

Your email address will not be published. Required fields are marked *