KeywordRecognizer Class

Definition

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:

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