public void StartSpeechRecognition() { StopService(); try { if (ContextCompat.CheckSelfPermission(Android.App.Application.Context, Manifest.Permission.RecordAudio) != Android.Content.PM.Permission.Granted) { ActivityCompat.RequestPermissions(CrossCurrentActivity.Current.Activity, new[] { Manifest.Permission.RecordAudio }, 0); } else { if (_speechRecognizer == null) { _speechRecognizer = SpeechRecognizer.CreateSpeechRecognizer(Android.App.Application.Context); _speechRecognizer.PartialResults += _speechRecognizer_PartialResults; _speechRecognizer.Results += _speechRecognizer_Results; _speechRecognizer.Error += _speechRecognizer_Error; } var intent = new Android.Content.Intent(RecognizerIntent.ActionRecognizeSpeech); intent.PutExtra(RecognizerIntent.ExtraLanguagePreference, "de"); intent.PutExtra(RecognizerIntent.ExtraCallingPackage, Android.App.Application.Context.PackageName); intent.PutExtra(RecognizerIntent.ExtraPartialResults, true); intent.PutExtra(RecognizerIntent.ExtraMaxResults, 2); intent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500); intent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500); intent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 1500); _speechRecognizer.StartListening(intent); } } catch (Exception) { } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); mWork = new Work(this); mAdditional = new Additional(this); Text_Title = FindViewById <TextView>(Resource.Id.textView1); Text_Speech = FindViewById <TextView>(Resource.Id.textView2); Text_Information = FindViewById <TextView>(Resource.Id.textView3); Text_Error = FindViewById <TextView>(Resource.Id.textView4); image = FindViewById <ImageView>(Resource.Id.imageView1); recButton = FindViewById <Button>(Resource.Id.btnRecord); sr = SpeechRecognizer.CreateSpeechRecognizer(this); sr.SetRecognitionListener(this); recButton.Click += delegate { if (!RecordingOn) { RecordingOn = true; speech_recognition(); } }; }
//bool isRun = false; //private TextView txt_view; //private ProgressBar processbar; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //SetContentView(Resource.Layout.Layout_SpeechRecognizingActivity); //Button btn_speech = (Button)FindViewById(Resource.Id.btn_start); //txt_view = (TextView)FindViewById(Resource.Id.txtSpeech); //processbar = (ProgressBar)FindViewById(Resource.Id.progress); // Create your application here speech = SpeechRecognizer.CreateSpeechRecognizer(this); speech.SetRecognitionListener(this); Intent recognizerIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); recognizerIntent.PutExtra(RecognizerIntent.ExtraLanguagePreference, "en-US"); recognizerIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 50000); recognizerIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500); recognizerIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 50000); recognizerIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1); recognizerIntent.PutExtra(RecognizerIntent.ExtraPartialResults, true); //btn_speech.Click += delegate //{ // isRun = !isRun; // speech.StartListening(recognizerIntent); //}; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); var BtnStartSpeech = FindViewById <Button>(Resource.Id.btn_start_speech); BtnStartSpeech.Click += BtnStartSpeech_Click; var recListener = new RecognitionListener(); recListener.BeginSpeech += RecListener_BeginSpeech; recListener.EndSpeech += RecListener_EndSpeech; recListener.Error += RecListener_Error; recListener.Ready += RecListener_Ready; recListener.Recognized += RecListener_Recognized; Recognizer = SpeechRecognizer.CreateSpeechRecognizer(this); Recognizer.SetRecognitionListener(recListener); SpeechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); SpeechIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, PackageName); }
protected override void OnResume() { base.OnResume(); FakeSessionDelete = new FakeSessionDelete(); database = new SQLiteRepository(); userRepo = new UserRepository(database); contactRepo = new ContactRepository(database); configRepo = new ConfigRepository(database); database.CreateDatabase(); loginService = new LoginService(); contactService = new ContactService(); errorText = new ErrorText(); if (_continue) { speechReco = SpeechRecognizer.CreateSpeechRecognizer(this.ApplicationContext); speechReco.SetRecognitionListener(this); intentReco = new Intent(RecognizerIntent.ActionRecognizeSpeech); intentReco.PutExtra(RecognizerIntent.ExtraLanguagePreference, "es"); intentReco.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName); intentReco.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelWebSearch); intentReco.PutExtra(RecognizerIntent.ExtraMaxResults, 1); toSpeech = new TextToSpeech(this, this); } }
private void BeginProcessing() { SpeechRecognizer recognizer = SpeechRecognizer.CreateSpeechRecognizer(this); recognizer.PartialResults += Recognizer_PartialResults; recognizer.Results += Recognizer_Results; recognizer.Error += (sender, args) => { Console.WriteLine(args.Error.ToString()); }; previousResultTimestamp = DateTime.UtcNow; Intent recognizerIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); recognizerIntent.PutExtra(RecognizerIntent.ExtraPartialResults, true); recognizerIntent.PutExtra(RecognizerIntent.ExtraLanguage, "de-DE"); recognizer.StartListening(recognizerIntent); new Handler(Looper.MyLooper()).PostDelayed(() => { if (DateTime.UtcNow.Subtract(previousResultTimestamp).TotalSeconds > 3) { BeginProcessing(); } }, 3500); }
protected override void OnResume() { base.OnResume(); nomusuario.Click += delegate { StopItems(); }; tipo.Click += delegate { StopItems(); }; velocidad.Click += delegate { StopItems(); }; activacion.Click += delegate { StopItems(); }; loginService = new LoginService(); userService = new UserService(); try { client = loginService.Connect(); if (client.IsUserAuthorized()) { usuario = client.Session.TLUser; } } catch (Exception ex) { this.FinishAffinity(); } database = new SQLiteRepository(); userRepository = new UserRepository(database); configRepository = new ConfigRepository(database); errorText = new ErrorText(); configuracion = configRepository.GetConfig(); speechReco = SpeechRecognizer.CreateSpeechRecognizer(this.ApplicationContext); speechReco.SetRecognitionListener(this); intentReco = new Intent(RecognizerIntent.ActionRecognizeSpeech); intentReco.PutExtra(RecognizerIntent.ExtraLanguagePreference, "es"); intentReco.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName); intentReco.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelWebSearch); intentReco.PutExtra(RecognizerIntent.ExtraMaxResults, 1); toSpeech = new TextToSpeech(this, this); gestureDetector = new GestureDetector(this); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.JsonFileReader = new JsonFileReader(); this.SpeechRecognizer = SpeechRecognizer.CreateSpeechRecognizer(this); this.SpeechRecognizer.Results += SpeechRecognizerOnResults; }
void StartRecognizer() { _speechRecognizer = SpeechRecognizer.CreateSpeechRecognizer(Application.Context); platformService.SetAudioEnabled(_firstInit); _speechRecognizer.SetRecognitionListener(this); _speechRecognizer.StartListening(VoiceIntent); }
void startover() { _speech.Destroy(); _speech = SpeechRecognizer.CreateSpeechRecognizer(this._context); _speech.SetRecognitionListener(this); _speechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1000); _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1000); _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 1500); StartListening(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); var BtnStartSpeech = FindViewById <Android.Widget.Button>(Resource.Id.btn_start_game); BtnStartSpeech.Click += BtnStartSpeech_Click; var recListener = new RecognitionListener(); recListener.BeginSpeech += RecListener_BeginSpeech; recListener.EndSpeech += RecListener_EndSpeech; recListener.Error += RecListener_Error; recListener.Ready += RecListener_Ready; recListener.Recognized += RecListener_Recognized; Recognizer = SpeechRecognizer.CreateSpeechRecognizer(this); Recognizer.SetRecognitionListener(recListener); SpeechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); SpeechIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, PackageName); //Debug Button //var BtnEndSpeech = FindViewById<Android.Widget.Button>(Resource.Id.btn_end_speech); //BtnEndSpeech.Click += BtnEndSpeech_Click; //BtnEndSpeech.Visibility = Android.Views.ViewStates.Invisible; var BtnGetOut = FindViewById <Android.Widget.Button>(Resource.Id.btn_GetOut); BtnGetOut.Click += BtnGetOut_Click; var BtnClearOut = FindViewById <Android.Widget.Button>(Resource.Id.btn_Clear); BtnClearOut.Click += BtnClearOut_Click; var txtYourScore = FindViewById <Android.Widget.EditText>(Resource.Id.YourScore); txtYourScore.Click += txtYourScore_Click; var BtnSeeOutChart = FindViewById <Android.Widget.Button>(Resource.Id.btn_SeeOutChart); BtnSeeOutChart.Click += delegate { StartActivity(typeof(OutChartActivity)); }; Log.Debug(nameof(AndroidActivity), nameof(OnCreate)); mList.Add("Start"); Forms.Init(this, savedInstanceState); mAudioManager = (AudioManager)GetSystemService(Context.AudioService); }
private async Task <int> listenRequest() { _speech = SpeechRecognizer.CreateSpeechRecognizer(_context); _speech.SetRecognitionListener(this); _tcs = new TaskCompletionSource <Java.Lang.Object>(); try{ _speech.StartListening(_stt.IntentSTT()); } catch (Exception e) {} return((int)await _tcs.Task); }
private void InitializeSpeechRecognizer() { _speechRecognizer = SpeechRecognizer.CreateSpeechRecognizer(this); _speechRecognizer.Error += SpeechRecognizerOnError; _speechRecognizer.Results += SpeechRecognizerOnResults; _speechRecognizer.ReadyForSpeech += SpeechRecognizerOnReadyForSpeech; _speechRecognizerIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); _speechRecognizerIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); _speechRecognizerIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if (!isOnline()) { mErrorDialog.Show(); return; } SetContentView(Resource.Layout.activity_get_started); mLocationManager = GetSystemService(LocationService) as LocationManager; mTts = new TextToSpeech(this, this, "com.google.android.tts"); speech = SpeechRecognizer.CreateSpeechRecognizer(this); speech.SetRecognitionListener(this); Criteria mLocationServiceCriteria = new Criteria { Accuracy = Accuracy.Coarse, PowerRequirement = Power.Medium }; IList <string> acceptableLocationProviders = mLocationManager.GetProviders(mLocationServiceCriteria, true); if (acceptableLocationProviders.Any()) { mLocationProvider = acceptableLocationProviders.First(); } else { mLocationProvider = string.Empty; } mSharedPreference = GetSharedPreferences(Constants.MY_PREF, 0); token = mSharedPreference.GetString("token", " "); mEditor = mSharedPreference.Edit(); mLoadingDialog = new LoadingDialog(this, Resource.Drawable.main); mLoadingDialog.SetCancelable(false); Window window = mLoadingDialog.Window; window.SetLayout(WindowManagerLayoutParams.MatchParent, WindowManagerLayoutParams.MatchParent); window.SetBackgroundDrawable(new ColorDrawable(Resources.GetColor(Resource.Color.trans))); SpannableString s = new SpannableString("Contoso Cabs"); typeface = Typeface.CreateFromAsset(this.Assets, "JosefinSans-SemiBold.ttf"); s.SetSpan(new TypefaceSpan("Amaranth-Regular.ttf"), 0, s.Length(), SpanTypes.ExclusiveExclusive); s.SetSpan(new ForegroundColorSpan(this.Resources.GetColor(Resource.Color.title)), 0, s.Length(), SpanTypes.ExclusiveExclusive); this.TitleFormatted = s; mGetStarted = FindViewById <Button>(Resource.Id.btnGetStarted); mUri = FindViewById <Button>(Resource.Id.btnuri); mSpeak = FindViewById <ImageView>(Resource.Id.imagespeech); mTextView = FindViewById <TextView>(Resource.Id.bookText); mTextView.SetTypeface(typeface, TypefaceStyle.Normal); mGetStarted.SetTypeface(typeface, TypefaceStyle.Normal); mGetStarted.SetOnClickListener(this); mUri.SetOnClickListener(this); mSpeak.SetOnClickListener(this); }
public CustomRecognizer(Context _context) { this._context = _context; Words = ""; _speech = SpeechRecognizer.CreateSpeechRecognizer(this._context); _speech.SetRecognitionListener(this); _speechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); _speechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); _speechIntent.PutExtra(RecognizerIntent.ActionRecognizeSpeech, RecognizerIntent.ExtraPreferOffline); _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1000); _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1000); _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 1500); }
void RestartRecognizer() { lock (SyncLock) { AndroidRecognizer?.SetRecognitionListener(null); AndroidRecognizer?.Destroy(); AndroidRecognizer?.Dispose(); AndroidRecognizer = SpeechRecognizer.CreateSpeechRecognizer(Application.Context); AndroidRecognizer.SetRecognitionListener(this); AndroidRecognizer.StartListening(CreateIntent()); } }
static Task DoStart() { if (AndroidRecognizer == null) { StandardListener = new RecognitionListener(); AndroidRecognizer = SpeechRecognizer.CreateSpeechRecognizer(UIRuntime.NativeRootScreen as AndroidOS.BaseActivity); AndroidRecognizer.SetRecognitionListener(StandardListener); AndroidRecognizer.StartListening(CreateIntent()); IsStopped = false; } return(Task.CompletedTask); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Context context = this; // initilize the speech recognizer sr = SpeechRecognizer.CreateSpeechRecognizer(this); sr.SetRecognitionListener(this); if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean) { AudioManager am = (AudioManager)Application.Context.GetSystemService(Context.AudioService); am.SetStreamMute(Stream.Music, true); } //// initilize the intent //intent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); //intent.PutExtra(RecognizerIntent.ExtraCallingPackage, Application.Context.PackageName); //intent.PutExtra(RecognizerIntent.ExtraPartialResults, true); //intent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500); //intent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500); //intent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 180000000); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); recButton = FindViewById <Button>(Resource.Id.btnRecord); textBox = FindViewById <TextView>(Resource.Id.textYourText); recButton.Click += RecButton_Click; // check to see if we can actually record - if we can, assign the event to the button string rec = Android.Content.PM.PackageManager.FeatureMicrophone; if (rec != "android.hardware.microphone") { // no microphone, no recording. Disable the button and output an alert var alert = new AlertDialog.Builder(recButton.Context); alert.SetTitle("You don't seem to have a microphone to record with"); alert.SetPositiveButton("OK", (sender, e) => { textBox.Text = "No microphone present"; recButton.Enabled = false; return; }); alert.Show(); } }
private void CreateSpeechRecognizer() { mSpeechRecognizer = SpeechRecognizer.CreateSpeechRecognizer(this); mSpeechRecognizerIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, Application.PackageName); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraPrompt, "Speak now"); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 2000); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 2000); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 1500); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default); mSpeechRecognizer.SetRecognitionListener(this); }
public void Start() { speechRecognizer = SpeechRecognizer.CreateSpeechRecognizer(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity); speechRecognizer.SetRecognitionListener(this); var intent = new Intent(RecognizerIntent.ActionRecognizeSpeech); intent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); intent.PutExtra(RecognizerIntent.ExtraMaxResults, 1); intent.PutExtra(RecognizerIntent.ExtraPartialResults, true); intent.PutExtra(RecognizerIntent.ExtraCallingPackage, Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity.PackageName); intent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500); intent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500); intent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000); speechRecognizer.StartListening(intent); }
private void RecButton_Click(object sender, System.EventArgs e) { if (recButton.Text == "Start Recording") { recButton.Text = "End Recording"; sr.StartListening(this.CreateSpeechIntent()); } else { recButton.Text = "Start Recording"; sr.Destroy(); sr = SpeechRecognizer.CreateSpeechRecognizer(this); sr.SetRecognitionListener(this); //sr.StopListening(); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Create your application here mSpeechRecognizer = SpeechRecognizer.CreateSpeechRecognizer(this); mSpeechRecognizerIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, PackageName); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraPrompt, GetString(Resource.String.VoiceCommandsDesc)); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, this.Resources.Configuration.Locale.Language); mSpeechRecognizerIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 5); Button StartListening = FindViewById <Button>(Resource.Id.Startlisning); StartListening.Click += StartListening_Click; }
public async Task Speak() { Recognizer = SpeechRecognizer.CreateSpeechRecognizer(_activity.Activity); Recognizer.SetRecognitionListener(this); SpeechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); //SpeechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500); //SpeechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500); //SpeechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 1500); SpeechIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 2); SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); SpeechIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, _activity.Activity.PackageName); await StartListening(); }
protected override void OnResume() { base.OnResume(); b.Click += delegate { StopItems(); StartActivity(typeof(Enviar)); }; b2.Click += delegate { StopItems(); StartActivity(typeof(MisChats)); }; b3.Click += delegate { StopItems(); StartActivity(typeof(MisContactos)); }; b4.Click += delegate { StopItems(); StartActivity(typeof(Configuracion)); }; logout.Click += delegate { count = 1; record = true; textToSpeak = "¿Está seguro que quiere cerrar la sesión? Hasta dentro de 2 horas no podrá volverse a loguear con el mismo número de teléfono."; toSpeech = new TextToSpeech(this, this); }; speechReco = SpeechRecognizer.CreateSpeechRecognizer(this.ApplicationContext); speechReco.SetRecognitionListener(this); intentReco = new Intent(RecognizerIntent.ActionRecognizeSpeech); intentReco.PutExtra(RecognizerIntent.ExtraLanguagePreference, "es"); intentReco.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName); intentReco.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelWebSearch); intentReco.PutExtra(RecognizerIntent.ExtraMaxResults, 1); toSpeech = new TextToSpeech(this, this); gestureDetector = new GestureDetector(this); }
public void OnError([GeneratedEnum] SpeechRecognizerError error) { Android.Util.Log.WriteLine(Android.Util.LogPriority.Debug, "OnError:", error.ToString()); //sr.StopListening(); //sr.StartListening(intent); if (error == Android.Speech.SpeechRecognizerError.NoMatch) { sr.StartListening(this.CreateSpeechIntent()); } else if (error == Android.Speech.SpeechRecognizerError.SpeechTimeout) { sr.Destroy(); sr = SpeechRecognizer.CreateSpeechRecognizer(this); sr.SetRecognitionListener(this); sr.StartListening(this.CreateSpeechIntent()); } }
private void StartRecordingAndRecognizing() { var recListener = new RecognitionListener(); recListener.BeginSpeech += RecListener_BeginSpeech; recListener.EndSpeech += RecListener_EndSpeech; recListener.Error += RecListener_Error; recListener.Ready += RecListener_Ready; recListener.Recognized += RecListener_Recognized; Recognizer = SpeechRecognizer.CreateSpeechRecognizer(Android.App.Application.Context); Recognizer.SetRecognitionListener(recListener); SpeechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech); SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); SpeechIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, Android.App.Application.Context.PackageName); Recognizer.StartListening(SpeechIntent); }
private void StartRecordingAndRecognizing() { var recListener = new RecognitionListener(); recListener.BeginSpeech += RecListener_BeginSpeech; recListener.EndSpeech += RecListener_EndSpeech; recListener.Error += RecListener_Error; recListener.Ready += RecListener_Ready; recListener.Recognized += RecListener_Recognized; Recognizer = SpeechRecognizer.CreateSpeechRecognizer(_activity.BaseContext); Recognizer.SetRecognitionListener(recListener); SpeechIntent = new Intent(RecognizerIntent.ActionVoiceSearchHandsFree); SpeechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); SpeechIntent.PutExtra(RecognizerIntent.ExtraCallingPackage, _activity.PackageName); Recognizer.StartListening(SpeechIntent); }
public override bool OnKeyUp(Keycode keyCode, KeyEvent e) { if (keyCode == Keycode.Headsethook) { if (ButtonCount < 1) { TimeSpan tt = new TimeSpan(0, 0, 1); Device.StartTimer(tt, TestHandleFunc); } ButtonCount++; } if (keyCode == Keycode.VolumeDown) { sr = SpeechRecognizer.CreateSpeechRecognizer(this); Intent intent = new Intent(RecognizerIntent.ActionRecognizeSpeech); intent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); intent.PutExtra(RecognizerIntent.ExtraCallingPackage, "this package"); intent.PutExtra(RecognizerIntent.ExtraMaxResults, 5); sr.StartListening(intent); //sr.SetRecognitionListener(RecognitionListener); StartActivityForResult(intent, VOICE); } if (keyCode == Keycode.VolumeUp) { sr = SpeechRecognizer.CreateSpeechRecognizer(this); sr.SetRecognitionListener(listener); Intent intent = new Intent(RecognizerIntent.ActionRecognizeSpeech); intent.PutExtra(RecognizerIntent.ExtraLanguage, "en-US"); intent.PutExtra(RecognizerIntent.ExtraPreferOffline, true); intent.PutExtra(RecognizerIntent.ExtraPrompt, "CHADCS Is Listening"); intent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm); intent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.English); intent.PutExtra(RecognizerIntent.ExtraCallingPackage, "this package"); intent.PutExtra(RecognizerIntent.ExtraMaxResults, 5); sr.StartListening(intent); StartActivityForResult(intent, VOICE); } return(true); /* base.OnKeyUp(keyCode, e); */ }
protected void InitializeRecognizer() { lock (speechRecognizerLock) { if (speechRecognizer != null) { speechRecognizer.Destroy(); speechRecognizer = null; } speechRecognizer = SpeechRecognizer.CreateSpeechRecognizer(context); speechRecognizer.ReadyForSpeech += SpeechRecognizer_ReadyForSpeech; speechRecognizer.RmsChanged += SpeechRecognizer_RmsChanged; speechRecognizer.EndOfSpeech += SpeechRecognizer_EndOfSpeech; speechRecognizer.Results += SpeechRecognizer_Results; speechRecognizer.Error += SpeechRecognizer_Error; } }
protected override void OnResume() { base.OnResume(); database = new SQLiteRepository(); contactRepository = new ContactRepository(database); configRepository = new ConfigRepository(database); configuracion = configRepository.GetConfig(); errorText = new ErrorText(); speechReco = SpeechRecognizer.CreateSpeechRecognizer(this.ApplicationContext); speechReco.SetRecognitionListener(this); intentReco = new Intent(RecognizerIntent.ActionRecognizeSpeech); intentReco.PutExtra(RecognizerIntent.ExtraLanguagePreference, "es"); intentReco.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName); intentReco.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelWebSearch); intentReco.PutExtra(RecognizerIntent.ExtraMaxResults, 1); gestureDetector = new GestureDetector(this); toSpeech = new TextToSpeech(this, this); }