private void VoiceCommandTrackHumansHandler(SpeechRecognizerDictionaryItem grammarItem, double angle) { Talker.Say(10, "Game On!"); robotStrategyTypePrevious = RobotStrategyType.None; _mapperVicinity.robotState.robotStrategyType = RobotStrategyType.PersonFollowing; }
private void VoiceCommandStopHandler(SpeechRecognizerDictionaryItem grammarItem, double angle) { _mapperVicinity.robotState.robotStrategyType = RobotStrategyType.None; // active Stop implied StopMoving(); Talker.Say(10, "Stopped!"); }
private void VoiceCommandBackUpHandler(SpeechRecognizerDictionaryItem grammarItem, double angle) { robotStrategyTypePrevious = _mapperVicinity.robotState.robotStrategyType; _mapperVicinity.robotState.robotStrategyType = RobotStrategyType.InTransition; SafePosture(); Translate(-300, MaximumBackwardVelocityMmSec, true); // use the shoot-and-forget version. }
private void VoiceCommandTurnRightHandler(SpeechRecognizerDictionaryItem grammarItem, double angle) { robotStrategyTypePrevious = _mapperVicinity.robotState.robotStrategyType; _mapperVicinity.robotState.robotStrategyType = RobotStrategyType.InTransition; SafePosture(); int rotateAngle = 30; TurnByAngle(rotateAngle, ModerateTurnPower, true); // use the shoot-and-forget version. }
/// <summary> /// Speech recognized handler /// </summary> /// <param name="recognized"></param> private void SpeechRecognizedHandler(sr.SpeechRecognized recognized) { TimeSpan sinceTalk = DateTime.Now - Talker.lastSpoken; if (sinceTalk.TotalSeconds < SpeechRecognizerTalkerBlackoutSec) { Tracer.Trace("SpeechRecognizedHandler in blackout at " + sinceTalk.TotalSeconds + " sec"); return; } int angle = Direction.to180fromRad(-recognized.Body.Angle); string commandText = recognized.Body.Text; string commandSemantics = recognized.Body.Semantics.ValueString; double confidence = Math.Round(recognized.Body.Confidence, 3); // 0 to 1, usually around 0.97 for successfully recognized commands //Tracer.Trace("**************************************** SpeechRecognizedHandler **************************************** "); //Tracer.Trace("speech '" + commandText + "'=>'" + commandSemantics + "' at " + angle + " degrees, confidence " + confidence); // find the handler based on semantics: SpeechRecognizerDictionaryItem srdi = (from di in speechRecognizerDictionary where di.semantics == commandSemantics select di).FirstOrDefault(); // usually Confidence is 0.95-0.99 if (srdi != null && recognized.Body.Confidence > srdi.minimumRequiredConfidence) { VoiceCommandState state = _state.VoiceCommandState; state.TimeStamp = DateTime.Now; state.Text = commandText; state.Semantics = commandSemantics; state.ConfidencePercent = (int)Math.Round(confidence * 100.0f); state.Direction = angle; LogHistory(1, "speech '" + commandText + "'=>'" + commandSemantics + "' at " + angle + " deg, " + confidence); // now call the handler: srdi.handler(srdi, angle); } else if (confidence > 0.5d) { LogHistory(3, "rejected '" + commandText + "'=>'" + commandSemantics + "' at " + angle + " deg, " + confidence); Talker.Say(10, "Homm"); // not enough confidence } //setPan(angle); //setTilt(0); }
private void VoiceCommandHereIAmHandler(SpeechRecognizerDictionaryItem grammarItem, double angle) { if (_mapperVicinity.robotState.robotStrategyType == RobotStrategyType.PersonFollowing && !haveATargetNow && !_mapperVicinity.robotState.ignoreKinectSounds) { double targetPanRelativeToRobot = _state.currentPanKinect + angle; //Talker.Say(10, "Sound at " + ((int)angle)); Talker.Say(10, "Sound at " + ((int)targetPanRelativeToRobot)); //Tracer.Trace("+++++++++++++++ currentPanKinect=" + _state.currentPanKinect + " Sound angle=" + angle + " targetPanRelativeToRobot=" + targetPanRelativeToRobot); //SetDesiredKinectPlatformPan(angle); setPanTilt(angle, 5.0d); lastVoiceLocalized = DateTime.Now; setCurrentGoalBearingRelativeToRobot(targetPanRelativeToRobot); // choose robotTacticsType - current tactics is move towards human: FollowDirectionMaxVelocityMmSec = ModerateForwardVelocityMmSec; _mapperVicinity.robotState.robotTacticsType = RobotTacticsType.FollowDirection; } }
private void VoiceCommandContinueHandler(SpeechRecognizerDictionaryItem grammarItem, double angle) { Talker.Say(10, "Strategy: " + robotStrategyTypePrevious); _mapperVicinity.robotState.robotStrategyType = robotStrategyTypePrevious; }
private void VoiceCommandYourMasterHandler(SpeechRecognizerDictionaryItem grammarItem, double angle) { Talker.Say(10, "Sir, Sergei Grich inn, Sir!"); }
private void VoiceCommandShootMeHandler(SpeechRecognizerDictionaryItem grammarItem, double angle) { SpawnIterator(ShootGunOnce); }