0

I'm trying to develop game that using voice command to access main menu. I want to ask how to hide tap to speak interface from google speech? Because it almost cover all my screen.

  • I haven't tried anything to hide it since I'm new on this – Yoshua Rudy Jan 02 '16 at 16:58
  • 1
    Possible duplicate of [How can I use speech recognition without the annoying dialog in android phones](http://stackoverflow.com/questions/6316937/how-can-i-use-speech-recognition-without-the-annoying-dialog-in-android-phones) – Nikolay Shmyrev Jan 02 '16 at 18:49

1 Answers1

-1

Call promptSpeechInput() to start the speech recognition activity. Catch the results with onActivityResult(),

/**
 * Showing google speech input dialog
 * */
private void promptSpeechInput() {
    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
    intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
            getString(R.string.speech_prompt));
    try {
        startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
    } catch (ActivityNotFoundException a) {
        Toast.makeText(getApplicationContext(),
                getString(R.string.speech_not_supported),
                Toast.LENGTH_SHORT).show();
    }
}

/**
 * Receiving speech input
 * */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
    case REQ_CODE_SPEECH_INPUT: {
        if (resultCode == RESULT_OK && null != data) {

            ArrayList<String> result = data
                    .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            txtSpeechInput.setText(result.get(0));
        }
        break;
    }

    }
}

For example, from a button:

 speechRecButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            promptSpeechInput();
        }
    });

For more specific information: http://www.androidhive.info/2014/07/android-speech-to-text-tutorial/

  • I get that from the same link that you provided. My problem is I want to hide tap to speak interface that cover my screen after I press the mic icon – Yoshua Rudy Jan 02 '16 at 17:00
  • This answer is showing the interface/dialog .. @YoshuaRudy has asked to hide it. – Nitesh Verma Dec 30 '16 at 07:58