Last reviewed: 12/15/2024 8:27:15 AM
Windows Desktop (WinUI) Applications
Develop Windows Desktop (WinUI) applications that speak and listen using your favorite Windows App SDK development tools. This includes development environments such as Microsoft Visual Studio.
The following sections describe the steps for integrating LexiconKit with Windows Desktop (WinUI) applications.
LexiconKit Assemblies
LexiconKit includes Windows App SDK compatible .NET assemblies to support most applications' target framework. If you need a specific target framework, then contact Chant Product Support.
To access LexiconKit .NET classes within a Windows Desktop (WinUI) application, add project references with the applicable nuget package depending on the application type and 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.
-
For Acapela TTS, Cepstral Swift, Microsoft Azure Speech, Microsoft SAPI5, Micosoft Speech Platform, and Microsoft WindowsMedia (via WinRT C++) speech technologies:
- Select the Chant.LexiconKit.Windows package and press the Install button.
-
For Microsoft WindowsMedia (via WinRT .NET) speech technologies:
- Select the Chant.LexiconKit.WinRT.WindowsMedia package and press the Install button.
To access the LexiconKit .NET classes within your application that target Acapela TTS, Cepstral Swift, Microsoft Azure Speech, Microsoft SAPI5, Micosoft Speech Platform, and Microsoft WindowsMedia (via WinRT C++) speech technologies, add references to the Chant shared and LexiconKit assemblies in your code.
using System;
...
using Chant.LexiconKit.Windows;
using Chant.Shared.Windows;
These applications require the applicable LexiconKit Speech API library in the same directory (Appx) as the application .exe.
| Speech API | LexiconKit Speech API class | LexiconKit Speech API library |
|---|---|---|
| Acapela TTS | NAcaTTSSynthesizer | CLexiconKit.AcaTTS.dll or CLexiconKitX64.AcaTTS.dll |
| Cepstral Swift | NSwiftSynthesizer | CLexiconKit.Swift.dll or CLexiconKitX64.Swift.dll |
| Microsoft Azure Speech | NMCSSynthesizer | CLexiconKit.MCS.dll or CLexiconKitX64.MCS.dll |
| Microsoft SAPI 5 | NSAPI5Recognizer or NSAPI5Synthesizer | CLexiconKit.SAPI5.dll or CLexiconKitX64.SAPI5.dll |
| Microsoft Speech Platform | NMSPRecognizer or NMSPSynthesizer | CLexiconKit.MSP.dll or CLexiconKitX64.MSP.dll |
| Microsoft WindowsMedia | NWindowsMediaRecognizer or NWindowsMediaSynthesizer | CLexiconKit.WinRT.dll or CLexiconKitX64.WinRT.dll |
To access the LexiconKit .NET classes within applications that target Microsoft WindowsMedia (via WinRT .NET) speech technologies, add references to the Chant shared and LexiconKit assemblies in your code.
using System;
...
using Chant.LexiconKit.WinRT.WindowsMedia;
using Chant.Shared.WinRT.WindowsMedia;
These applications do not require a LexiconKit Speech API library.
| Speech API | LexiconKit Speech API class | LexiconKit Speech API library |
|---|---|---|
| Microsoft WindowsMedia (via WinRT .NET) | NWindowsMediaRecognizer or NWindowsMediaSynthesizer | NA |
Object Instantiation
Declare variables for the LexiconKit classes, instantiate instance, add the event handlers, and set the credentials.
private NLexiconKit _LexiconKit;
private NSAPI5Synthesizer _Synthesizer = null;
public MainWindow()
{
InitializeComponent();
// Instantiate LexiconKit
_LexiconKit = new NLexiconKit();
if (_LexiconKit != null)
{
// Set credentials
_LexiconKit.SetCredentials("Credentials");
_Synthesizer = _LexiconKit.CreateSAPI5Synthesizer();
if (_Synthesizer != null)
{
_Synthesizer.APIError += this.Sythesizer_APIError;
}
}
}
Event Callbacks
Event callbacks are the mechanism in which the class object sends information back to the application such as there was an error.
private void Recognizer_RecognitionCommand(object sender, RecognitionCommandEventArgs e)
{
if ((e != null) && (e.Phrase != null))
{
...
}
}
private void Synthesizer_WordPosition(object sender, WordPositionEventArgs e)
{
if (e != null)
{
int startPosition = e.Position;
int wordLength = e.Length;
...
}
}
Package.appxmanifest Capablities
If the application uses cloud-based speech technologies, it requires Internet (client) capabilities. Select Internet under Package.appxmanifest Capabilities in Visual Studio or add the following to the Package.appxmanifest file:
<Capabilities>
<rescap:Capability Name="runFullTrust" />
<Capability Name="internetClient"/>
</Capabilities>
Platform Target
Set the project Platform target to either x86 for 32-bit application or x64 for 64-bit application as follows:
Within your C# project
- Select the Build tab under project properties.
- Select x86 or x64 in the Platform target dropdown list.
Development and Deployment Checklist
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 deploying .NET Applications targeting Microsoft SAPI, Microsoft Speech Platform, or Microsoft WindowsMedia (via WinRT C++) speech technologies:
- 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.LexiconKit.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 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.
-
Copy NLexiconKit.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.LexiconKit.Windows" version="11.0.0.0" publicKeyToken="88f55b96a2c67ff3" /> </dependentAssembly> </dependency>
- 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.LexiconKit.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 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.
- Copy NLexiconKitX64.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.LexiconKit.Windows" version="11.0.0.0" publicKeyToken="88f55b96a2c67ff3" /> </dependentAssembly> </dependency>
Review the following checklist before deploying .NET Applications targeting WindowsMedia (via WinRT .NET) speech technologies:
- 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.LexiconKit.WinRT.WindowsMedia.dll and Chant.Shared.WinRT.WindowsMedia.dll assemblies to the target system or merge them with your application using an obfuscator like .NET Reactor by Eziriz.
Sample Projects
Windows Desktop (WinUI) sample projects are installed at the following location:
- Documents\Chant\LexiconKit 11\WinUI\Windows\cs.