Last reviewed: 7/27/2024 8:58:16 AM

Chant Talk&Listen

Chant Talk&Listen enables applications to synthesize and recognize speech.

Simple Speech

Sometimes applications need a simple way to synthesize and recognize. Chant Talk&Listen application helper enables applications to synthesize and recognize speech without having to worry about events, properties, and callback handlers.


// Instantiate TalkListen
NTalkListen _TalkListen = new NTalkListen();
if (_TalkListen != null)
{
    // Set credentials
    _TalkListen.SetCredentials("Credentials");
    NSAPI5Synthesizer _Synthesizer = _TalkListen.CreateSAPI5Synthesizer();
    if (_Synthesizer != null)
    {
        _Synthesizer.Talk("This is the easiest way to synthesize.");
    }
    NSAPI5Recognizer _Recognizer = _TalkListen.CreateSAPI5Recognizer();
    if (_Recognizer != null)
    {
        string recognitionResults = _Recognizer.Listen();
    }
}
    

// Instantiate TalkListen object
CTalkListen* _TalkListen = new CTalkListen();
if (_TalkListen =! NULL)
{
    // Set credentials
    _TalkListen->SetCredentials(L"Credentials");
    // Create synthesizer
    CSAPI5Synthesizer* _Synthesizer = _TalkListen->CreateSAPI5Synthesizer();
    if (_Synthesizer != NULL)
    {
        _Synthesizer->Talk(L"This is the easiest way to synthesize.");
    }
    // Create recognizer
    CSAPI5Recognizer* _Recognizer = _TalkListen->CreateSAPI5Recognizer();
    if (_Recognizer != NULL)
    {
        wchar_t* pszRecognitionResults = _Recognizer->Listen();
    }
}
    

// Instantiate TalkListen object
CTalkListen* _TalkListen = new CTalkListen();
if (_TalkListen =! NULL)
{
    // Set credentials
    _TalkListen->SetCredentials("Credentials");
    // Create synthesizer
    CSAPI5Synthesizer* _Synthesizer = _TalkListen->CreateSAPI5Synthesizer();
    if (_Synthesizer != NULL)
    {
        _Synthesizer->Talk("This is the easiest way to synthesize.");
    }
    // Create recognizer
    CSAPI5Recognizer* _Recognizer = _TalkListen->CreateSAPI5Recognizer();
    if (_Recognizer != NULL)
    {
        String recognitionResults = _Recognizer->Listen();
    }
}
    

var
  _TalkListen: TTalkListen;
  _Recognizer: TSAPI5Recognizer;
  _Synthesizer: TSAPI5Synthesizer;
  recognitionResults: string;
begin
    // Instantiate TalkListen object
    _TalkListen := TTalkListen.Create();
    if (_TalkListen <> nil) then
    begin
        // Set credentials
        _TalkListen.SetCredentials('Credentials');
        // Create synthesizer
        _Synthesizer := _TalkListen.CreateSAPI5Synthesizer();
        if (_Synthesizer <> nil) then
        begin
            _Synthesizer.Talk('This is the easiest way to synthesize.');
        end;
        // Create recognizer
        _Recognizer := _TalkListen.CreateSAPI5Recognizer();
        if (_Recognizer <> nil) then
        begin
            recognitionResults := _Recognizer.Listen();
        end;
    end;
end;
    

// Create TalkListen object
JTalkListen _TalkListen = new JTalkListen();
// Set credentials
_TalkListen.setCredentials("Credentials");
JSAPI5Synthesizer _Synthesizer = _TalkListen.createSAPI5Synthesizer();
if (_Synthesizer != null)
{
        _Synthesizer.talk("This is the easiest way to synthesize.");
}
JSAPI5Recognizer _Recognizer = _TalkListen.createSAPI5Recognizer();
if (_Recognizer != null)
{
        String recognitionResults = _Recognizer.listen();
}
    

