コード例 #1
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            if (VoiceCommandName == "Search")
            {
                SelectedArrival   = Arrives.Single(c => c.Name == ArrivesCity);
                SelectedDeparture = Departs.Single(c => c.Name == DepartsCity);

                Search();
            }
        }
コード例 #2
0
        public async void UseVoice()
        {
            var searchUI = new SpeechRecognizerUI();

            searchUI.Recognizer.Grammars.AddGrammarFromUri("search", new Uri("ms-appx:///resources/grammar.xml"));

            searchUI.Settings.ListenText  = "Search for?";
            searchUI.Settings.ExampleText = "Show flights from Auckland to Wellington";

            var searchResult = await searchUI.RecognizeWithUIAsync();

            if (searchResult.ResultStatus == SpeechRecognitionUIStatus.Succeeded &&
                searchResult.RecognitionResult.TextConfidence != SpeechRecognitionConfidence.Rejected)
            {
                SelectedArrival   = Arrives.Single(c => c.Name == (string)searchResult.RecognitionResult.Semantics["arrives"].Value);
                SelectedDeparture = Departs.Single(c => c.Name == (string)searchResult.RecognitionResult.Semantics["departs"].Value);

                Search();
            }
        }