/// <summary> /// adds a simple method to execute /// </summary> /// <param name="lang">the language</param> /// <param name="text">the phrase a unique text for the language</param> /// <param name="simpleSpeechGroupKey">the simple speech group key for this simple command</param> /// <param name="action">the action to perfrom when the phrase is recognized</param> public void AddSimpleCommand(string lang, string text, string simpleSpeechGroupKey, Action action) { Dictionary <string, SimpleSpeechGroupTuple> langSpeechGroups; if (this.SimpleCommands.TryGetValue(lang, out langSpeechGroups) == false) { //no language tuple for simple commands langSpeechGroups = new Dictionary <string, SimpleSpeechGroupTuple>(); this.SimpleCommands.Add(lang, langSpeechGroups); } SimpleSpeechGroupTuple simpleSpeechGroup; if (langSpeechGroups.TryGetValue(simpleSpeechGroupKey, out simpleSpeechGroup) == false) { //no speech group with this key here simpleSpeechGroup = new SimpleSpeechGroupTuple(true); langSpeechGroups.Add(simpleSpeechGroupKey, simpleSpeechGroup); } if (simpleSpeechGroup.Commands.ContainsKey(text)) { throw new Exception("speech dictionary already contains a simple method: " + text + "on speech group: " + simpleSpeechGroupKey + " on language: " + lang); } simpleSpeechGroup.Commands.Add(text, new SimpleCommandTuple(action, true)); }
/// <summary> /// adds a simple method to execute /// </summary> /// <param name="lang">the language</param> /// <param name="text">the phrase a unique text for the language</param> /// <param name="simpleSpeechGroupKey">the simple speech group key for this simple command</param> /// <param name="action">the action to perfrom when the phrase is recognized</param> public void AddSimpleCommand(string lang, string text, string simpleSpeechGroupKey, Action action) { Dictionary<string, SimpleSpeechGroupTuple> langSpeechGroups; if (this.SimpleCommands.TryGetValue(lang, out langSpeechGroups) == false) { //no language tuple for simple commands langSpeechGroups = new Dictionary<string, SimpleSpeechGroupTuple>(); this.SimpleCommands.Add(lang, langSpeechGroups); } SimpleSpeechGroupTuple simpleSpeechGroup; if (langSpeechGroups.TryGetValue(simpleSpeechGroupKey, out simpleSpeechGroup) == false) { //no speech group with this key here simpleSpeechGroup = new SimpleSpeechGroupTuple(true); langSpeechGroups.Add(simpleSpeechGroupKey, simpleSpeechGroup); } if (simpleSpeechGroup.Commands.ContainsKey(text)) { throw new Exception("speech dictionary already contains a simple method: " + text + "on speech group: " + simpleSpeechGroupKey + " on language: " + lang); } simpleSpeechGroup.Commands.Add(text, new SimpleCommandTuple(action, true)); }