Last reviewed: 7/27/2024 9:46:18 AM

Microsoft Visual C++ Applications

Develop C++ applications that manage speaker profiles using your favorite version of Microsoft Visual C++.

The following sections describe the steps for integrating ProfileKit with Microsoft Visual C++ applications.

ProfileKit Header Files

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

To access ProfileKit 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.ProfileKit.Windows package and press the Install button.
  • Chant ProfileKit Windows package
  • Select the Chant.Shared.Windows package and press the Install button.
  • Chant Shared Windows package

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


#include "Chant.Shared.Windows.h"
#include "Chant.ProfileKit.Windows.h"

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


#include "Chant.Shared.Windows.cpp"
#include "Chant.ProfileKit.Windows.cpp"

Object Instantiation

Declare a global variable for the ProfileKit class, instantiate instance, set the credentials, and set the event handler message.

Add the following to your application header file:


    protected:
    CProfileKit* _ProfileKit;
    CSAPI5Profile* _Profile;
    CSAPI5Recognizer* _Recognizer;

Add the following to your application source file:


// Instantiate ProfileKit object
_ProfileKit = new CProfileKit();
if (_ProfileKit != NULL)
{
    // Set credentials
    _ProfileKit->SetCredentials(L"Credentials");
    // Create recognizer
    _Recognizer = _ProfileKit->CreateSAPI5Recognizer();
    if (_Recognizer != NULL)
    {
        // Optionally, register Event Handler
        _Recognizer->SetAPIError(APIError);
    }
}

ProfileKit applications require the ProfileKit library (CProfileKit.dll or CProfileKitX64.dll) and the applicable ProfileKit Speech API library in the same directory as the application .exe.

Speech API ProfileKit Speech API class ProfileKit Speech API library
Microsoft SAPI 5CSAPI5RecognizerCProfileKit.SAPI5.dll or CProfileKitX64.SAPI5.dll
Microsoft Speech PlatformCMSPRecognizerCProfileKit.MSP.dll or CProfileKitX64.MSP.dll
Nuance Dragon NaturallySpeakingCDgnRecognizerCProfileKit.Dgn.dll or CProfileKitX64.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 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 CProfileKit.dll to the target system and place in the same directory with your application.
  • Copy applicable 32-bit ProfileKit 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 CProfileKitX64.dll to the target system and place in the same directory with your application.
  • Copy applicable 64-bit ProfileKit 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\ProfileKit 10\CDLL.