示例#1
0
        public async Task FindByVoiceAsync()
        {
            IsListening       = true;
            _speechRecognizer = new SpeechRecognizer();
            var wordsFromJson = _agendaService.GetWordsFromJson().Where(w => w.Length >= 3).Distinct().ToList();

            _speechRecognizer.Constraints.Add(new SpeechRecognitionListConstraint(wordsFromJson, "keyword"));
            await _speechRecognizer.CompileConstraintsAsync();

            _speechRecognizer.ContinuousRecognitionSession.ResultGenerated +=
                ContinuousRecognitionSession_ResultGenerated;
            _speechRecognizer.HypothesisGenerated += SpeechRecognizerHypothesisGenerated;
            await _speechRecognizer.ContinuousRecognitionSession.StartAsync();
        }