SpeechRecognizer icon indicating copy to clipboard operation
SpeechRecognizer copied to clipboard

Hide Popup

Open joshglazer opened this issue 11 years ago • 4 comments

Is there any way to hide or change the popup?

joshglazer avatar Feb 19 '14 00:02 joshglazer

I am not sure.

poiuytrez avatar Feb 19 '14 13:02 poiuytrez

This doesn't help much with PhoneGap but I know in pure Android it's possible to do speech recognition without showing a dialogue box.

In this example I'm doing all the code in the main class, which extends RecognitionListener

public class MainActivity extends Activity implements RecognitionListener { ...

Inside that class you can instantiate a new Intent and create a SpeechRecognizer object.

private Intent speechIntent;
speechIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
speechIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
speechIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
speechIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, this.getPackageName());

private SpeechRecognizer speechInput;
speechInput = SpeechRecognizer.createSpeechRecognizer(this);
speechInput.setRecognitionListener(this);

The SpeechRecognizer object can then be told to listen like so.

speechInput.startListening(speechIntent);

Once results are detected they will be passed to a callback function called onResults, which is a requirement of implementing RecognitionListener

So, you can then pull the results out like this.

public void onResults(Bundle results) {
    ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);

    String spokenSentence = matches.get(0);
}

Hopefully that can help adding this feature.

alanjames1987 avatar Mar 30 '14 16:03 alanjames1987

+1 for hiding the window, it would be nice (in my case I need constant background speech recognition of a sequence of letters, showing each letter pronounced one by one)

ThomasDalla avatar Sep 13 '14 14:09 ThomasDalla

+1for hiding the pop up.

auxdesigner avatar Feb 14 '16 21:02 auxdesigner