Search code examples
androidspeech-recognitionvoice

Hide Google Voice recognition


I'm using Google Voice recognition and would like to hide the popup with Google and the mic that is being shown.. This is my code:

Intent intent = new Intent(
                    RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

            intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, getResources().getString(R.string.ttslang));

            try {
                startActivityForResult(intent, RESULT_SPEECH);
            } catch (ActivityNotFoundException a) {
                Toast t = Toast.makeText(getApplicationContext(),
                        getResources().getString(R.string.notts),
                        Toast.LENGTH_SHORT);
                t.show();
            }

As I think that I already saw such apps, I think that this is possible.. If it is, does somebody know how?

Many thanks!


Solution

  • For that, you need to use SpeechRecognizer. An example can be found here.

    It's quite easy to implement:

    SpeechRecognizer recognizer = SpeechRecognizer.createSpeechRecognizer(this);       
    recognizer.setRecognitionListener(new RecognitionListener() { ... });  
    

    The listener catches the events and you process them accordingly.