Last reviewed: 3/23/2024 11:49:42 AM
Delphi VCL and FireMonkey Applications
Develop Object Pascal applications that manage conversations using your favorite version of Delphi.
The following sections describe the steps for integrating VoiceXMLKit with Delphi VCL and FireMonkey applications.
VoiceXMLKit Unit
VoiceXMLKit includes an Object Pascal source file Chant.VoiceXMLKit.pas comprised of the Object Pascal classes that manage VoiceXML converations. 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 VoiceXMLKit Object Pascal classes within your application, first add a project reference to the VoiceXMLKit Object Pascal source files:
- Within your Delphi project, select Project Options.
- Select the Delphi compiler options.
- Add Search path reference to the VoiceXMLKit unit source file directory: C:\Program Files\Chant\VoiceXMLKit 7\Delphi\source.
- Add unit output path reference to the local directory with a period '.' character.
To access the VoiceXMLKit Object Pascal classes within your application, add a reference to the Chant.Shared and Chant.VoiceXMLKit units in your uses clause.
unit Unit1;
interface
uses
..., Chant.Shared, Chant.VoiceXMLKit;
Add an event handler declaration and Object instance variable to the application declarations.
type
TForm1 = class(TForm)
...
procedure VoiceXMLDone(Sender: TObject; Args: TVxmlDoneEventArgs);
procedure VoiceXMLCompileError(Sender: TObject; Args: TVxmlCompileErrorEventArgs);
procedure VoiceXMLDlgAddChoice(Sender: TObject; Args: TVxmlDlgTextEventArgs);
procedure VoiceXMLDlgClearChoices(Sender: TObject; Args: TVxmlDlgEventArgs);
procedure VoiceXMLDlgClearText(Sender: TObject; Args: TVxmlDlgEventArgs);
procedure VoiceXMLDlgCreateDialog(Sender: TObject; Args: TVxmlDlgEventArgs);
procedure VoiceXMLDlgHideChoices(Sender: TObject; Args: TVxmlDlgEventArgs);
procedure VoiceXMLDlgHideDialog(Sender: TObject; Args: TVxmlDlgEventArgs);
procedure VoiceXMLDlgHideText(Sender: TObject; Args: TVxmlDlgEventArgs);
procedure VoiceXMLDlgSelectChoice(Sender: TObject; Args: TVxmlDlgTextEventArgs);
procedure VoiceXMLDlgSetPrompt(Sender: TObject; Args: TVxmlDlgTextEventArgs);
procedure VoiceXMLDlgSetText(Sender: TObject; Args: TVxmlDlgTextEventArgs);
procedure VoiceXMLDlgShowChoices(Sender: TObject; Args: TVxmlDlgEventArgs);
procedure VoiceXMLDlgShowDialog(Sender: TObject; Args: TVxmlDlgEventArgs);
procedure VoiceXMLDlgShowText(Sender: TObject; Args: TVxmlDlgEventArgs);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
_VoiceXMLKit: TVoiceXMLKit;
_VoiceXML: TSAPI5VoiceXML;
_Recognizer: TSAPI5Recognizer;
_Synthesizer: TSAPI5Synthesizer;
Object Instantiation
Instantiate an instance, set the credentials, and set the event handler message.
// Instantiate VoiceXMLKit object
_VoiceXMLKit := TVoiceXMLKit.Create();
if (_VoiceXMLKit <> nil) then
begin
// Set credentials
_VoiceXMLKit.SetCredentials('Credentials');
// Create VoiceXML
_VoiceXML := _VoiceXMLKit.CreateSAPI5VoiceXML();
// Create recognizer
_Recognizer := _VoiceXMLKit.CreateSAPI5Recognizer();
// Create synthesizer
_Synthesizer := _VoiceXMLKit.CreateSAPI5Synthesizer();
_VoiceXML.Done := VoiceXMLDone;
_VoiceXML.CompileError := VoiceXMLCompileError;
_VoiceXML.DlgAddChoice := VoiceXMLDlgAddChoice;
_VoiceXML.DlgClearChoices := VoiceXMLDlgClearChoices;
_VoiceXML.DlgClearText := VoiceXMLDlgClearText;
_VoiceXML.DlgCreateDialog := VoiceXMLDlgCreateDialog;
_VoiceXML.DlgHideChoices := VoiceXMLDlgHideChoices;
_VoiceXML.DlgHideDialog := VoiceXMLDlgHideDialog;
_VoiceXML.DlgHideText := VoiceXMLDlgHideText;
_VoiceXML.DlgSelectChoice := VoiceXMLDlgSelectChoice;
_VoiceXML.DlgSetPrompt := VoiceXMLDlgSetPrompt;
_VoiceXML.DlgSetText := VoiceXMLDlgSetText;
_VoiceXML.DlgShowChoices := VoiceXMLDlgShowChoices;
_VoiceXML.DlgShowDialog := VoiceXMLDlgShowDialog;
_VoiceXML.DlgShowText := VoiceXMLDlgShowText;
end;
VoiceXMLKit applications require the VoiceXMLKit library (CVoiceXMLKit.dll or CVoiceXMLKitX64.dll) and the applicable VoiceXMLKit Speech API library in the same directory as the application .exe.
Speech API | VoiceXMLKit Speech API class | VoiceXMLKit Speech API library |
---|---|---|
Microsoft SAPI 5 | TSAPI5Recognizer or TSAPI5Synthesizer | CVoiceXMLKit.SAPI5.dll or CVoiceXMLKitX64.SAPI5.dll |
Microsoft Speech Platform | TMSPRecognizer or TMSPSynthesizer | CVoiceXMLKit.MSP.dll or CVoiceXMLKitX64.MSP.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.VoiceXMLDone(Sender: TObject; Args: TVxmlDoneEventArgs);
begin
if ((Args <> nil) and (Args.Variables <> nil)) then
begin
...
end;
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 CVoiceXMLKit.dll to the target system and place in the same directory with your application.
- Copy applicable 32-bit VoiceXMLKit 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 CVoiceXMLKitX64.dll to the target system and place in the same directory with your application.
- Copy applicable 64-bit VoiceXMLKit 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\VoiceXMLKit 7\Delphi.