public void SpeechToText(string command) { // move to lower case command = command.ToLower(); // translate command to game world command = Translate(command); // put info qi //QuickInfoMsg qimsg = new QuickInfoMsg(); //qimsg.command = DialogMsg.Cmd.open; //qimsg.title = "Speech Command"; //qimsg.text = "Cmd=<" + command + "> ..."; //QuickInfoDialog.GetInstance().PutMessage(qimsg); // check dialog manager DialogMgr.GetInstance().SpeechToText(command); // run it through the dialog if (DialogueTree.Instance.ActiveDialogue != null) DialogueTree.Instance.ActiveDialogue.SpeechToText(command); // send to everyone SpeechMsg speechmsg = new SpeechMsg(command); ObjectManager.GetInstance().PutMessage(speechmsg); // find closest command by interrigating all the objects if (speechmsg.Stats.Count > 0) { SpeechMsg.Info info = null; foreach (SpeechMsg.Info tmp in speechmsg.Stats) { if (info == null) // first one info = tmp; else { // check for higher percentage if (tmp.percent > info.percent) info = tmp; } } if (info != null) { // send this command InteractMsg interact = new InteractMsg(info.obj.gameObject, info.map, true); info.obj.PutMessage(interact); // close the interact menu....just in case InteractDialogMsg msg = new InteractDialogMsg(); msg.command = DialogMsg.Cmd.close; InteractDialogLoader.GetInstance().PutMessage(msg); } } }
virtual public void HandleSpeech( SpeechMsg msg ) { float result; // go through all InteractionMap messages and find one that matches foreach (InteractionMap map in ItemResponse) { // get name of each item string name = StringMgr.GetInstance().Get(map.item).ToLower(); // Debug.Log("HandleSpeech() : compare <" + msg.Utterance + "> with <" + name + ">"); if ((result=SpeechProcessor.GetInstance().CheckUtterance(msg.Utterance, name)) > 0.5f) { // add to speech msg msg.Stats.Add(new SpeechMsg.Info(this, map, result)); // we're done return; } } // handle displaying menu by prettyname string menu = prettyname.ToLower() + " menu"; // Debug.Log("HandleSpeech() : compare <" + msg.Utterance + "> with <" + name + ">"); if ((result = SpeechProcessor.GetInstance().CheckUtterance(msg.Utterance, menu)) > 0.5f) { DoInteractMenu(); } }