Dim _TalkListen As NTalkListen
Dim _Recognizer As NSAPI5Recognizer
Dim _Synthesizer As NSAPI5Synthesizer
Dim resultsResults As String
    ' Instantiate TalkListen
    _TalkListen = New NTalkListen()
    If (_TalkListen IsNot Nothing) Then
        ' Set credentials
        _TalkListen.SetCredentials("Credentials")
        _Synthesizer = _TalkListen.CreateSAPI5Synthesizer()
        If (_Synthesizer IsNot Nothing) Then
            _Synthesizer.Talk("This is the easiest way to synthesize.")
        End If
        _Recognizer = _TalkListen.CreateSAPI5Recognizer()
        If (_Recognizer IsNot Nothing) Then
            resultsResults = _Recognizer.Listen()
        End If
    End If
    

Syntax Options

The Talk method has two optional parameters that may be used to control speech synthesis:

  • text - (required) The text to synthesize.
  • name - (optional) The speech synthesizer voice name or language.
  • async - (optional) True or False for asynchronous synthesis. Note some synthesizers only perform asynchronous synthesis. The default is False.

The Listen method has four optional parameters that may be used to control speech recognition:

  • timeout - (optional) The maximum time to listen in seconds. If the value is 0, listening occurs until speech is recognized.
  • commands - (optional) A comma separated list of phrases to use for recognition.
  • grammar - (optional) The file path of a speech recognition grammar to use for recognition.
  • name - (optional) The speech recognizer name or language.

Recognizer and Synthesizer objects may be one of the support SpeechKit classes as follows:

Speech API SpeechKit Speech API class SpeechKit Speech API library
Acapela TTSxAcaTTSSynthesizerCSpeechKit.AcaTTS.dll or CSpeechKitX64.AcaTTS.dll
Cepstral SwiftxSwiftSynthesizerCSpeechKit.Swift.dll or CSpeechKitX64.Swift.dll
CereProc CereVoicexCereVoiceSynthesizerCSpeechKit.CereVoice.dll or CSpeechKitX64.CereVoice.dll
Microsoft SAPI 5xSAPI5Recognizer or xSAPI5SynthesizerCSpeechKit.SAPI5.dll or CSpeechKitX64.SAPI5.dll
Microsoft Speech PlatformxMSPRecognizer or xMSPSynthesizerCSpeechKit.MSP.dll or CSpeechKitX64.MSP.dll
Microsoft WindowsMedia (WinRT C++)xWindowsMediaRecognizer or xWindowsMediaSynthesizerCSpeechKit.WinRT.dll or CSpeechKitX64.WinRT.dll
Nuance Dragon NaturallySpeakingxDgnRecognizerCSpeechKit.Dgn.dll or CSpeechKitX64.Dgn.dll

where x is C for C++Builder and C++; T for Delphi; J for Java; and N for .NET.

Development and Deployment

Talk&Listen applications require the Talk&Listen library and the applicable SpeechKit Speech API library:

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

To access the Talk&Listen C++Builder classes within your application, add a reference to the Talk&Listen header files in your C++Builder application header file.

#include "Chant.TalkListen.h"

Add a reference in your C++Builder application source file to the Talk&Listen code needed to dynamically load and unload the runtime DLL.

#include "Chant.TalkListen.cpp"

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 CTalkListen.dll (CTalkListenX64.dll) to the target system and place in the same directory with your application.
  • Copy applicable 32-bit (64-bit) SpeechKit Speech API DLL(s) to the target system and place in the same directory with your application.

To access Talk Listen earch 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.TalkListen.Windows package and press the Install button.
  • Chant Talk&Listen Windows package

To access the Talk&Listen C++ classes within your application, add a reference to the Talk&Listen header files in your C++ application header file:

#include "Chant.TalkListen.Windows.h"

Add a reference in your C++ application source file to the Talk&Listen code needed to dynamically load and unload the runtime DLL:

#include "Chant.TalkListen.Windows.cpp"

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++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 CTalkListen.dll (CTalkListenX64.dll) to the target system and place in the same directory with your application.
  • Copy applicable 32-bit (64-bit) SpeechKit Speech API DLL(s) to the target system and place in the same directory with your application.

