Last reviewed: 7/27/2024 9:49:31 AM

.NET Windows Forms Applications

Develop .NET Windows Forms applications that manage speaker profiles using your favorite .NET Windows Forms development tools. This includes development environments such as Microsoft Visual C# .NET and Microsoft Visual Basic .NET.

The following sections describe the steps for integrating ProfileKit with .NET Windows Forms applications.

ProfileKit Assemblies

ProfileKit includes Windows Forms compatible .NET assemblies for .NET Framework and .NET 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 Forms application, add project references to 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.
  • Chant ProfileKit Windows package

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;

Imports Chant.ProfileKit.Windows
Imports Chant.Shared.Windows
Class MainWindow
...

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

  1. Select the Build tab under project properties.
  2. Select x86 or x64 in the Platform target dropdown list.

Within your VB .NET Project

  1. Select the Compile tab under project properties.
  2. Press the Advanced Compile Options... button.
  3. Select x86 or x64 in the Target CPU dropdown list.

Object Instantiation

Declare a global variable for the ProfileKit class, instantiate an instance, add the event handler, 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;
        }
    }
}

Dim _ProfileKit As NProfileKit
Dim WithEvents _Recognizer As NSAPI5Recognizer
Dim _Profile As NSAPI5Profile

Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Dim engine As NChantEngine
' Instantiate ProfileKit
_ProfileKit = New NProfileKit()
If (_ProfileKit IsNot Nothing) Then
' Set credentials
_ProfileKit.SetCredentials("Credentials")
_Recognizer = _ProfileKit.CreateSAPI5Recognizer()
End If
End Sub

These applications require the applicable ProfileKit Speech API library in the same directory as the application .exe.

Speech API ProfileKit Speech API class ProfileKit Speech API library
Microsoft SAPI 5NSAPI5RecognizerCProfileKit.SAPI5.dll or CProfileKitX64.SAPI5.dll
Microsoft Speech PlatformNMSPRecognizerCProfileKit.MSP.dll or CProfileKitX64.MSP.dll
Nuance Dragon NaturallySpeakingNDgnRecognizerCProfileKit.Dgn.dll or CProfileKitX64.Dgn.dll

Event Callbacks

Event callbacks are the mechanism in which the class object sends information back to the application such as compilation is complete 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;
    ...
}

Private Sub Recognizer_APIError(ByVal sender As System.Object, ByVal e As ChantAPIErrorEventArgs) Handles _Synthesizer.APIError
    Dim errorMsg As String
    ' Format transcript message
    errorMsg = "(" + e.RC.ToString() + ") "
    errorMsg += " " + e.Function.ToString() + " "
    errorMsg += e.Message
    ...
End Sub

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 developing and deploying applications targeting Microsoft SAPI5, Micosoft Speech Platform, and Nuance Dragon NaturallySpeaking 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.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 .NET application and include an App.manifest with a dependent assembly declaration:
      
      <dependency>
          <dependentAssembly>
                  <assemblyIdentity type="win32" name="Chant.ProfileKit.Windows" version="10.0.0.0" publicKeyToken="b0bbb116f89034f3" />
          </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.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 NProfileKitX64.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.ProfileKit.Windows" version="10.0.0.0" publicKeyToken="b0bbb116f89034f3" />
          </dependentAssembly>
      </dependency>