Why doesn't Unity voice recognition work for single letters?

Viewed 681

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);
}
1 Answers

In Short: Single letter recognition is really hard. Just imagine the differences between b,p and d.

One thing you can do is set your KeywordRecognizer to low confidence

keywordRecognizer = new KeywordRecognizer(actions.Keys.Array(), ConfidenceLevel.low);

But, this wont help you as you will most likely have way more wrong recognitions afterwards. Further, if you want to say commands back to back the KeywordRecognizer will fail you anyways as he processes over the first keyword and ignores the ones spoken during the processing delay.

An alternative would be DictationRecognizer which does not listen for specific key words, but translates the user voice into a text which you could then scan for your key words / letters. Obviously, this also has a massive delay.

So, if you can't have a delay, then I supppose the only valid solution is to rethink why you need letter recognition and not full keywords like "alpha" instead of "a".

Related