To access the Talk&Listen Object Pascal classes within your application, first add a project reference to the Talk&Listen 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 Talk&Listen unit source file directory: C:\Program Files\Chant\TalkListen 5\Delphi\source.
  4. Add unit output path reference to the local directory with a period '.' character.

To access the Talk&Listen Object Pascal classes within your application, add a reference to the Chant.TalkListen units in your uses clause.

unit Unit1;

interface

uses
  ..., Chant.TalkListen;

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 CTalkListen.dll (CTalkListenX64.dll) to the target system and place in the same directory with your application.
  • Copy applicable 32-bit (64-bit) SpeechKit Speech API DLL(s) to the target system and place in the same directory with your application.

To access the Talk&Listen Java classes within your application, add the class libraries to your JDK environment:

  1. copy the JTalkListen.DLL (JTalkListenX64.DLL) file to your Java JDK bin directory;
  2. copy the applicable 32-bit (64-bit) speech API DLL file(s) to your Java JDK bin directory;
  3. copy the talklisten.jar library to your Java JDK lib; and
  4. append a path reference for your Java JDK lib\talklisten.jar path as a classpath property in your system settings.

To access the Talk&Listen Java classes within your application, add references to the Talk&Listen class libraries in your code:

import com.talklisten.*;

When developing and deploying Java applications, ensure you have a valid license, bundle the correct Chant class libraries, and configure your installation properly on the target system. Review the following checklist before developing and deploying your applications:

  • Develop and deploy Java applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
  • Copy talklisten.jar to the target system Java JRE lib directory and/or ensure the classpath includes the path where the talklisten.jar library is placed on your target system.
  • Copy JTalkListen.dll (JTalkListenX64.dll) to the target system Java JRE bin directory.
  • Copy applicable 32-bit (64-bit) SpeechKit Speech API DLL(s) to the target system Java JRE bin directory.

To access Talk&Listen .NET classes, add project references to the following nuget packages depending on desired speech APIs:

  • 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.TalkListen.Windows package and press the Install button.
  • Chant Talk&Listen Windows package

To access the Talk&Listen .NET classes within applications, add references to the Talk&Listen assemblies in your code.

using System;
...
using Chant.TalkListen.Windows;

or

Imports Chant.TalkListen.Windows
Class MainWindow
...

When developing and deploying .NET applications, ensure you have a valid license, bundle the correct Chant class libraries, and configure your installation properly on the target system. Review the following checklist before developing and deploying your applications:

  • Develop and deploy .NET applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
  • Copy Chant.TalkListen.Windows.dll assembly to the target system or merge them with your application using an obfuscator like .NET Reactor by Eziriz.
  • Copy applicable 32-bit (64-bit) SpeechKit Speech API DLL(s) to the target system and place in the same directory with your application.
  • Copy NTalkListen.dll to the target system,
    • register as a COM library on the target system, or
    • place in the same directory with .NET application and include an App.manifest with a dependent assembly declaration:
      
      <dependency>
          <dependentAssembly>
                  <assemblyIdentity type="win32" name="Chant.TalkListen.Windows" version="5.0.0.0" publicKeyToken="b7bf58a6a1b083a7" />
          </dependentAssembly>
      </dependency>
      

Sample Projects

Sample projects are installed at the following location:

C++Builder VCL and FireMonkey sample projects are installed at the following location:

  • Documents\Chant\TalkListen 5\CBuilder.

Microsoft Visual C++ sample projects that use nuget packages may be found in the following directory of the vssamples.zip download:

  • Chant\TalkListen 5\CDLL.

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

  • Documents\Chant\TalkListen 5\Delphi.

Java sample projects are installed at the following location:

  • Documents\Chant\TalkListen 5\Java.

.NET sample projects that use nuget packages may be found in the following directory of the vssamples.zip download:

  • Chant\TalkListen 5\NET\Windows\cs and
  • Chant\TalkListen 5\NET\Windows\vb.