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(); } }
void StopRecognizer() { _speechRecognizer?.StopListening(); _speechRecognizer?.Cancel(); _speechRecognizer?.Destroy(); _speechRecognizer = null; CancelDialog(); }
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; } }
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(); }
void StopRecognizer() { Mvx.Resolve <IMvxMainThreadDispatcher>().RequestMainThreadAction(() => { _speechRecognizer?.StopListening(); _speechRecognizer?.Cancel(); _speechRecognizer?.Destroy(); _speechRecognizer = null; CancelDialog(); }); }