Last reviewed: 3/23/2024 10:21:25 AM

C++Builder VCL and FireMonkey Applications

Develop C++ applications that speak and listen using your favorite version of C++Builder.

The following sections describe the steps for integrating SpeechKit with C++Builder VCL and FireMonkey applications.

SpeechKit Header Files

SpeechKit includes C++ header files comprised of the C++Builder classes that manage grammars and automatically load and unload the runtime DLL.

To access the SpeechKit 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 SpeechKit header files directory: C:\Program Files\Chant\SpeechKit 13\CBuilder\include.
  • For 64-bit apps, add Win64 as a conditional to the compiler options.

To access the SpeechKit C++Builder classes within your application, add a reference to the Chant shared and SpeechKit header files in your C++Builder application header file.


#include "Chant.Shared.h"
#include "Chant.SpeechKit.h"

Add a reference in your C++Builder application source file to the Chant shared and SpeechKit code needed to dynamically load and unload the runtime DLL.


#include "Chant.Shared.cpp"
#include "Chant.SpeechKit.cpp"

Object Instantiation

Declare a global variable for the SpeechKit class, instantiate an instance, set the credentials, and set the event handlers.

Add the following to your application header file:


    private:		// User declarations
    CSpeechKit* _SpeechKit;
    CChantRecognizer* _Recognizer;
    CChantSynthesizer* _Synthesizer;
};
// Event handlers
void CALLBACK RecognitionCommand(void* Sender, CRecognitionCommandEventArgs* Args);
void CALLBACK WordPosition(void* Sender, CWordPositionEventArgs* Args);

Add the following to your application source file:


// Instantiate SpeechKit object
_SpeechKit = new CSpeechKit();
if (_SpeechKit =! NULL)
{
    // Set credentials
    _SpeechKit->SetCredentials("Credentials");
    // Create recognizer
    _Recognizer = _SpeechKit->CreateChantRecognizer();
    if (_Recognizer != NULL)
    {
        // Register Event Handlers
        _Recognizer->SetRecognitionCommand(RecognitionCommand);
    }
    // Create synthesizer
    _Synthesizer = _SpeechKit->CreateChantSynthesizer();
    if (_Synthesizer != NULL)
    {
        // Register Event Handlers
        _Synthesizer->SetWordPosition(WordPosition);
    }
}

Windows applications require the SpeechKit library (CSpeechKit.dll or CSpeechKitX64.dll) and the applicable SpeechKit Speech API library in the same directory as the application .exe.

Speech API SpeechKit Speech API class SpeechKit Speech API library
Acapela TTSCAcaTTSSynthesizerCSpeechKit.AcaTTS.dll or CSpeechKitX64.AcaTTS.dll
Cepstral SwiftCSwiftSynthesizerCSpeechKit.Swift.dll or CSpeechKitX64.Swift.dll
CereProc CereVoiceCCereVoiceSynthesizerCSpeechKit.CereVoice.dll or CSpeechKitX64.CereVoice.dll
Microsoft Azure SpeechCMCSRecognizer or CMCSSynthesizerCSpeechKit.MCS.dll or CSpeechKitX64.MCS.dll
Microsoft SAPI 5CSAPI5Recognizer or CSAPI5SynthesizerCSpeechKit.SAPI5.dll or CSpeechKitX64.SAPI5.dll
Microsoft Speech PlatformCMSPRecognizer or CMSPSynthesizerCSpeechKit.MSP.dll or CSpeechKitX64.MSP.dll
Microsoft WindowsMedia (WinRT C++)CChantRecognizer or CChantSynthesizerCSpeechKit.WinRT.dll or CSpeechKitX64.WinRT.dll
Microsoft WindowsMedia (WinRT C++)CWindowsMediaRecognizer or CWindowsMediaSynthesizerCSpeechKit.WinRT.dll or CSpeechKitX64.WinRT.dll
Nuance Dragon NaturallySpeakingCDgnRecognizerCSpeechKit.Dgn.dll or CSpeechKitX64.Dgn.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 RecognitionCommand(void* Sender, CRecognitionCommandEventArgs* Args)
{
    // Get the command
    if ((Args != NULL) && (Args->GetPhrase().Length() > 0))
    {
        ...
    }
}
void CALLBACK WordPosition(void* Sender, CWordPositionEventArgs* Args)
{
    if (Args != NULL) 
    {
        int startPosition = Args->GetPosition();
        int wordLength = Args->GetLength();
        ...
    }
}

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 CSpeechKit.dll to the target system and place in the same directory with your application.
  • Copy applicable 32-bit SpeechKit 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 CSpeechKitX64.dll to the target system and place in the same directory with your application.
  • Copy applicable 64-bit SpeechKit 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\SpeechKit 13\CBuilder.