Last reviewed: 3/23/2024 9:45:21 AM

Delphi VCL and FireMonkey Applications

Develop Object Pascal applications that manage speaker profiles using your favorite version of Delphi.

The following sections describe the steps for integrating ProfileKit with Delphi VCL and FireMonkey applications.

ProfileKit Unit

ProfileKit includes an Object Pascal source file Chant.ProfileKit.pas comprised of the Object Pascal classes that manage grammars. It also includes an Object Pascal source file Chant.Shared.pas comprised of common Object Pascal classes that all Chant libraries use.

To access the ProfileKit Object Pascal classes within your application, first add a project reference to the ProfileKit Object Pascal source files:

  1. Within your Delphi project, select Project Options.
  2. Select the Delphi compiler options.
  3. Add Search path reference to the ProfileKit unit source file directory: C:\Program Files\Chant\ProfileKit 10\Delphi\source.
  4. Add unit output path reference to the local directory with a period '.' character.

To access the ProfileKit Object Pascal classes within your application, add a reference to the Chant.Shared and Chant.ProfileKit units in your uses clause.


unit Unit1;

interface

uses
  ..., Chant.Shared, Chant.ProfileKit;

Add an event handler declaration and Object instance variable to the application declarations.


  type
  TForm1 = class(TForm)
    ...
    procedure APIError(Sender: TObject; Args: TChantAPIErrorEventArgs);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  _ProfileKit: TProfileKit;
  _Recognizer: TSAPI5Recognizer;

Object Instantiation

Instantiate an instance, set the credentials, and set the event handler message.


// Instantiate ProfileKit object
_ProfileKit := TProfileKit.Create();
if (_ProfileKit <> nil) then
begin
    // Set credentials
    _ProfileKit.SetCredentials('Credentials');

    // Create recognizer
    _Recognizer := _ProfileKit.CreateSAPI5Recognizer();

    if (_Recognizer <> nil) then
    begin
        // Register Event Handler
        _Recognizer.APIError := APIError;
    end;
end;

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 5TSAPI5RecognizerCProfileKit.SAPI5.dll or CProfileKitX64.SAPI5.dll
Microsoft Speech PlatformTMSPRecognizerCProfileKit.MSP.dll or CProfileKitX64.MSP.dll
Nuance Dragon NaturallySpeakingTDgnRecognizerCProfileKit.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 training recognition occurred or there was an error.


procedure TForm1.APIError(Sender: TObject; Args: TChantAPIErrorEventArgs);
var
  strErrorMsg: string;
begin
      strErrorMsg := '';
      strErrorMsg := '(' + IntToStr(Args.RC) + ') ';
      strErrorMsg := strErrorMsg + ' ' + IntToStr(Args.Function) + ' ' + Args.Message +  #13 + #10;
      ...
end;

Development and Deployment Checklist

When developing and deploying Delphi 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 Delphi 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 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 Delphi 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 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

Delphi VCL and FireMonkey sample projects are installed at the following location:

  • Documents\Chant\ProfileKit 10\Delphi.