How do I develop Windows Desktop applications that do more with Speech Technology?"
Last reviewed: 2/8/2022
HOW Article ID: H072124
The information in this article applies to:
- SpeechKit 10
Summary
Develop Windows Desktop applications that speak and listen using your favorite speech technology with SpeechKit.
More Information
SpeechKit includes Windows App SDK compatible .NET 5.0 assemblies to support your application's target framework. This means WinUI 3.0 apps can use all the SpeechKit supported speech APIs.
These applications require the applicable SpeechKit Speech API library and speech recognition grammar files in the same directory (AppX) as the application .exe.
Speech API | SpeechKit Speech API class | SpeechKit Speech API library |
---|---|---|
Acapela TTS | CAcaTTSSynthesizer | CSpeechKit.AcaTTS.dll or CSpeechKitX64.AcaTTS.dll |
Cepstral Swift | NSwiftSynthesizer | CSpeechKit.Swift.dll or CSpeechKitX64.Swift.dll |
CereProc CereVoice | NCereVoiceSynthesizer | CSpeechKit.CereVoice.dll or CSpeechKitX64.CereVoice.dll |
Microsoft SAPI 5 | NSAPI5Recognizer or NSAPI5Synthesizer | CSpeechKit.SAPI5.dll or CSpeechKitX64.SAPI5.dll |
Microsoft Speech Platform | NMSPRecognizer or NMSPSynthesizer | CSpeechKit.MSP.dll or CSpeechKitX64.MSP.dll |
Microsoft WindowsMedia (WinRT C++) | NWindowsMediaRecognizer or NWindowsMediaSynthesizer | CSpeechKit.WinRT.dll or CSpeechKitX64.WinRT.dll |
Nuance Dragon NaturallySpeaking | NDgnRecognizer | CSpeechKit.Dgn.dll or CSpeechKitX64.Dgn.dll |
To access the SpeechKit classes within your Windows Desktop application, add them to your project References:
- Within your project, right click on the Dependencies node in the Solution Explorer.
-
Add references to the Chant shared and SpeechKit assemblies:
- Program Files\Chant\SpeechKit 10\NET\libv5.0\Chant.SpeechKit.Windows.dll and
- Program Files\Chant\SpeechKit 10\NET\libv5.0\Chant.Shared.Windows.dll.
To access the SpeechKit .NET classes within your application, add references to the Chant shared and SpeechKit assemblies in your code.
using System;
...
using Chant.SpeechKit.Windows;
using Chant.Shared.Windows;
Declare variables for the SpeechKit classes, instantiate instance, add the event handlers, and set the license properties.
private NSpeechKit _SpeechKit = null;
private NSAPI5Recognizer _Recognizer = null;
private NSAPI5Synthesizer _Synthesizer = null;
public MainWindow()
{
InitializeComponent();
// Instantiate SpeechKit
_SpeechKit = new NSpeechKit();
if (_SpeechKit != null)
{
// Set license properties
//_SpeechKit.SetLicense("LicenseRegistrationNumber", "LicenseSerialNumber");
// Else, for evaluation, set only evaluation serial number
_SpeechKit.SetLicense(string.Empty, "EvaluationSerialNumber");
_Recognizer = _SpeechKit.CreateSAPI5Recognizer();
if (_Recognizer != null)
{
_Recognizer.RecognitionCommand += this.Recognizer_RecognitionCommand;
}
_Synthesizer = _SpeechKit.CreateSAPI5Synthesizer();
if (_Synthesizer != null)
{
_Synthesizer.WordPosition += Synthesizer_WordPosition;
}
}
}
If the application requires speech recognition, it requires use of the microphone. Select Microphone under Package.appxmanifest Capabilities in Visual Studio or add the following to the Package.appxmanifest file:
<Capabilities>
<DeviceCapability Name="microphone" />
</Capabilities>
If the application requires speech recognition, it requires use of the microphone. Set the Microphone usage to On for the app under Settings->Privacy->Microphone.
Windows desktop sample projects are installed at the following location: Documents\Chant\SpeechKit 10\WinUI\Windows\cs.