Last reviewed: 7/27/2024 8:57:33 AM
Chant Speech Manager
Chant Speech Manager enables applications to create and schedule speech processing requests. A request can specify as much or as little as needed. For example, a request can specify a speech API, engine, language, or allow Speech Manager to select based on availability.
Speech Manager Requests
There are two types of speech requests supported: transcription and speech synthesis.
With transcription requests, audio streams (i.e., buffers and files) serve as audio source for speech recognition.
With synthesis requests, audio is generated from synthesizing speech from text and returned as buffers, file, or streamed for live playback.
Requests are created, scheduled, and destroyed. A request is created with optional parameters that specify the details for transcription or synthesis. Once a request is created, it can be managed with various priorities:
- Cancel - cancel the request;
- Interrupt - cancel the current request and process this request immediately (speech synthesis only);
- Priority - place the request at the head of the queue to be the next request processed; or
- Schedule - append the request at the end of the queue to be processed.
The request can be destroyed when appropriate by the application.
Speech Manager uses the SpeechKit speech API libraries to process the requests. All SpeechKit speech API property setting and event handling is supported.
// Instantiate SpeechManager
NSpeechManager _SpeechManager = new NSpeechManager();
if (_SpeechManager != null)
{
// Set credentials
_SpeechManager.SetCredentials("Credentials");
// Create transcription request
NChantTranscribeAudioRequest transcribeRequest = _SpeechManager.CreateTranscribeAudioRequest("", "", "myaudio.wav");
if (transcribeRequest != null)
{
// Register for recognition events
transcribeRequest.RecognitionDictation += Recognizer_RecognitionDictation;
// Optionally register for begin/end events
transcribeRequest.AudioSourceStart += Recognizer_AudioSourceStart;
transcribeRequest.AudioSourceStop += Recognizer_AudioSourceStop;
// Schedule request
transcribeRequest.ScheduleRequest();
// Since we no longer need it, destroy it
transcribeRequest.Dispose();
}
// Create synthesis request
NChantSpeakRequest speakRequest = _SpeechManager.CreateSpeakRequest("See how easy it is to talk with Speech Manager.");
if (speakRequest != null)
{
// Optionally register for begin/end events
speakRequest.AudioDestStart += Synthesizer_AudioDestStart;
speakRequest.AudioDestStop += Synthesizer_AudioDestStop;
speakRequest.Done += Synthesizer_TTSDone;
speakRequest.Started += Synthesizer_TTSStarted;
// Schedule request
speakRequest.ScheduleRequest();
// Since we no longer need it, destroy it
speakRequest.Dispose();
}
}
// Instantiate SpeechManager object
CSpeechManager* _SpeechManager = new CSpeechManager();
if (_SpeechManager =! NULL)
{
// Set credentials
_SpeechManager->SetCredentials(L"Credentials");
// Create transcription request
CChantTranscribeAudioRequest* pTranscribeRequest = _SpeechManager->CreateTranscribeAudioRequest(L"", L"", L"myaudio.wav");
if (pTranscribeRequest != NULL)
{
// Register for recognition events
pTranscribeRequest->SetRecognitionDictation(RecognitionDictation);
// Optionally register for begin/end events
pTranscribeRequest->SetAudioSourceStart(AudioSourceStart);
pTranscribeRequest->SetAudioSourceStop(AudioSourceStop);
// Schedule request
pTranscribeRequest->ScheduleRequest();
// Since we no longer need it, destroy it
delete pTranscribeRequest;
}
// Create synthesis request
CChantSpeakRequest* pSpeakRequest = _SpeechManager->CreateSpeakRequest(L"See how easy it is to talk with Speech Manager.");
if (pSpeakRequest != NULL)
{
// Optionally register for begin/end events
pSpeakRequest->SetAudioDestStart(AudioDestStart);
pSpeakRequest->SetAudioDestStop(AudioDestStop);
pSpeakRequest->SetDone(TTSDone);
pSpeakRequest->SetStarted(TTSStarted);
// Schedule request
pSpeakRequest->ScheduleRequest();
// Since we no longer need it, destroy it
delete pSpeakRequest;
}
}
// Instantiate SpeechManager object
CSpeechManager* _SpeechManager = new CSpeechManager();
if (_SpeechManager =! NULL)
{
// Set credentials
_SpeechManager->SetCredentials("Credentials");
// Create transcription request
CChantTranscribeAudioRequest* pTranscribeRequest = _SpeechManager->CreateTranscribeAudioRequest("","","myaudio.wav");
if (pTranscribeRequest != NULL)
{
// Register for recognition events
pTranscribeRequest->SetRecognitionDictation(RecognitionDictation);
// Optionally register for begin/end events
pTranscribeRequest->SetAudioSourceStart(AudioSourceStart);
pTranscribeRequest->SetAudioSourceStop(AudioSourceStop);
// Schedule request
pTranscribeRequest->ScheduleRequest();
// Since we no longer need it, destroy it
delete pTranscribeRequest;
}
// Create synthesis request
CChantSpeakRequest* pSpeakRequest = _SpeechManager->CreateSpeakRequest("See how easy it is to talk with Speech Manager.");
if (pSpeakRequest != NULL)
{
// Optionally register for begin/end events
pSpeakRequest->SetAudioDestStart(AudioDestStart);
pSpeakRequest->SetAudioDestStop(AudioDestStop);
pSpeakRequest->SetDone(TTSDone);
pSpeakRequest->SetStarted(TTSStarted);
// Schedule request
pSpeakRequest->ScheduleRequest();
// Since we no longer need it, destroy it
delete pSpeakRequest;
}
}
var
_SpeechManager: TSpeechManager;
transcribeRequest: TChantTranscribeAudioRequest;
speakRequest: TChantSpeakRequest;
begin
// Instantiate SpeechManager object
_SpeechManager := TSpeechManager.Create();
if (_SpeechManager <> nil) then
begin
// Set credentials
_SpeechManager.SetCredentials('Credentials');
// Create transcription request
transcribeRequest := _SpeechManager.CreateTranscribeAudioRequest('','','myaudio.wav');
if (request <> nil) then
begin
// Register for recognition events
transcribeRequest.RecognitionDictation := RecognitionDictation;
// Optionally register for begin/end events
transcribeRequest.AudioSourceStart := AudioSourceStart;
transcribeRequest.AudioSourceStop := AudioSourceStop;
// Schedule request
transcribeRequest.ScheduleRequest();
// Since we no longer need it, destroy it
transcribeRequest.Destroy();
end;
// Create synthesis request
speakRequest := _SpeechManager.CreateSpeakRequest('See how easy it is to talk with Speech Manager.');
if (request <> nil) then
begin
// Optionally register for begin/end events
request.AudioDestStart := AudioDestStart;
request.AudioDestStop := AudioDestStop;
request.Done := TTSDone;
request.Started := TTSStarted;
// Schedule request
request.ScheduleRequest();
// Since we no longer need it, destroy it
request.Destroy();
end;
end;
end;
// Create SpeechManager object
JSpeechManager _SpeechManager = new JSpeechManager();
// Set credentials
_SpeechManager.setCredentials("Credentials");
// Create transcription request
JChantTranscribeAudioRequest transcribeRequest = _SpeechManager.createTranscribeAudioRequest("", "", "myaudio.wav", "", "");
if (transcribeRequest != null)
{
// Set the callback
transcribeRequest.setChantSpeechKitEvents(this);
// Register for recognition events
transcribeRequest.registerCallback(ChantSpeechKitCallback.CCSRRecognitionDictation);
// Optionally register for begin/end events
transcribeRequest.registerCallback(ChantSpeechKitCallback.CCSAudioStart);
transcribeRequest.registerCallback(ChantSpeechKitCallback.CCSAudioStop);
// Schedule request
transcribeRequest.scheduleRequest();
// Since we no longer need it, destroy it
transcribeRequest.dispose();
}
// Create synthesis request
JChantSpeakRequest speakRequest = _SpeechManager.createSpeakRequest("See how easy it is to talk with Speech Manager.", "", "");
if (speakRequest != null)
{
// Set the callback
speakRequest.setChantSpeechKitEvents(this);
// Optionally register for begin/end events
speakRequest.registerCallback(ChantSpeechKitCallback.CCDAudioStart);
speakRequest.registerCallback(ChantSpeechKitCallback.CCDAudioStop);
speakRequest.registerCallback(ChantSpeechKitCallback.CCTTSDone);
speakRequest.registerCallback(ChantSpeechKitCallback.CCTTSStarted);
// Schedule request
speakRequest.scheduleRequest();
// Since we no longer need it, destroy it
speakRequest.dispose();
}
Dim _SpeechManager As NSpeechManager
Dim WithEvents _SRRequest As NChantTranscribeAudioRequest
Dim WithEvents _TTSRequest As NChantSpeakRequest
' Instantiate SpeechManager
_SpeechManager = New NSpeechManager()
If (_SpeechManager IsNot Nothing) Then
If (Not String.IsNullOrEmpty(audioFile.Text.Trim())) Then
' Create transcription request
_SRRequest = _SpeechManager.CreateTranscribeAudioRequest("", "", "myaudio.wav")
If (_SRRequest IsNot Nothing) Then
' Schedule request
_SRRequest.ScheduleRequest()
' Since we no longer need it, destroy it
_SRRequest.Dispose()
End If
End If
' Create synthesis request
_TTSRequest = _SpeechManager.CreateSpeakRequest("See how easy it is to talk with Speech Manager.")
If (_TTSRequest IsNot Nothing) Then
' Schedule request
_TTSRequest.ScheduleRequest()
' Since we no longer need it, destroy it
_TTSRequest.Dispose()
End If
End If
Syntax Options
A SpeechManager supports the following methods:
- CreateTranscribeAudioRequest - Instantiate a transcription request.
- CreateSpeakRequest - Instantiate a speak request;
- FlushSRRequests - Remove all transcription requests.
- FlushTTSRequests - Remove all speak requests.
- QuiesceSRRequests - Stop processing all transcription requests allowing the current request to finish.
- QuiesceTTSRequests - Stop processing all speak requests allowing the current request to finish.
- StartSRRequests - Start processing transcription requests.
- StartTTSRequests - Start processing speak requests.
- StopSRRequests - Stop processing all transcription requests canceling the current request.
- StopTTSRequests - Stop processing all speak requests canceling the current request.
The CreateTranscribeAudioRequest method has two optional parameters that may be used to control speech recognition:
- commands - (optional) Comma-separated list of commands for command recognition.
- grammar - (optional) File path of speech recognition grammar for grammar recognition.
- audiofile - (optional) File path of audio file for transcription. Use PutAudioBytes for audio buffers.
- api - (optional) Speech API. Supported APIs include: sapi5, dragon, and msp.
- engine - (optional) Speech engine name, id, or language.
A TranscribeAudioRequest supports the following methods:
- CancelRequest - Cancels the request and removes it.
- PriorityRequest - Schedules the request as the next request to process.
- PutAudioBytes - Sets the source audio for the transcription.
- SetProperty - Sets the engine properties.
- ScheduleRequest - Schedules the request at the end of the queue to be processed.
The CreateSpeakRequest method has four optional parameters that may be used to control speech synthesis:
- text - (required) The text from which to synthesize speech.
- options - (optional) Speech synthesis options.
- outfile - (optional) The file path of where to write the synthesized audio.
- outformat - (optional) The audio output format.
- api - (optional) Speech API. Supported APIs include: sapi5, windowsmedia, msp, acatt, swift, cerevoice.
- engine - (optional) Speech engine name, id, or language.
A SpeakRequest supports the following methods:
- CancelRequest - Cancels the request and removes it.
- GetAudioBytes - Returns the audio bytes from speech synthesis.
- InterruptRequest - Cancels the current request and schedules the request as the next request to process.
- PriorityRequest - Schedules the request as the next request to process.
- SetProperty - Sets the engine properties.
- ScheduleRequest - Schedules the request at the end of the queue to be processed.
Development and Deployment
Speech Manager applications require the Speech Manager library and the applicable SpeechKit Speech API libraries:
To access the Speech Manager 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 Speech Manager header files directory: C:\Program Files\Chant\SpeechManager 4\CBuilder\include.
- For 64-bit apps, add Win64 as a conditional to the compiler options.
To access the Speech Manager C++Builder classes within your application, add a reference to the Speech Manager header files in your C++Builder application header file.
#include "Chant.Shared.h"
#include "Chant.SpeechManager.h"
#include "Chant.SpeechKit.h"
Add a reference in your C++Builder application source file to the Speech Manager code needed to dynamically load and unload the runtime DLL.
#include "Chant.Shared.cpp"
#include "Chant.SpeechKit.cpp"
#include "Chant.SpeechManager.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 CSpeechManager.dll (CSpeechManagerX64.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 Speech Manager 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.SpeechManager.Windows package and press the Install button.
- Select the Chant.SpeechKit.Windows package and press the Install button.
- Select the Chant.Shared.Windows package and press the Install button.
To access the Speech Manager C++ classes within your application, add a reference to the Speech Manager header files in your C++ application header file:
#include "Chant.Shared.Windows.h"
#include "Chant.SpeechKit.Windows.h"
#include "Chant.SpeechManager.Windows.h"
Add a reference in your C++ application source file to the Speech Manager code needed to dynamically load and unload the runtime DLL:
#include "Chant.Shared.Windows.cpp"
#include "Chant.ChantSpeechKit.Windows.cpp"
#include "Chant.ChantSpeechManager.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 CSpeechManager.dll (CSpeechManagerX64.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 Speech Manager Object Pascal classes within your application, first add a project reference to the Speech Manager Object Pascal source files:
- Within your Delphi project, select Project Options.
- Select the Delphi compiler options.
- Add Search path reference to the Speech Manager unit source file directory: C:\Program Files\Chant\SpeechManager 4\Delphi\source.
- Add Search path reference to the Speech Manager unit source file directory: C:\Program Files\Chant\SpeechKit 13\Delphi\source.
- Add unit output path reference to the local directory with a period '.' character.
To access the Speech Manager Object Pascal classes within your application, add a reference to the Chant.SpeechManager units in your uses clause.
unit Unit1;
interface
uses
..., Chant.Shared, Chant.SpeechKit, Chant.SpeechManager;
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 CSpeechManager.dll (CSpeechManagerX64.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 Speech Manager Java classes within your application, add the class libraries to your JDK environment:
- copy the JSpeechManager.DLL (JSpeechManagerX64.DLL) file to your Java JDK bin directory;
- copy the applicable 32-bit (64-bit) speech API DLL file(s) to your Java JDK bin directory;
- copy the speechmanager.jar library to your Java JDK lib;
- copy the speechkit.jar library to your Java JDK lib;
- copy the chantshared.jar library to your Java JDK lib;
- append a path reference for your Java JDK lib\speechmanager.jar path as a classpath property in your system settings;
- append a path reference for your Java JDK lib\speechkit.jar path as a classpath property in your system settings; and
- append a path reference for your Java JDK lib\chantshared.jar path as a classpath property in your system settings.
To access the Speech Manager Java classes within your application, add references to the Speech Manager class libraries in your code:
import com.speechmanager.*;
import com.speechkit.*;
import net.chant.shared.*;
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 speechmanager.jar, speechkit.jar, and chant.shared.jar to the target system Java JRE lib directory and/or ensure the classpath includes the path where the speechmanager.jar, speechkit.jar, and chant.shared.jar libraries are placed on your target system.
- Copy JSpeechManager.dll (JSpeechManagerX64.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 Speech Manager .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.SpeechManager.Windows package and press the Install button.
To access the Speech Manager .NET classes within applications, add references to the Speech Manager assemblies in your code.
using System;
...
using Chant.SpeechManager.Windows;
using Chant.SpeechKit.Windows;
using Chant.Shared.Windows;
or
Imports Chant.SpeechManager.Windows
Imports Chant.SpeechKit.Windows
Imports Chant.Shared.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.SpeechManager.Windows.dll, Chant.SpeechKit.Windows.dll and Chant.Shared.Windows.dll assemblies 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 NSpeechManager.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.SpeechManager.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\SpeechManager 4\CBuilder.
Microsoft Visual C++ sample projects that use nuget packages may be found in the following directory of the vssamples.zip download:
- Chant\SpeechManager 4\CDLL.
Delphi VCL and FireMonkey sample projects are installed at the following location:
- Documents\Chant\SpeechManager 4\Delphi.
Java sample projects are installed at the following location:
- Documents\Chant\SpeechManager 4\Java.
.NET sample projects that use nuget packages may be found in the following directory of the vssamples.zip download:
- Chant\SpeechManager 4\NET\Windows\cs and
- Chant\SpeechManager 4\NET\Windows\vb.