How Tos
Last reviewed: 2/1/2017
Article ID: H021701
HOW: Developing Microsoft HoloLens applications that speak and listen
The information in this article applies to:
- SpeechKit 8
Summary
You can develop Microsoft HoloLens applications that speak and listen with SpeechKit.
More Information
The following sections describe the steps for integrating SpeechKit with Microsoft HoloLens applications.
SpeechKit Assemblies
SpeechKit includes UWP compatible .NET assemblies.
To access the SpeechKit .NET classes within your application, add them to your project References:
- Within your .NET project, right click on the References node in the Solution Explorer.
-
Add references to the Chant shared and SpeechKit .NET assemblies:
- Program Files\Chant\SpeechKit 8\UWP\lib\Chant.SpeechKit.WindowsMedia.dll and
- Program Files\Chant\SpeechKit 8\UWP\lib\Chant.Shared.WindowsMedia.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.WindowsMedia; using Chant.Shared.WindowsMedia;
Speech Recognition
The following example illustrates using a command vocabulary.
private Chant.SpeechKit.NChantSR NChantSR1; ... // Instantiate NChantSR object NChantSR1 = new NChantSR(); // Setup event callback handler NChantSR1.HasEvent += this.NChantSR1_HasEvent; // Set license properties NChantSR1.SetStringProperty(ChantStringProperty.CSPLicense, "LicenseRegistrationNumber"); NChantSR1.SetStringProperty(ChantStringProperty.CSPSerials, "LicenseSerialNumber"); // Register for command recognition event NChantSR1.RegisterCallback(ChantCallback.CCSRHasCommand); // Define the vocabulary NChantCommandVocab nChantCommandVocab = nChantSR.CreateChantCommandVocab("commands"); // Add commands to the vocabulary nChantCommandVocab.AddCommand("Open File"); nChantCommandVocab.AddCommand("Print File"); nChantCommandVocab.AddCommand("Close File"); // Enable the vocabulary nChantCommandVocab.Enable(); ... private void NChantSR1_HasEvent(object sender, HasEventArgs e) { // Get the event from the event queue NChantSREvent nChantSREvent = NChantSR1.GetChantSREvent(); switch (nChantSREvent.ChantCallback) { case ChantCallback.CCSRHasCommand: { // Handle command ... break; } default: break; } // Remove the event from the event queue NChantSR1.RemoveEvent(); }
Speech Synthesis
The following examples illustrate using the StartPlayback method to synthesize speech and playback audio.
private Chant.SpeechKit.NChantTTS NChantTTS1; ... // Instantiate NChantTTS object NChantTTS1 = new NChantTTS(); // Setup event callback handler NChantTTS1.HasEvent += this.NChantTTS1_HasEvent; // Set license properties NChantTTS1.SetStringProperty(ChantStringProperty.CSPLicense, "LicenseRegistrationNumber"); NChantTTS1.SetStringProperty(ChantStringProperty.CSPSerials, "LicenseSerialNumber"); // Synthesize text to speech NChantTTS1.StartPlayback("Hello world."); ...