How Tos

Last reviewed: 7/15/2011

Article ID: H071128

HOW: Developing Dragon NaturallySpeaking applications that recognize speech

The information in this article applies to:

  • SpeechKit 7

Summary

Dragon NaturallySpeaking offers command and dictation recognition capabilities that may be integrated directly within applications.

More Information

SpeechKit 7 introduces enhance Dragon NaturallySpeaking support by dynamically determining the best Dragon APIs to used based on the version installed.

Nuance is deprecating API functions and shifting them to surviving APIs. SpeechKit 7 automatically adjusts to use the appropriate API.

GetProperty and SetProperty

New ChantSR methods GetProperty and SetProperty provide a way to set engine properties directly using the speech API constant values. These methods use the name of the enumeration constant type and the numeric value of the constant to identify the property to access. New property values are passed as a string and the ChantSR class converts to the applicable data type required by the speech API.

The following example illustrates getting and setting the Dragon NatuallySpeaking engine constant dgnengoptionUseConfidence (1). For boolean values "1" represents true and "0" represents false.

String stringVal = NChantSR1.GetProperty("dgnengineoptionconstants", 1);

NChantSR1.SetProperty("dgnengineoptionconstants", 1, "1");

Command and Dictation Recognition

There are 2 ways to integrate Dragon NaturallySpeaking within your application:

  1. Define Command and Dictation vocbaularies, enable and disable as needed, process CCSRHasCommand and CCSRHasText events to retrieve recognized text, and
  2. Define a CSRDgnDictCustom control and associated it with a text control in your application where dictation results are placed directly in the text control.

The following example illustrates defining a dictation vocabulary. Use "Text" [default], "Numbers", "Letters" as the vocabulary name.

// Define a dictation vocabulary
int dictationVocabID = NChantSR1.DefineResource(ChantSpeechResource.CSRDictationVocab, "text");
// Load and enable dictation vocabulary
NChantSR1.EnableResource(ChantSpeechResource.CSRDictationVocab, dictationVocabID);
// Disable it
NChantSR1.DisableResource(ChantSpeechResource.CSRDictationVocab, dictationVocabID);

The following example illustrates defining a CSRDgnDictCustom resource.

// Have recognized speech placed directly in the textbox when it has focus
int dictCustomResourceID = NChantSR1.defineResource(ChantSpeechResource.CSRDgnDictCustom, "",ChantResourceFunction.CRFNone, text1, this, -1, 0);
// Enable it to make it active
NChantSR1.EnableResource(ChantSpeechResource.CSRDgnDictCustom, dictCustomResourceID);
// Disable it
NChantSR1.DisableResource(ChantSpeechResource.CSRDgnDictCustom, dictCustomResourceID);

Dialogs

ChantDialog constants are available that map to newer Dragon dialogs. These include:

  • CDPerformanceAssistant - Displays the Dragon Help panel.
  • CDManageUsers - Displays the Dragon Speaker management dialog.
  • CDRoamingUsersOptions - Displays the Dragon dialog for managing roaming users.

Register for the CCSRProgress callback event to be notified when the dialog closes. The ID property contains the ChantDialog constant and the Flags property contains the exit code.

The following example illustrates running the microphone setup dialog.

NChantSR1.ShowDialog(ChantDialog.CDMicTraining, this.Handle, "", "");