Voice Commands With the Mixed Reality Toolkit

Voice Commands With the Mixed Reality Toolkit

What you’ll need

If you haven’t done so already, be sure you’ve properly setup your development environment and you’ve imported the Mixed Reality Toolkit into your project.  You’ll also need to be familiar with the Unity Editor and its interface controls.  If you are not, there is a great tutorial series to get you started.

Getting Started

Note: This Feature is only availible for Windows Standalone and UWP Build Targets.

  1. Voice Input
  2. Create a new scene
  3. Run the MRTK scene wizard via:
    MixedRealityToolkit/Configure/Apply Scene Settings
  4. Create a Cube
  5. Create a new script named SpeechHandler
  6. Attach the SpeechHandler to your Cube
  7. Open the new script in any text editor
  8. Implement the ISpeechHandler interface
  9. Add switch statement for eventData.RecognizedText with a case for each command you wish to use.

Note: Select and other Voice Commands are reserved by the OS and cannot be used.

ProTip: Use simple Voice Commands that are one or two words.

using UnityEngine;
using HoloToolkit.Unity.InputModule;

public class SpeechHandler : MonoBehaviour, ISpeechHandler
    void ISpeechHandler.OnSpeechKeywordRecognized(SpeechEventData eventData)
        switch (eventData.RecognizedText.ToLower())
            case "your voice command":

    public void DoAction()
        // TODO: Action

Now, let’s take it a step further and use Dictation to input text.

Comments are closed.