コード例 #1
0
        private async void WitText_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == System.Windows.Input.Key.Enter)
            {
                this.Focus();

                ProgressBar.IsIndeterminate = true;

                Wit wit = new Wit("CBP3OGVVJI23M5XAH7ARKOMDDSKB3HJV");

                WitResponse witResponse = await wit.CaptureTextIntent(WitText.Text);

                if (witResponse != null && witResponse.outcomes != null && witResponse.outcomes.Count > 0)
                {
                    WitIntent.Text = "Intent = " + witResponse.outcomes[0].intent;

                    if (witResponse.outcomes[0].entities.ContainsKey("datetime"))
                    {
                        List <WitDateTimeEntity> dateEntities = witResponse.outcomes[0].entities["datetime"].ToObject <List <WitDateTimeEntity> >();
                    }
                }
                else
                {
                    WitIntent.Text = "Intent not found";
                }

                ProgressBar.IsIndeterminate = false;
            }
        }
コード例 #2
0
        private void WitMicButton_CaptureVoiceIntentCompleted(object sender, WitResponse witResponse)
        {
            if (witResponse != null && witResponse.outcomes != null && witResponse.outcomes.Count > 0)
            {
                WitIntent.Text = "Intent = " + witResponse.outcomes[0].intent;
            }
            else
            {
                WitIntent.Text = "Intent not found";
            }

            ProgressBar.IsIndeterminate = false;
        }
コード例 #3
0
        private void HandleIntent(WitResponse witResponse)
        {
            var intent = witResponse.BestOutcome.Intent;

            if (_handlers.ContainsKey(intent))
            {
                var h        = _handlers[intent];
                var response = h(new JarvisIntent(witResponse));
                _output.SendOutput(response.Response);
            }
            else
            {
                throw new InvalidOperationException("Invalid intent: " + intent);
            }
        }
コード例 #4
0
 public JarvisIntent(WitResponse intent)
 {
     Intent = intent;
 }