Last reviewed: 12/15/2024 8:31:27 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 ProfileKit with Windows Desktop (WinUI) applications.
ProfileKit Assemblies
ProfileKit 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 ProfileKit .NET classes within a Windows Desktop (WinUI) application, add project references with the following nuget package:
- 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.ProfileKit.Windows package and press the Install button.
To access the ProfileKit .NET classes within your application, add references to the Chant shared and ProfileKit assemblies in your code.
using System;
...
using Chant.ProfileKit.Windows;
using Chant.Shared.Windows;
Object Instantiation
Declare variables for the ProfileKit classes, instantiate instance, add the event handlers, and set the credentials.
private NProfileKit _ProfileKit;
private NSAPI5Profile _Profile = null;
private NSAPI5Recognizer _Recognizer = null;
public MainWindow()
{
InitializeComponent();
// Instantiate ProfileKit
_ProfileKit = new NProfileKit();
if (_ProfileKit != null)
{
// Set credentials
_ProfileKit.SetCredentials("Credentials");
_Recognizer = _ProfileKit.CreateSAPI5Recognizer();
if (_Recognizer != null)
{
_Recognizer.APIError += this.Recognizer_APIError;
}
}
}
Event Callbacks
Event callbacks are the mechanism in which the class object sends information back to the application such as training recognition occurred or there was an error.
private void Recognizer_APIError(object sender, ChantAPIErrorEventArgs e)
{
// Format transcript message
string errorMsg = "";
errorMsg = "(" + e.RC.ToString() + ") ";
errorMsg += " " + e.Function.ToString() + " ";
errorMsg += e.Message;
...
}
Package.appxmanifest Capablities
If the application requires speech recognition, it requires use of the microphone. If it uses cloud-based speech technologies, it requires Internet (client) capabilities. Select Internet and Microphone under Package.appxmanifest Capabilities in Visual Studio or add the following to the Package.appxmanifest file:
<Capabilities>
<rescap:Capability Name="runFullTrust" />
<Capability Name="internetClient"/>
<DeviceCapability Name="microphone"/>
</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.
These applications require the applicable ProfkileKit Speech API library in the same directory (AppX) as the application .exe.
| Speech API | ProfileKit Speech API class | ProfileKit Speech API library |
|---|---|---|
| Microsoft SAPI 5 | CSAPI5Recognizer or CSAPI5Synthesizer | CSpeechKit.SAPI5.dll or CSpeechKitX64.SAPI5.dll |
| Microsoft Speech Platform | CMSPRecognizer or CMSPSynthesizer | CSpeechKit.MSP.dll or CSpeechKitX64.MSP.dll |
| Nuance Dragon NaturallySpeaking | CDgnRecognizer | CSpeechKit.Dgn.dll or CSpeechKitX64.Dgn.dll |
Development and Deployment Checklist
When developing and deploying Windows Desktop (WinUI) 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 applications targeting Microsoft SAPI5, Micosoft Speech Platform, and Nuance Dragon NaturallySpeaking speech technologies:
- Develop and deploy Windows Desktop (WinUI) applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
- Copy Chant.ProfileKit.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 ProfileKit Speech API DLL(s) to the target system and place in the same directory with your application.
-
Copy NProfileKit.dll to the target system,
- register as a COM library on the target system, or
- place in the same directory with Windows Desktop (WinUI) application and include an App.manifest with a dependent assembly declaration:
<dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Chant.ProfileKit.Windows" version="11.0.0.0" publicKeyToken="b0bbb116f89034f3" /> </dependentAssembly> </dependency>
- Develop and deploy Windows Desktop (WinUI) applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
- Copy Chant.ProfileKit.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 ProfileKit Speech API DLL(s) to the target system and place in the same directory with your application.
- Copy NLexiconKitX64.dll to the target system,
- register as a COM library on the target system, or
- place in the same directory with Windows Desktop (WinUI) application and include an App.manifest with a dependent assembly declaration:
<dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Chant.ProfileKit.Windows" version="11.0.0.0" publicKeyToken="b0bbb116f89034f3" /> </dependentAssembly> </dependency>
Sample Projects
Windows Desktop (WinUI) sample projects are installed at the following location:
- Documents\Chant\ProfileKit 11\WinUI\Windows\cs.