- Home /
Error: there already is a keyword recognizer with "go" as one of its keyword UnityEngine.Windows.Speech.KeywordRecognizer:.ctor(String[])
I'm Trying to make speech recognition with KeywordRecognizer and Microsoft.Speech but i got this error
Error: there already is a keyword recognizer with "go" as one of its keyword UnityEngine.Windows.Speech.KeywordRecognizer:.ctor(String[])
it sends me the same error even when i write a different word than go
this is my code: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Windows.Speech; using System.Linq;
public class Recognition : MonoBehaviour {
KeywordRecognizer KeywordRecognizer;
Dictionary<string, System.Action> keywords = new Dictionary<string, System.Action>();
void Start()
{
keywords.Add(" go ", () =>
{
GoCalled();
});
KeywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());
KeywordRecognizer.OnPhraseRecognized += KeywrodRecognizerOnPhraseRecognized;
KeywordRecognizer.Start();
}
void KeywrodRecognizerOnPhraseRecognized(PhraseRecognizedEventArgs args)
{
System.Action keywordAction;
if (keywords.TryGetValue(args.text , out keywordAction))
{
keywordAction.Invoke();
}
}
void GoCalled()
{
print("you just said GO");
}
}
Answer by Influnza · Aug 02, 2017 at 04:38 AM
I was hitting hit this error when loading a new scene and creating a new recognizer. The error went away with:
void OnDestroy()
{
if (keywordRecognizer != null)
{
keywordRecognizer.Stop();
keywordrecognizer.Dispose();
}
}
I think even a better solution would be to create a singleton once (DontDestroyOnLoad)
This would have been my first assumption that you somehow create two or more at the same time. The $$anonymous$$eywordRecogniser wraps some native OS libraries, so make sure you only create one instance at any time. Even when you implement a singleton i would strongly recommend to keep that OnDestroy. Native resources should always be explicitly disposed. Never rely on the GC.
Answer by sandbaydev · Jan 19, 2018 at 02:54 PM
Bit old question, but I had the same problem so I thought to add:
Make sure you start only ONE speech recognition script in the scene. If you have 2 objects with the script, you'll get that error.
Your answer
![](https://koobas.hobune.stream/wayback/20220612110507im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to use custom TensorFlow speech recognition model in Unity3d? 0 Answers
a Problem with new Unity 5.0 - 5.1 0 Answers
problem when i open the asset store from unity! 0 Answers
problem in exporting unity 5 project 0 Answers
MeshCollider invert 0 Answers