Skip to content

Instantly share code, notes, and snippets.

@mateuszbaluch
Last active September 4, 2016 11:49
Show Gist options
  • Select an option

  • Save mateuszbaluch/bd611849f7eae1a43eb7c8798b492245 to your computer and use it in GitHub Desktop.

Select an option

Save mateuszbaluch/bd611849f7eae1a43eb7c8798b492245 to your computer and use it in GitHub Desktop.
public void onVoiceActivation(View view) {
Intent recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "pl_PL");
recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, view.getContext().getPackageName());
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
this.speech.startListening(recognizerIntent);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
this.speech.stopListening();
}
}, 5000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment