Last reviewed: 3/23/2024 9:22:32 AM
C++Builder VCL and FireMonkey Applications
Develop C++ applications that manage lexicons using your favorite version of C++Builder.
The following sections describe the steps for integrating LexiconKit with C++Builder VCL and FireMonkey applications.
LexiconKit Header Files
LexiconKit includes C++ header files comprised of the C++Builder classes that manage grammars and automatically load and unload the runtime DLL.
To access the LexiconKit 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 LexiconKit header files directory: C:\Program Files\Chant\LexiconKit 10\CBuilder\include.
- For 64-bit apps, add Win64 as a conditional to the compiler options.
To access the LexiconKit C++Builder classes within your application, add a reference to the Chant shared and LexiconKit header files in your C++Builder application header file.
#include "Chant.Shared.h"
#include "Chant.LexiconKit.h"
Add a reference in your C++Builder application source file to the Chant shared and LexiconKit code needed to dynamically load and unload the runtime DLL.
#include "Chant.Shared.cpp"
#include "Chant.LexiconKit.cpp"
Object Instantiation
Declare a global variable for the LexiconKit class, instantiate an instance, set the credentials, and set the event handlers.
Add the following to your application header file:
private: // User declarations
CLexiconKit* _LexiconKit;
CSAPI5Synthesizer* _Synthesizer;
};
// Event handler (optional)
void CALLBACK APIError(void* Sender, CChantAPIErrorEventArgs* Args);
Add the following to your application source file:
// Instantiate LexiconKit object
_LexiconKit = new CLexiconKit();
if (_LexiconKit != NULL)
{
// Set credentials
_LexiconKit->SetCredentials("Credentials");
// Create synthesizer
_Synthesizer = _LexiconKit->CreateSAPI5Synthesizer();
if (_Synthesizer != NULL)
{
// Optionally, register Event Handler
_Synthesizer->SetAPIError(APIError);
}
}
LexiconKit applications require the LexiconKit library (CLexiconKit.dll or CLexiconKitX64.dll) and the applicable LexiconKit Speech API library in the same directory as the application .exe.
Speech API | LexiconKit Speech API class | LexiconKit Speech API library |
---|---|---|
Acapela TTS | CAcaTTSSynthesizer | CLexiconKit.AcaTTS.dll or CLexiconKitX64.AcaTTS.dll |
Cepstral Swift | CSwiftSynthesizer | CLexiconKit.Swift.dll or CLexiconKitX64.Swift.dll |
Microsoft Azure Speech | CMCSSynthesizer | CLexiconKit.MCS.dll or CLexiconKitX64.MCS.dll |
Microsoft SAPI 5 | CSAPI5Recognizer or CSAPI5Synthesizer | CLexiconKit.SAPI5.dll or CLexiconKitX64.SAPI5.dll |
Microsoft Speech Platform | CMSPRecognizer or CMSPSynthesizer | CLexiconKit.MSP.dll or CLexiconKitX64.MSP.dll |
Microsoft WindowsMedia | CWindowsMediaRecognizer or CWindowsMediaSynthesizer | CLexiconKit.WinRT.dll or CLexiconKitX64.WinRT.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 APIError(void* Sender, CChantAPIErrorEventArgs* Args)
{
// Format transcript message
String strErrorMsg = "(" + IntToStr(Args->GetRC()) + ") ";
strErrorMsg = strErrorMsg + " " + Args->GetFunction() + " " + Args->GetMessage() + "\r\n";
...
}
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 CLexiconKit.dll to the target system and place in the same directory with your application.
- Copy applicable 32-bit LexiconKit Speech API DLL(s) to the target system and place in the same directory with your application.
- Copy applicable 32-bit Microsoft Cognitive Services client DLLs to the target system and place in the same directory with your application when using Azure Speech.
- 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 CLexiconKitX64.dll to the target system and place in the same directory with your application.
- Copy applicable 64-bit LexiconKit Speech API DLL(s) to the target system and place in the same directory with your application.
- Copy applicable 64-bit Microsoft Cognitive Services client DLLs to the target system and place in the same directory with your application when using Azure Speech.
Sample Projects
C++Builder VCL and FireMonkey sample projects are installed at the following location:
- Documents\Chant\LexiconKit 10\CBuilder.