Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Speech to Text Example

I've looked at the Android example for VoiceRecognition, but I don't really understand what it is suppose to do or how it works. In the manifest there isn't any sort of main activity to run and so when I install the app on my phone I can't run it.

I'm also trying to find a simple example of Speech to text that takes speech as input and outputs the text on the screen. Just so I can study it to see how it works, but I haven't been able to find any sort of example on the web that shows it.

like image 677
Palagerini Avatar asked Aug 03 '12 05:08

Palagerini


People also ask

How will you convert text into voice in Android briefly explain with examples?

Go to the app -> res -> layout -> activity_main. xml section and set the layout for the app. In this file add an EditText to input the text from the user, a Button, so whenever the user clicks on the Button then it's converted to speech and a TextView to display the GeeksforGeeks text.

Is there a speech to text app for Android?

Using Google's backend, SpeechTexter allows you to create SMS messages, text notes, emails, and tweets with your own voice. The easy-to-use app supports over 70 languages and has a better than 90% accuracy rate. You can customize your own commands for punctuation as well.


1 Answers

I did it like that:

in onCreate:

List<ResolveInfo> activities = pm.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);

In the method starting the voice recognition:

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Voice recognition Demo...");
startActivityForResult(intent, REQUEST_CODE);

onActivityResult:

protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK)
    {
        // Populate the wordsList with the String values the recognition engine thought it heard
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
    }
}

Hope I'm not missing anything, been a time since. Drop me a note if something doesn't work. About the text output: I'm sure you can handle that once you have a populated matches array.

like image 195
Cdr. Powell Avatar answered Oct 21 '22 07:10

Cdr. Powell