/////////////////////////////////////////////////////////////////// // if if{(join1) (expr0)}else{&element} // if1 if{expr1 - &element0}elseif{&join1}else{&element} /////////////////////////////////////////////////////////////////// public IEnumerator <ccr.ITask> RunHandler(Microsoft.Robotics.Technologies.Speech.SpeechRecognizer.Proxy.SpeechRecognized message) { Increment(); if (message.Body.Confidence > 0.7D) { Increment(); _joinAlphaPorts[1].Post(message.Body); if (message.Body.Semantics.Children[@"TypeOfMoving"].ValueString == @"Stop") { Increment(); _mergeGamma.Post(FloatCast(0D)); } else if (message.Body.Semantics.Children[@"TypeOfMoving"].ValueString == @"Move") { Increment(); _joinAlphaPorts[0].Post(message.Body.Semantics.Children[@"TypeOfMoving"].ValueString); } else { Increment(); _mergeAlpha.Post(message.Body.Semantics.Children[@"TypeOfMoving"].ValueString); } } else { Increment(); _mergeAlpha.Post(message.Body); } Decrement(); yield return(WaitUntilComplete()); }
/// <summary> /// Speech recognized handler /// </summary> /// <param name="recognized"></param> private void SpeechRecognizedHandler(sr.SpeechRecognized recognized) { // Keep speech event queue from growing infinitely if (_state.SpeechEvents.Count == MaxSpeechEventsToRetain) { _state.SpeechEvents.RemoveAt(0); } // Add latest event to queue _state.SpeechEvents.Add(new EventListEntry(recognized.Body)); }
/// <summary> /// Handles the recognition event notification /// </summary> /// <param name="recognition"></param> #region CODECLIP 02-2 void OnSRRecognition(sr.SpeechRecognized recognition) { if (recognition.Body.Semantics != null) { switch (recognition.Body.Semantics.ValueString) { case "Forward": _drivePort.SetDrivePower(0.5, 0.5); break; case "Backward": _drivePort.SetDrivePower(-0.5, -0.5); break; case "Left": _drivePort.SetDrivePower(-0.3, 0.3); break; case "Right": _drivePort.SetDrivePower(0.3, -0.3); break; case "Stop": _followMe = false; _drivePort.SetDrivePower(0.0, 0.0); break; case "FollowMe": _followMe = !_followMe; if (!_followMe) { _drivePort.SetDrivePower(0.0, 0.0); } break; } } }
IEnumerator <ccr.ITask> SpeechRecognizerSpeechRecognizedHandler(Microsoft.Robotics.Technologies.Speech.SpeechRecognizer.Proxy.SpeechRecognized message) { OnSpeechRecognizerSpeechRecognizedHandler handler = new OnSpeechRecognizerSpeechRecognizedHandler(this, Environment.TaskQueue); return(handler.RunHandler(message)); }