Skip to content

Instantly share code, notes, and snippets.

@dev-aritra
Created August 25, 2018 15:00
Show Gist options
  • Save dev-aritra/826b77d11f29b4ae5c80e5e7b9cf3316 to your computer and use it in GitHub Desktop.
Save dev-aritra/826b77d11f29b4ae5c80e5e7b9cf3316 to your computer and use it in GitHub Desktop.
private void StartRecordingAndRecognizing()
{
string rec = global::Android.Content.PM.PackageManager.FeatureMicrophone;
if (rec == "android.hardware.microphone")
{
var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, "Speak now");
voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);
voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);
voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
_activity.StartActivityForResult(voiceIntent, VOICE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment