Search code examples
androidspeech-recognitionspeech-to-textvoice-recognition

Speech Recognition without default Activity/Intent


I'm currently using the below code to acquire speech on my phone:

Intent intent = new Intent( RecognizerIntent.ACTION_RECOGNIZE_SPEECH );

          intent.putExtra( RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault() );
          intent.putExtra( RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM );
          intent.putExtra( RecognizerIntent.EXTRA_PROMPT, "Say something..." );

          try
          {
            startActivityForResult( intent, RESULT_SPEECH );
          }

This works really well except I'd like to be able to get speech using my own screens. The above code displays a default Android activity of some sort. What I would like to do is display my own activity with a list of search results and be able to spell out the letters until I match what I want.

For example:

  1. Press a button to enable speech acquisition
  2. Acquire one letter, say "S"
  3. Acquire another letter, say "T"
  4. As I go I would display a list of search results such as [ST]ar Wars

How can acquire speech without using a default/system activity so that I can do this on my own screens?


Solution

  • Found out how. This post was an excellent step in the right direction.

    I just needed to implement RecognitionListener.