Last reviewed: 3/23/2024 9:23:16 AM
Delphi VCL and FireMonkey Applications
Develop Object Pascal applications that manage lexicons using your favorite version of Delphi.
The following sections describe the steps for integrating LexiconKit with Delphi VCL and FireMonkey applications.
LexiconKit Unit
LexiconKit includes an Object Pascal source file Chant.LexiconKit.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 LexiconKit Object Pascal classes within your application, first add a project reference to the LexiconKit Object Pascal source files:
- Within your Delphi project, select Project Options.
- Select the Delphi compiler options.
- Add Search path reference to the LexiconKit unit source file directory: C:\Program Files\Chant\LexiconKit 10\Delphi\source.
- Add unit output path reference to the local directory with a period '.' character.
To access the LexiconKit Object Pascal classes within your application, add a reference to the Chant.Shared and Chant.LexiconKit units in your uses clause.
unit Unit1;
interface
uses
..., Chant.Shared, Chant.LexiconKit;
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;
_LexiconKit: TLexiconKit;
_Synthesizer: TSAPI5Synthesizer;
Object Instantiation
Instantiate an instance, set the credentials, and set the event handler message.
// Instantiate LexiconKit object
_LexiconKit := TLexiconKit.Create();
if (_LexiconKit <> nil) then
begin
// Set credentials
_LexiconKit.SetCredentials('Credentials');
// Create synthesizer
_Synthesizer := _LexiconKit.CreateSAPI5Synthesizer();
if (_Synthesizer <> nil) then
begin
// Register Event Handler
_Synthesizer.APIError := APIError;
end;
end;
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 | TAcaTTSSynthesizer | CLexiconKit.AcaTTS.dll or CLexiconKitX64.AcaTTS.dll |
Cepstral Swift | TSwiftSynthesizer | CLexiconKit.Swift.dll or CLexiconKitX64.Swift.dll |
Microsoft Azure Speech | TMCSSynthesizer | CLexiconKit.MCS.dll or CLexiconKitX64.MCS.dll |
Microsoft SAPI 5 | TSAPI5Recognizer or TSAPI5Synthesizer | CLexiconKit.SAPI5.dll or CLexiconKitX64.SAPI5.dll |
Microsoft Speech Platform | TMSPRecognizer or TMSPSynthesizer | CLexiconKit.MSP.dll or CLexiconKitX64.MSP.dll |
Microsoft WindowsMedia | TWindowsMediaRecognizer or TWindowsMediaSynthesizer | 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.
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 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 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 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
Delphi VCL and FireMonkey sample projects are installed at the following location:
- Documents\Chant\LexiconKit 10\Delphi.