void Update() { str = UnitySphinx.DequeueString(); if (UnitySphinx.GetSearchModel() == "kws") { print("listening for keyword"); if (str != "") { UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.jsgf); guitext.text = "order up"; print(str); } } else if (UnitySphinx.GetSearchModel() == "jsgf") { print("listening for order"); if (str != "") { guitext.text = str; char[] delimChars = { ' ' }; string[] cmd = str.Split(delimChars); int numAnimals = interpretNum(cmd [0]); GameObject animal = interpretAnimal(cmd [1]); for (int i = 0; i < numAnimals; i++) { Vector3 randPos = new Vector3(spawn.position.x + UnityEngine.Random.Range(-0.1f, 0.1f), spawn.position.y + UnityEngine.Random.Range(-0.1f, 0.1f), spawn.position.z + UnityEngine.Random.Range(-0.1f, 0.1f)); Instantiate(animal, randPos, spawn.rotation); } UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.kws); } } }
// Update is called once per frame void Update() { if (UnitySphinx.GetSearchModel() == "kws") { str = UnitySphinx.DequeueString(); print("listening for keyword"); if (str != "") { UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.jsgf); //guitext.text = "order up"; print(str); } } /* * else if (UnitySphinx.GetSearchModel() == "jsgf") * { * if (str!="") * { * Vector3 v; * if (str == "ALAXA") * v = new Vector3(0, 0.5f, 0); * else if (str == "AYNACHA") * v = new Vector3(0, -0.5f, 0); * else if (str == "KUPI") * v = new Vector3(0.5f, 0, 0); * else v = new Vector3(-0.5f, 0, 0); * * transform.position += v; * print("de prueba " + str); * } * * * }*/ }
// Update is called once per frame void Update() { str = UnitySphinx.DequeueString(); if (UnitySphinx.GetSearchModel() == "kws") { //print("listening for keyword"); if (str != "") { if (str.IndexOf("movement") != -1) { UnitySphinx.Stop(); jsgf = Application.dataPath + "/Resources/UnitySphinx/model/en-us/movement.gram"; UnitySphinx.Init(jsgf, kws); UnitySphinx.Run(); UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.jsgf); } if (str.IndexOf("rotation") != -1) { UnitySphinx.Stop(); jsgf = Application.dataPath + "/Resources/UnitySphinx/model/en-us/rotation.gram"; UnitySphinx.Init(jsgf, kws); UnitySphinx.Run(); UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.jsgf); } print(str); } } else if (UnitySphinx.GetSearchModel() == "jsgf") { print("listening for order"); if (str != "") { if (str.IndexOf("move") != -1) { startposition = 0f; if (str.IndexOf("up") != -1) { direction = 1; } else if (str.IndexOf("down") != -1) { direction = -1; } if (str.IndexOf("one") != -1) { meters = 1; } if (str.IndexOf("two") != -1) { meters = 2; } else if (str.IndexOf("three") != -1) { meters = 3; } else if (str.IndexOf("four") != -1) { meters = 4; } } if (str.IndexOf("rotate") != -1) { if (str.IndexOf("right") != -1) { direction = 1; } else if (str.IndexOf("left") != -1) { direction = -1; } if (str.IndexOf("fast") != -1) { velocity = 4; } if (str.IndexOf("slow") != -1) { velocity = 1; } } if (str.IndexOf("exit") != -1) { meters = 0; direction = 0; velocity = 0f; UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.kws); } print(str); } if (startposition <= meters) { startposition = startposition + 0.05f; transform.Translate(0, 0, direction * 0.05f); } transform.Rotate(0, 0, direction * velocity * Time.deltaTime * 50); } }
// Use this for initialization void Start() { //UnitySphinx.Init(); UnitySphinx.Run(); UnitySphinx.SetSearchModel(UnitySphinx.SearchModel.jsgf); }