예제 #1
0
        public async Task <string> AskReason()
        {
            using (var sttService = new SttService())
            {
                await TtsService.SayAsync(SpeechDictionnary.GetReasonSentence());

                await sttService.AddConstraintAsync(ConstraintsDictionnary.ConstraintForCertification, false);

                await sttService.AddConstraintAsync(ConstraintsDictionnary.ConstraintForMeeting, false);

                await sttService.AddConstraintAsync(ConstraintsDictionnary.ConstraintForSandwichs, false);

                await sttService.AddConstraintAsync(ConstraintsDictionnary.ConstraintForOtherWords);

                var result = await sttService.RecognizeAsync();

                if (result.Confidence != SpeechRecognitionConfidence.Rejected)
                {
                    var firedConstraint = (SpeechRecognitionListConstraint)result.Constraint;
                    return(firedConstraint.Commands.First());
                }

                return("Autre");
            }
        }
예제 #2
0
        public async Task <string> AskNameAsync()
        {
            using (var sttService = new SttService())
            {
                bool   repeat;
                string name;

                do
                {
                    // --> 1 : Asking the name
                    await TtsService.SayAsync(SpeechDictionnary.GetAskNameSentence());

                    await sttService.AddConstraintAsync(ConstraintsDictionnary.GetConstraintForName());

                    var result = await RecognitionWithFallBack(sttService);

                    name = result.Text;

                    // Clean up stt service to clean constraints of prévious recognitions
                    await sttService.CleanConstraintsAsync();

                    // --> 3 : Asking confirmation for the name
                    await sttService.AddConstraintAsync(ConstraintsDictionnary.ConstraintForYes, false);

                    await sttService.AddConstraintAsync(ConstraintsDictionnary.ConstraintForNo, false);

                    await sttService.AddConstraintAsync(ConstraintsDictionnary.ConstraintForAbortWords);

                    await TtsService.SayAsync(SpeechDictionnary.GetYesOrNoSentence(result.Text));

                    result = await RecognitionWithFallBack(sttService);

                    var firedConstraint = (SpeechRecognitionListConstraint)result.Constraint;

                    switch (firedConstraint.Tag)
                    {
                    case "constraint_yes":
                        repeat = false;
                        break;

                    case "constraint_abord_words":
                        name   = null;
                        repeat = false;
                        break;

                    default:
                        repeat = true;
                        break;
                    }

                    await sttService.CleanConstraintsAsync();
                } while (repeat);

                return(name);
            }
        }
예제 #3
0
        public async Task SayHelloAsync(PersonDto[] persons)
        {
            if (persons == null)
            {
                return;
            }

            var listPersons = persons
                              .Select(p => p)
                              .Where(p => !string.IsNullOrEmpty(p.FirstName) && p.NbPasses <= 1)
                              .ToArray();

            if (listPersons.Any())
            {
                await TtsService.SayAsync(SpeechDictionnary.GetHelloSentence(listPersons));
            }
        }
예제 #4
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);
        }
예제 #5
0
        public async Task ListeningWhatToDo()
        {
            await PrepareListening();

            await TtsService.SayAsync(SpeechDictionnary.GetAskWhatToDoSentence());

            await _continuousRecognitionSession.AddConstraintAsync(ConstraintsDictionnary.ConstraintForEvents, false);

            await _continuousRecognitionSession.AddConstraintAsync(ConstraintsDictionnary.ConstraintForAbortWords, false);

            await _continuousRecognitionSession.AddConstraintAsync(ConstraintsDictionnary.ConstraintForSandwichs, false);

            await _continuousRecognitionSession.AddConstraintAsync(ConstraintsDictionnary.ConstraintForCallingSomeone, false);

            await _continuousRecognitionSession.AddConstraintAsync(ConstraintsDictionnary.ConstraintForToDescribeSomeOne, false);

            await _continuousRecognitionSession.AddConstraintAsync(ConstraintsDictionnary.ConstraintForReservation);

            await _continuousRecognitionSession.StartContinuousRecognitionAsync();
        }
예제 #6
0
 public async Task SayEventsAvailable()
 {
     await TtsService.SayAsync(SpeechDictionnary.GetEventsAvailableSentence());
 }