Listing 6: Speech recognition is disabled while the computer is speaking so that it won't talk to itself.
if (sResponse != "") { sResponse = ProcessResponse(sResponse); //Turn off SR while the computer is speaking Grammar.CmdSetRuleState("CommandsRule", SpeechRuleState.SGDSInactive); voice.Speak(sResponse,SpeechVoiceSpeakFlags.SVSFlagsAsync); } if (sAction != "") PerformAction(sAction); //if there was a verbal response, wait until it's done and re-enable SR voice.WaitUntilDone(5000); //wait up to 5 seconds Grammar.CmdSetRuleState("CommandsRule", SpeechRuleState.SGDSActive);