Last reviewed: 3/23/2024 11:48:14 AM
C++Builder VCL and FireMonkey Applications
Develop C++ applications that manage conversations using your favorite version of C++Builder.
The following sections describe the steps for integrating VoiceXMLKit with C++Builder VCL and FireMonkey applications.
VoiceXMLKit Header Files
VoiceXMLKit includes C++ header files comprised of the C++Builder classes that manage grammars and automatically load and unload the runtime DLL.
To access the VoiceXMLKit C++Builder classes within your application, first add a project reference to the C++Builder header include files:
- Within your C++Builder project, select Project Options.
- Select the C++Builder compiler options.
- Add Include path reference to the VoiceXMLKit header files directory: C:\Program Files\Chant\VoiceXMLKit 7\CBuilder\include.
- For 64-bit apps, add Win64 as a conditional to the compiler options.
To access the VoiceXMLKit C++Builder classes within your application, add a reference to the Chant shared and VoiceXMLKit header files in your C++Builder application header file.
#include "Chant.Shared.h"
#include "Chant.VoiceXMLKit.h"
Add a reference in your C++Builder application source file to the Chant shared and VoiceXMLKit code needed to dynamically load and unload the runtime DLL.
#include "Chant.Shared.cpp"
#include "Chant.VoiceXMLKit.cpp"
Object Instantiation
Declare a global variable for the VoiceXMLKit class, instantiate an instance, set the credentials, and set the event handlers.
Add the following to your application header file:
private:
// User declarations
CVoiceXMLKit* _VoiceXMLKit;
CSAPI5Synthesizer* _Synthesizer;
CSAPI5Recognizer* _Recognizer;
CSAPI5VoiceXML* _VoiceXML;
};
void CALLBACK VoiceXMLDone(void* Sender, CVxmlDoneEventArgs* Args);
void CALLBACK VoiceXMLCompileError(void* Sender, CVxmlCompileErrorEventArgs* Args);
void CALLBACK VoiceXMLDlgAddChoice(void* Sender, CVxmlDlgTextEventArgs* Args);
void CALLBACK VoiceXMLDlgClearChoices(void* Sender, CVxmlDlgEventArgs* Args);
void CALLBACK VoiceXMLDlgClearText(void* Sender, CVxmlDlgEventArgs* Args);
void CALLBACK VoiceXMLDlgCreateDialog(void* Sender, CVxmlDlgEventArgs* Args);
void CALLBACK VoiceXMLDlgHideChoices(void* Sender, CVxmlDlgEventArgs* Args);
void CALLBACK VoiceXMLDlgHideDialog(void* Sender, CVxmlDlgEventArgs* Args);
void CALLBACK VoiceXMLDlgHideText(void* Sender, CVxmlDlgEventArgs* Args);
void CALLBACK VoiceXMLDlgSelectChoice(void* Sender, CVxmlDlgTextEventArgs* Args);
void CALLBACK VoiceXMLDlgSetPrompt(void* Sender, CVxmlDlgTextEventArgs* Args);
void CALLBACK VoiceXMLDlgSetText(void* Sender, CVxmlDlgTextEventArgs* Args);
void CALLBACK VoiceXMLDlgShowChoices(void* Sender, CVxmlDlgEventArgs* Args);
void CALLBACK VoiceXMLDlgShowDialog(void* Sender, CVxmlDlgEventArgs* Args);
void CALLBACK VoiceXMLDlgShowText(void* Sender, CVxmlDlgEventArgs* Args);
Add the following to your application source file:
// Instantiate VoiceXMLKit object
_VoiceXMLKit = new CVoiceXMLKit();
if (_VoiceXMLKit != NULL)
{
// Set credentials
_VoiceXMLKit->SetCredentials("Credentials");
// Create VoiceXML
_VoiceXML = _VoiceXMLKit->CreateSAPI5VoiceXML();
// 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()->Count > 0))
{
...
}
}
Development and Deployment Checklist
When developing and deploying C++Builder VCL and FireMonkey 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++Builder VCL and FireMonkey 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.
- Deploy C++Builder VCL and FireMonkey 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
C++Builder VCL and FireMonkey sample projects are installed at the following location:
- Documents\Chant\VoiceXMLKit 7\CBuilder.