Skip to content

Instantly share code, notes, and snippets.

@StephenVinouze
Created May 12, 2020 16:25
Show Gist options
  • Save StephenVinouze/8eca744bd7578df5833730db7ffe2a58 to your computer and use it in GitHub Desktop.
Save StephenVinouze/8eca744bd7578df5833730db7ffe2a58 to your computer and use it in GitHub Desktop.
val recognizerIntent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH).apply {
putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH)
putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, context.packageName)
putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, true)
}
}
speechRecognizer.startListening(recognizerIntent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment