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");
}
}