public async Task StopListening() { if (_continuousRecognitionSession != null) { if (await _continuousRecognitionSession.CancelContinuousRecognitionAsync()) { _continuousRecognitionSession.Dispose(); _continuousRecognitionSession = null; } } }
public async Task <string> Listen() { using (var sttService = new SttService()) { await sttService.AddConstraintAsync(ConstraintsDictionnary.GetConstraintForSpeak()); var result = await sttService.RecognizeAsync(); return(result.Text); } }
private static async Task <SpeechRecognitionResult> RecognitionWithFallBack(SttService sttService) { SpeechRecognitionResult result; do { result = await sttService.RecognizeAsync(); if (result.Confidence == SpeechRecognitionConfidence.Rejected) { await TtsService.SayAsync(SpeechDictionnary.GetNotUnderstoodSentence()); } else { break; } } while (true); return(result); }
public async Task <string> AskIdentified() { using (var sttService = new SttService()) { await TtsService.SayAsync("Veux tu t'identifier ?"); await sttService.AddConstraintAsync(ConstraintsDictionnary.ConstraintForYes, false); await sttService.AddConstraintAsync(ConstraintsDictionnary.ConstraintForNo); var result = await sttService.RecognizeAsync(); if (result.Confidence != SpeechRecognitionConfidence.Rejected) { var firedConstraint = (SpeechRecognitionListConstraint)result.Constraint; return(firedConstraint.Commands.First()); } return("non"); } }