Beispiel #1
0
 public async Task StopListening()
 {
     if (_continuousRecognitionSession != null)
     {
         if (await _continuousRecognitionSession.CancelContinuousRecognitionAsync())
         {
             _continuousRecognitionSession.Dispose();
             _continuousRecognitionSession = null;
         }
     }
 }
Beispiel #2
0
        public async Task <string> Listen()
        {
            using (var sttService = new SttService())
            {
                await sttService.AddConstraintAsync(ConstraintsDictionnary.GetConstraintForSpeak());

                var result = await sttService.RecognizeAsync();

                return(result.Text);
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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");
            }
        }