示例#1
0
        private void StartRecognition()
        {
            AudioHandler.Start();
            Speech.Activate();

            var rec = new Recognizer(() => { Speech.Deactivate(); }, HandleResult);
        }
示例#2
0
        /// <summary>
        /// This occurs on asynchronous basis
        /// </summary>
        /// <param name="Q"></param>
        /// <param name="A"></param>
        private void AsyncResultChanged(string Q, string A)
        {
            this.Dispatcher.Invoke(() =>
            {
                if (A.StartsWith("SUDO:") == false)
                {
                    //Play results audio
                    AudioHandler.Results();

                    //Hide the spinner
                    Spinner.Hide();

                    //Hide the hypothesis
                    var da = new DoubleAnimation(0, TimeSpan.FromMilliseconds(500));
                    Hypothesis.BeginAnimation(OpacityProperty, da);

                    ResultSheet.Visibility = Visibility.Visible;
                    var sa = FindResource("ResultsAnimation") as Storyboard;
                    sa.Begin();

                    //Speak the answer
                    OpenSpeak.Speak(A);

                    q_label.Content = "\"" + Q + "\"";
                    a_label.Text    = A;
                }
                else
                {
                    //Play results audio
                    AudioHandler.Results();

                    //Hide the spinner
                    Spinner.Hide();

                    //Hide the hypothesis
                    var da = new DoubleAnimation(0, TimeSpan.FromMilliseconds(500));
                    Hypothesis.BeginAnimation(OpacityProperty, da);

                    ResultSheet.Visibility = Visibility.Visible;
                    var sa = FindResource("ResultsAnimation") as Storyboard;
                    sa.Begin();

                    //Speak the answer
                    OpenSpeak.Speak(A.Replace("SUDO:", ""));

                    q_label.Content = "\"" + Q + "\"";
                    a_label.Text    = "Here's what I've got";
                }
            });
        }