I am trying to create a voice recognition game in unity. What i don't understand is when i use word such as "left" or "forward", it easily detects it. But when it comes to just using a letter, it doesn't detect it at all even though i followed same method to detect.The game requires using only single letter.Does anybody knows how to detect letters through voice recognition in unity?
Following is the code i used:
private KeywordRecognizer keywordRecognizer;
private Dictionary<string, Action> actions = newDictionary<string,Action>();
void Update{
actions.Add("Left", Left);//this works
actions.Add("A", Alpha);//this doesn't
keywordRecognizer = new KeywordRecognizer(actions.Keys.ToArray());
keywordRecognizer.OnPhraseRecognized += RecognizedSpeech;
keywordRecognizer.Start();
}
private void RecognizedSpeech(PhraseRecognizedEventArgs speech){
Debug.Log(speech.text);
actions[speech.text].Invoke();
word = speech.text;
results.text = "You said: <b>" + word + "</b>";
}
private void Left(){
transform.Translate(-1, 0, 0);
}
private void Alpha(){
transform.Translate(1, 0, 0);
}