Last reviewed: 7/27/2024 9:24:22 AM
Microsoft Visual C++ Applications
Develop C++ applications that manage grammars using your favorite version of Microsoft Visual C++.
The following sections describe the steps for integrating LexiconKit with Microsoft Visual C++ applications.
LexiconKit Header Files
LexiconKit includes C++ header files comprised of the C++ classes that manage grammars and automatically load and unload the runtime DLL.
To access LexiconKit 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.LexiconKit.Windows package and press the Install button.
- Select the Chant.Shared.Windows package and press the Install button.


To access the LexiconKit C++ classes within your application, add a reference to the Chant shared and LexiconKit header files in your C++ application header file:
#include "Chant.Shared.Windows.h"
#include "Chant.LexiconKit.Windows.h"
Add a reference in your C++ application source file to the Chant shared and LexiconKit code needed to dynamically load and unload the runtime DLL:
#include "Chant.Shared.Windows.cpp"
#include "Chant.LexiconKit.Windows.cpp"
Object Instantiation
Declare a global variable for the LexiconKit class, instantiate instance, set the credentials, and set the event handler message.
Add the following to your application header file:
protected:
CLexiconKit* _LexiconKit;
CSAPI5Synthesizer* _Synthesizer;
};
Add the following to your application source file:
// Instantiate LexiconKit object
_LexiconKit = new CLexiconKit();
if (_LexiconKit != NULL)
{
// Set credentials
_LexiconKit->SetCredentials(L"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
CString strErrorMsg;
strErrorMsg.Format(L"(%d) %s %s\r\n", Args->GetRC(), Args->GetFunction(), Args->GetMessage());
...
}
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 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.
- 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 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
Microsoft Visual C++ sample projects that use nuget packages may be found in the following directory of the vssamples.zip download:
- Chant\LexiconKit 10\CDLL.