Documentation: Speech Commands

Speech Commands

MARUI Speech Commands enable the execution of custom commands using voice input.
Like the HotKeys, they can be freely programmed and any created speech commands can be saved.

Speech Commands can be programmed either with Python or MEL script,
or more conveniently with the Speech Commands Editor.

Initial Set-Up

MARUI Speech Commands use the Windows speech recognition engine.
If you have not yet initialized the Windows speech recognition engine, you must do so before you can use MARUI Speech Commands.
Please follow the guide provided by Microsoft on how to initialize Windows speech recognition:
https://support.microsoft.com/en-us/help/4027176/windows-10-use-voice-recognition

The Speech Commands Editor

The Speech Command editor is a simple graphical dialog to create, edit, save and delete MARUI Speech Commands.
If can be opened from the Maya shelf, by clicking the Speech Commands icon in the MARUI shelf tab:

Speech Command Editor

The Speech Commands List

In the top part of the Speech Commands Editor is a list of all the Speech Commands you have created.
Upon first opening the Speech Commands editor, this list will most likely be empty.

Adding Speech Commands

To add new custom speech commands, fill in the text fields and press the Create New button. This will automatically update the speech recognition engine so that it will recognize the new command.

Spoken Command / Identifier

This is the spoken phrase that the speech recognition engine will listen for to identify commands. This is also the name of the speech command that will appear in the Speech Commands List.

Command / Script

This is the MEL or Python command that will be issued when a voice command is recognized.
It can be a Maya command (eg. move -relative 1 2 3) or your own script.
Use the radio buttons below to specify whether the script is in MEL script of Python script.

Updating Speech Commands

You can update speech commands by selecting them from the Speech Commands List, changing the values in the text fields and pressing Update Selected. This will automatically update the speech recognition engine with the updated command.
You can also change the order of speech commands in the list by pressing the Move Up and Move Down buttons on the right side of the Speech Commands List.

Deleting Speech Commands

You can delete speech commands by selecting the command in the Speech Commands List and pressing the Delete Selected button. This will automatically update the speech recognition engine so that it will no longer recognize deleted commands.

Saving and Loading Speech Commands, and the SpeechCommands save-file

At the bottom of the Speech Commands Editor are two buttons: Save and Load.
Save will save your current Speech Commands to your computer hard drive, so they will be available the next time you start MARUI.
The location of the Speech Commands save file will be in your Maya preferences folder.
By default, this will be
C:\Users\<your name>\Documents\maya\<maya version>\prefs\MARUI_Speech.mel
for example, for a user named “Max” and Maya version 2018, this folder would be:
C:\Users\max\Documents\maya\2018\prefs\MARUI_Speech.mel
This is a simple MEL script file, so you can edit it with a text editor to include your own scripts.
See the section below on how to read and write scripts for SpeechCommands.

MARUI will load your saved Speech Commands automatically upon starting.

Using the MARUI Speech Command Widget

In the default user interface layout, you can access the MARUI Speech Command Widget by holding the “Alt” button on your left controller.
Then the buttons on the right controller will change and reveal the Speech Command Widget (on the up side of Oculus Touch thumb stick or on the upper end of the Vive controller touchpad.

You can hold widget and speak your command.
The command will be executed soon after you finished saying it.
Be sure not to let go of the stick too early, as it can take a moment to process the audio.

An alternative way to use it is to just briefly “touch” (and release) the widget. This enables speech recognition permanently (until you touch the widget again).
Again, commands will be executed as soon as you finish them.

Scripting Speech Commands

If you want to automate Speech Command creation, you can perform all the operations that the Speech Commands editor allows manually via Python or MEL script.
The command to create, edit, save and delete Speech Commands is the MARUI_Speech command.
The following example illustrates how to use scripting to create, edit, and delete Speech Commands.

~pp~// Add Speech Commands
MARUI_Speech -addElement -speechIdentifier “Execute MEL command” -command “myMELcommand()”;
MARUI_Speech -addElement -speechIdentifier “Execute Python command” -command “myPythonCommand()” -python 1;
// Update the second element (whose zero-based index is 1) in the list of registered Speech Commands
MARUI_Speech -setElement 1 -speechIdentifier “New spoken command”;
// Delete the third element (whose zero-based index is 2) in the list of registered Speech Commands
MARUI_Speech -deleteElement 2;

Troubleshooting

If you’re having trouble with the MARUI Speech Commands, please try the following:
(1) Check that Windows speech recognition is set up and working properly (for example by dictating a few commands into a text editor.
https://support.microsoft.com/en-us/help/4027176/windows-10-use-voice-recognition
(2) Look at the Speech Command widget when it is activated to see if it receives your speech audio.
When activated, the red frame around it will change color to indicate the sound level received from the microphone.
If the microphone channel is broken or inaccessible, it will show a broken microphone symbol instead.
(3) Check which microphone is set as default input device in your Windows audio settings.
(4) If you’re trouble getting your speech commands identified correctly,
try short and simple command words (such as “delete”, “flip”, etc) instead of long sentences.