KeywordRecognizer Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Recognizes a word or short phrase using a keyword model.
public sealed class KeywordRecognizer : IDisposable
type KeywordRecognizer = class
interface IDisposable
Public NotInheritable Class KeywordRecognizer
Implements IDisposable
- Inheritance
-
KeywordRecognizer
- Implements
Examples
First, the object needs to be instantiated:
// (This sample uses the microphone. You can use any input source.)
var audioConfig = Microsoft.CognitiveServices.Speech.Audio.AudioConfig.FromDefaultMicrophoneInput();
var recognizer = new KeywordRecognizer (audioConfig);
(optional) Then, the events need to be wired in order to receive notifications:
recognizer.Recognized += (s, e) =>
{
// Keyword detected!
};
All set up. Start recognition.
// for .table, see:
// https://docs.microsoft.com/azure/cognitive-services/speech-service/custom-keyword-basics
var keywordModel = KeywordRecognitionModel.FromFile(@"C:\path\to\your\tablefile.table");
var result = recognizer.RecognizeOnceAsync(keywordModel);
result.Wait();
Remarks
You create a keyword model in Speech Studio, which saves it in a `.table` file.
See also:
- Get started with Custom Keyword
- KeywordRecognitionResult * KeywordRecognitionEventArgs * KeywordRecognitionModel * AudioConfig
Constructors
KeywordRecognizer(AudioConfig) |
Creates a KeywordRecognizer from an AudioConfig. The config defines the audio input to be used by the recognizer object. |
Properties
Properties |
A collection of properties and their values defined for this KeywordRecognizer. |
Methods
Dispose() |
This method performs cleanup of resources. |
RecognizeOnceAsync(KeywordRecognitionModel) |
Starts a keyword recognition session as an asynchronous operation. |
StopRecognitionAsync() |
Stops a currently active keyword recognition session asynchronously. |
Events
Canceled |
Signal for events relating to the cancellation of an interaction. The event indicates if the reason is a direct cancellation or an error. |
Recognized |
Signal for events related to the recognition of keywords. |
Applies to
Azure SDK for .NET
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin