SpeechRecognizer
SpeechRecognizer copied to clipboard
Hide Popup
Is there any way to hide or change the popup?
I am not sure.
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.
+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)
+1for hiding the pop up.