Voice commands are global commands available anywhere on the head unit to users of your app. Once the user has opened your SDL app (i.e. your SDL app has left the HMI state of NONE
) they have access to the voice commands you have setup. Your app will be notified when a voice command has been triggered even if the SDL app has been backgrounded.
The head unit manufacturer will determine how these voice commands are triggered, and some head units will not support voice commands.
On Manticore, voice commands are viewed and activated by a tab in the right hand section, not through a microphone.
You have the ability to create voice command shortcuts to your Main Menu cells which we highly recommended that you implement. Global voice commands should be created for functions that you wish to make available as voice commands that are not available as menu cells. We recommend creating global voice commands for common actions such as the actions performed by your Soft Buttons.
To create voice commands, you simply create and set VoiceCommand
objects to the voiceCommands
array on the screen manager.
const voiceCommand = new SDL.manager.screen.utils.VoiceCommand(['Command One'], function () { // Handle the VoiceCommand's Selection }); sdlManager.getScreenManager().setVoiceCommands([voiceCommand]);
The library automatically filters out empty strings and whitespace-only strings from a voice command's array of strings. For example, if a voice command has the following array values: [" ", "CommandA", "", "Command A"]
the library will filter it to: ["CommandA", "Command A"]
.
If you provide an array of voice commands which only contains empty string and whitespace-only strings across all of the voice commands, the upload request will be aborted and the previous voice commands will remain available.
Voice commands that are sent with duplicate strings in different voice commands, such as:
{ Command1: ["Command A", "Command B"], Command2: ["Command B", "Command C"], Command3: ["Command D", "Command E"] }
Then the manager will abort the upload request. The previous voice commands will remain available.
If any individual voice command contains duplicate strings, they will be reduced to one. For example, if the voice commands to be sent are:
{ Command1: ["Command A", "Command A", "Command B"], Command2: ["Command C", "Command D"] }
Then the manager will strip the duplicates to:
{ Command1: ["Command A", "Command B"], Command2: ["Command C", "Command D"] }
To delete previously set voice commands, you just have to set an empty array to the voiceCommands
array on the screen manager.
sdlManager.getScreenManager().setVoiceCommands([]);
Setting voice command strings composed only of whitespace characters will be considered invalid (e.g. " "
) and your request will be aborted by the module.
If you wish to do this without the aid of the screen manager, you can create AddCommand
objects without the menuParams
parameter to create global voice commands.