Skip to main content
A newer version of this page is available. .

Speech Recognition and Virtual Assistant (Nuance) CTP

  • 3 minutes to read

This topic contains instructions on how to bind the Rich Text Editor to the Nuance Dragon SpeechKit to integrate speech recognition and voice-enabled workflows into your applications.

Important

This functionality is available in v20.2.5 as a community technology preview (CTP).

Requirement

To use the RichEdit control with Nuance Speech Recognition, you need to have a Nuance Dragon subscription and to register Nuance resources in the header section.

Register Rich Text Editor in Nuance

Register a RichEdit control in the Dragon SpeechKit’s NUSA_configure method to enable Nuance API support in RichEdit. Note that you should register every RichEdit control on the page. After registration, a control can processes the Nuance default commands.

Use the nusaSettings property to access the RichEdit’s Nuance-related settings.

function NUSA_configure() {
    ...
    // register every RichEdit control that should work with Nuance functionality
    richEdit1.nusaSettings.register();
    richEdit2.nusaSettings.register();
}

Speech-Enabled RichEdit Focus

Specify the conceptName option in the register method to allow users to focus a RichEdit with the go to voice command.

function NUSA_configure() {
    ...
    // register every RichEdit control that should work with Nuance functionality
    richEdit1.nusaSettings.register({ conceptName: 'patient description' });
    richEdit2.nusaSettings.register({ conceptName: 'medical history' });
}

RichEdit Commands for Nuance

Rich Text Editor contains a set of custom Nuance commands that allow you to manage RichEdit functionality (for instance, change font name and color). Call the registerCommands method to register the commands. Note that regardless of the number of RichEdit controls on the page, the function should be called only once.

function NUSA_configure() {
    ...
    richEdit1.nusaSettings.registerCommands();
}

Add a command handler for every RichEdit control in the Dragon SpeechKit’s NUSA_onCommandRecognized event handler.

function NUSA_onCommandRecognized(cmdId, spokenText, content, placeholderIds, placeholderValues) {
    if(richs[0].nusaSettings.getCommandHandler()(cmdId, placeholderIds, placeholderValues))
        return;
// your custom commands
...
}

Custom User Commands

You can add custom RichEdit commands in the Dragon SpeechKit’s NUSA_onCommandRecognized event handler. Use the getFocusedRichEdit method to get the focused RichEdit control.

/** @type {DevExpress.RichEdit.RichEdit} */
const focusedRichEdit = richEdit.nusaSettings.getFocusedRichEdit();

Get Control Type and Container Type

Use the following methods to get the current instance of the NusaCustomControlType or NusaCustomContainerType type.

richEdit.nusaSettings.getCustomControl();
richEdit.nusaSettings.getCustomContainer();

Use the returned objects to modify the RichEdit’s Nuance-related settings (for instance, insert two paragraphs with the new paragraph voice command).

function NUSA_configure() {
    richEdit.nusaSettings.register();
    var customControl = richEdit.nusaSettings.getCustomControl();
    customControl.paragraphFormat = DevExpress.RichEdit.Characters.ParagraphBreak + 
        DevExpress.RichEdit.Characters.ParagraphBreak;
}

Use the customControlType and customContainerType parameters of the NusaRegisterOptions interface to specify the type names. The default values are: “DevExpressRichEdit” and “DevExpressRichEditContainer”.

Customize the Registered Commands

The registerCommands method accepts an optional parameter that allows you to modify command settings (for instance, change a command description).

richEdit.nusaSettings.registerCommands(function(commandSets/*: NusaCommandSet[]*/, placeholders: /*NusaPlaceholder[]*/) {
    commandSets[0].commands.find(function(cmd){
        return cmd.commandId == “DxReFontColor”}).description = 'Custom description';
});