Voice Recognition


I am currently working on a project using UnityEngine.Windows.Speech. I have a problem trying to move my character because I think it has to be inside the Update method otherwise it doesn’t update every frame and I get a jittery/stutter movement.

private string[] voiceCommands = { "Jump", "Forward" };
private KeywordRecognizer t_KeywordRecognizer;

// Initialisation in Start
t_KeywordRecognizer = new KeywordRecognizer(voiceCommands);
t_KeywordRecognizer.OnPhraseRecognized += OnPhraseRecognized;

public void OnPhraseRecognized(PhraseRecognizedEventArgs args)
    switch (args.text)
        case "Forward":
                transform.position += transform.forward * Time.deltaTime * movementSpeed;

The jumping works fine, but the movement is like a small step and stops. However, if I put

transform.position += transform.forward * Time.deltaTime * movementSpeed;

inside the Update method, the character moves forward with no issues.

Any ideas on how I can address this or what I’m doing wrong? :slight_smile:

EDIT: Forgot to mention that if I call the OnPhraseRecognized in Update with “null” as parameter, it says it cannot convert null to PhraseRecognizedEventArgs

In your case, it actually work like Input.GetKeyDown() so it will only move one step each time you call it.