Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
iOS Guides
Setting Up Voice Commands

Setting Up Voice Commands

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.

Note

The head unit manufacturer will determine how these voice commands are triggered, and some head units will not support voice commands.

Note

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.

Creating Voice Commands

To create voice commands, you simply create and set SDLVoiceCommand objects to the voiceCommands array on the screen manager.

SDLVoiceCommand *voiceCommand = [[SDLVoiceCommand alloc] initWithVoiceCommands:@[<#NSString#>] handler:^{
    <#Voice command selected#>
}];

self.sdlManager.screenManager.voiceCommands = @[voiceCommand];
let voiceCommand = SDLVoiceCommand(voiceCommands: [<#String#>]) {
    <#Voice command triggered#>
}

sdlManager.screenManager.voiceCommands = [voiceCommand]

Unsupported Voice Commands

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.

Duplicate Strings in Voice Commands

Duplicates Between Different Commands

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.

Duplicates in The Same Command

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"]
}

Deleting Voice Commands

To delete previously set voice commands, you just have to set an empty array to the voiceCommands array on the screen manager.

self.sdlManager.screenManager.voiceCommands = [];
sdlManager.screenManager.voiceCommands = []
Note

Setting voice command strings composed only of whitespace characters will be considered invalid (e.g. " ") and your request will be aborted by the module.

Using RPCs

If you wish to do this without the aid of the screen manager, you can create SDLAddCommand objects without the menuParams parameter to create global voice commands.

View on GitHub.com