How do I recognize speech with Dragon NaturallySpeaking?
Last reviewed: 7/15/2011
HOW Article ID: H071128
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");
wchar_t* pszVal = pChantSR->GetProperty("dgnengineoptionconstants", 1);
pChantSR->SetProperty(L"dgnengineoptionconstants", 1, L"1");
String stringVal = pChantSR->GetProperty("dgnengineoptionconstants", 1);
ChantSR1->SetProperty("dgnengineoptionconstants", 1, "1");
var stringVal: Integer;
stringVal := ChantSR1.GetProperty("dgnengineoptionconstants", 1);
ChantSR1.SetProperty('dgnengineoptionconstants', 1, '1');
String stringVal = JChantSR1.GetProperty("dgnengineoptionconstants", 1);
JChantSR1.setNumberProperty("dgnengineoptionconstants", 1, "1");
stringVal = WChantSR1.GetProperty("dgnengineoptionconstants", 1);
WChantSR1.SetProperty("dgnengineoptionconstants", 1, "1");
Dim stringVal As String
stringVal = XChantSR1.GetProperty("dgnengineoptionconstants", 1)
XChantSR1.SetProperty "dgnengineoptionconstants", 1, "1"
Dim stringVal As 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:
- Define Command and Dictation vocbaularies, enable and disable as needed, process CCSRHasCommand and CCSRHasText events to retrieve recognized text, and
- 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);
// Define a dictation vocabulary
long dictationVocabID;
dictationVocabID = pChantSR->DefineResource(CSRDictationVocab, L"text");
// Load and enable dictation vocabulary
pChantSR->EnableResource(CSRDictationVocab, dictationVocabID);
// Disable it
pChantSR->DisableResource(CSRDictationVocab, dictationVocabID);
// Define a dictation vocabulary
long dictationVocabID;
dictationVocabID = pChantSR->DefineResource(CSRDictationVocab, "text");
// Load and enable dictation vocabulary
pChantSR->EnableResource(CSRDictationVocab, dictationVocabID);
// Disable it
pChantSR->DisableResource(CSRDictationVocab, dictationVocabID);
// Define a dictation vocabulary
dictationVocabID: Integer;
dictationVocabID := ChantSR1.DefineResource(CSRDictationVocab, 'text');
// Load and enable dictation vocabulary
ChantSR1.EnableResource(CSRDictationVocab, dictationVocabID);
// Disable it
ChantSR1.DisableResource(CSRDictationVocab, dictationVocabID);
// Define a dictation vocabulary
int dictationVocabID = JChantSR1.defineResource(ChantSpeechResource.CSRDictationVocab, "text");
// Load and enable dictation vocabulary
JChantSR1.enableResource(ChantSpeechResource.CSRDictationVocab, dictationVocabID);
// Disable it
JChantSR1.disableResource(ChantSpeechResource.CSRDictationVocab, dictationVocabID);
// Define a dictation vocabulary
var dictationVocabID;
dictationVocabID = WChantSR1.DefineResource(CSRDictationVocab, "text");
// Load and enable dictation vocabulary
WChantSR1.EnableResource(CSRDictationVocab, dictationVocabID);
// Disable it
WChantSR1.DisableResource(CSRDictationVocab, dictationVocabID);
' Define a dictation vocabulary
Dim dictationVocabID as Integer
dictationVocabID = XChantSR1.DefineResource(CSRDictationVocab, "text")
' Load and enable dictation vocabulary
XChantSR1.EnableResource CSRDictationVocab, dictationVocabID
' Disable it
XChantSR1.DisableResource CSRDictationVocab, dictationVocabID
' Define a dictation vocabulary
Dim dictationVocabID As Integer
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);
// Have recognized speech placed directly in the textbox when it has focus
long dictCustomResourceID;
dictCustomResourceID = pChantSR->DefineResource(CSRDgnDictCustom, L"", CRFNone, Text1.hWnd, Form1.hWnd, -1, 0);
// Enable it to make it active
pChantSR->EnableResource(CSRDgnDictCustom, dictCustomResourceID);
// Disable it
pChantSR->DisableResource(CSRDgnDictCustom, dictCustomResourceID);
// Have recognized speech placed directly in the textbox when it has focus
long dictCustomResourceID;
dictCustomResourceID = pChantSR->DefineResource(CSRDgnDictCustom, "", CRFNone, Text1.hWnd, Form1.hWnd, -1, 0);
// Enable it to make it active
pChantSR->EnableResource(CSRDgnDictCustom, dictCustomResourceID);
// Disable it
pChantSR->DisableResource(CSRDgnDictCustom, dictCustomResourceID);
// Have recognized speech placed directly in the textbox when it has focus
dictCustomResourceID: Integer;
dictCustomResourceID := ChantSR1.DefineResource(CSRDgnDictCustom, '', CRFNone, Text1.Handle, Form1.Handle, -1, 0);
// Enable it to make it active
ChantSR1.EnableResource(CSRDgnDictCustom, dictCustomResourceID);
// Disable it
ChantSR1.DisableResource(CSRDgnDictCustom, dictCustomResourceID);
// Have recognized speech placed directly in the textbox when it has focus
int dictCustomResourceID = JChantSR1.defineResource(ChantSpeechResource.CSRDgnDictCustom, "",ChantResourceFunction.CRFNone, jTextArea1, this, -1, 0);
// Enable it to make it active
JChantSR1.enableResource(ChantSpeechResource.CSRDgnDictCustom, dictCustomResourceID);
// Disable it
JChantSR1.disableResource(ChantSpeechResource.CSRDgnDictCustom, dictCustomResourceID);
// Parse the web page hosting the WChantSR1 object for hypertext links
var resID;
resID = WChantSR1.DefineResource(CSRURL,"",CRFClickLink);
// Voice enable the links
WChantSR1.EnableResource(CSRURL,resID);
// Disable it
WChantSR1.DisableResource(CSRURL,resID);
' Have recognized speech placed directly in the textbox when it has focus
Dim dictCustomResourceID As Integer
dictCustomResourceID = XChantSR1.DefineResource(CSRDgnDictCustom, "", CRFNone, Text1.hWnd, Form1.hWnd, -1, 0)
' Enable it to make it active
XChantSR1.EnableResource CSRDgnDictCustom, dictCustomResourceID
' Disable it
XChantSR1.DisableResource CSRDgnDictCustom, dictCustomResourceID
' Have recognized speech placed directly in the textbox when it has focus
Dim dictCustomResourceID As Integer
dictCustomResourceID = NChantSR1.DefineResource(ChantSpeechResource.CSRDgnDictCustom, "",ChantResourceFunction.CRFNone, text1, Me, -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, "", "");
pChantSR->ShowDialog(CDMicTraining, m_hWnd);
pChantSR->ShowDialog(CDMicTraining, Handle);
ChantSR1.ShowDialog(CDMicTraining, Handle)
JChantSR1.showDialog(ChantDialog.CDMicTraining, this, "", "");
WChantSR1.ShowDialog(CDMicTraining);
XChantSR1.ShowDialog CDMicTraining, Form1.hWnd
NChantSR1.ShowDialog(ChantDialog.CDMicTraining, Me.Handle, "", "")