Example #1
0
 public SenseMovement(TelnetConnection tc)
 {
     this.tc = tc;
     send = new SendMovement(tc);
 }
Example #2
0
        /// <summary>
        /// Handler for recognized speech events.
        /// </summary>
        /// <param name="sender">object sending the event.</param>
        /// <param name="e">event arguments.</param>
        private void SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            // Speech utterance confidence below which we treat speech as if it hadn't been heard
            const double ConfidenceThreshold = 0.3;

            // Number of degrees in a right angle.
            const int DegreesInRightAngle = 90;

            // Number of pixels turtle should move forwards or backwards each time.
            const int DisplacementAmount = 60;

            ClearRecognitionHighlights();

            if (e.Result.Confidence >= ConfidenceThreshold)
            {
                SendMovement SM = new SendMovement(tc);
                switch (e.Result.Semantics.Value.ToString())
                {
                    case "CLOSE":
                        SM.TelnetChar("C");
                        Environment.Exit(0);
                        break;

                    case "SWITCH":
                        SM.TelnetChar("S");
                        break;

                    case "LEFT":
                        SM.TelnetChar("L");
                        break;

                    case "CENTER":
                        SM.TelnetChar("M");
                        break;

                    case "RIGHT":
                        SM.TelnetChar("R");
                        break;
                }
            }
        }