Last reviewed: 7/27/2024 11:50:25 AM
Microsoft Visual C++ Applications
Develop C++ applications that manage conversations using your favorite version of Microsoft Visual C++.
The following sections describe the steps for integrating VoiceXMLKit with Microsoft Visual C++ applications.
VoiceXMLKit Header Files
VoiceXMLKit includes C++ header files comprised of the C++ classes that manage VoiceXML converations and automatically load and unload the runtime DLL.
To access VoiceXMLKit C++ classes within a Visual C++ application, add project references to the following nuget packages:
- Select the application project in the Solution Explorer.
- Right-click the mouse and select the Manage Nuget Packages… menu item.
- Enter Chant in the search bar.
- Select the Chant.VoiceXMLKit.Windows package and press the Install button.
- Select the Chant.Shared.Windows package and press the Install button.
To access the VoiceXMLKit C++ classes within your application, add a reference to the Chant shared and VoiceXMLKit header files in your C++ application header file:
#include "Chant.Shared.Windows.h"
#include "Chant.VoiceXMLKit.Windows.h"
Add a reference in your C++ application source file to the Chant shared and VoiceXMLKit code needed to dynamically load and unload the runtime DLL:
#include "Chant.Shared.Windows.cpp"
#include "Chant.VoiceXMLKit.Windows.cpp"
Object Instantiation
Declare a global variable for the VoiceXMLKit class, instantiate instance, set the credentials, and set the event handler message.
Add the following to your application header file:
protected:
CVoiceXMLKit* _VoiceXMLKit;
CSAPI5Recognizer* _Recognizer;
};
Add the following to your application source file:
// Instantiate VoiceXMLKit object
_VoiceXMLKit = new CVoiceXMLKit();
if (_VoiceXMLKit != NULL)
{
// Set credentials
_VoiceXMLKit->SetCredentials(L"Credentials");
// Create VoiceXML
_VoiceXML = _VoiceXMLKit->CreateSAPI5VoiceXML();
if (_VoiceXML != NULL)
{
// Create recognizer
_Recognizer = _VoiceXMLKit->CreateSAPI5Recognizer();
// Create synthesizer
_Synthesizer = _VoiceXMLKit->CreateSAPI5Synthesizer();
// Register Event Handlers
_VoiceXML->SetDone(VoiceXMLDone);
_VoiceXML->SetCompileError(VoiceXMLCompileError);
_VoiceXML->SetDlgAddChoice(VoiceXMLDlgAddChoice);
_VoiceXML->SetDlgClearChoices(VoiceXMLDlgClearChoices);
_VoiceXML->SetDlgClearText(VoiceXMLDlgClearText);
_VoiceXML->SetDlgCreateDialog(VoiceXMLDlgCreateDialog);
_VoiceXML->SetDlgHideChoices(VoiceXMLDlgHideChoices);
_VoiceXML->SetDlgHideDialog(VoiceXMLDlgHideDialog);
_VoiceXML->SetDlgHideText(VoiceXMLDlgHideText);
_VoiceXML->SetDlgSelectChoice(VoiceXMLDlgSelectChoice);
_VoiceXML->SetDlgSetPrompt(VoiceXMLDlgSetPrompt);
_VoiceXML->SetDlgSetText(VoiceXMLDlgSetText);
_VoiceXML->SetDlgShowChoices(VoiceXMLDlgShowChoices);
_VoiceXML->SetDlgShowDialog(VoiceXMLDlgShowDialog);
_VoiceXML->SetDlgShowText(VoiceXMLDlgShowText);
}
}
VoiceXMLKit applications require the VoiceXMLKit library (CVoiceXMLKit.dll or CVoiceXMLKitX64.dll) and the applicable VoiceXMLKit Speech API library in the same directory as the application .exe.
Speech API | VoiceXMLKit Speech API class | VoiceXMLKit Speech API library |
---|---|---|
Microsoft SAPI 5 | CSAPI5Recognizer or CSAPI5Synthesizer | CVoiceXMLKit.SAPI5.dll or CVoiceXMLKitX64.SAPI5.dll |
Microsoft Speech Platform | CMSPRecognizer or CMSPSynthesizer | CVoiceXMLKit.MSP.dll or CVoiceXMLKitX64.MSP.dll |
Event Callbacks
Event callbacks are the mechanism in which the class object sends information back to the application such as compilation is complete or there was an error.
void CALLBACK VoiceXMLDone(void* Sender, CVxmlDoneEventArgs* Args)
{
if ((Args != NULL) && (Args->GetVariables()->GetCount() > 0))
{
...
}
}
Development and Deployment Checklist
When developing and deploying C++ applications, ensure you have a valid license, bundle the correct Chant class library, and configure your installation properly on the target system. Review the following checklist before developing and deploying your applications:
- Develop and deploy C++ applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
- Copy CVoiceXMLKit.dll to the target system and place in the same directory with your application.
- Copy applicable 32-bit VoiceXMLKit Speech API DLL(s) to the target system and place in the same directory with your application.
- Develop and deploy C++ applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
- Copy CVoiceXMLKitX64.dll to the target system and place in the same directory with your application.
- Copy applicable 64-bit VoiceXMLKit Speech API DLL(s) to the target system and place in the same directory with your application.
Sample Projects
Microsoft Visual C++ sample projects that use nuget packages may be found in the following directory of the vssamples.zip download:
- Chant\VoiceXMLKit 7\CDLL.