class KeywordRecognizer

class KeywordRecognizer
  : public std::enable_shared_from_this< KeywordRecognizer >

Recognizer type that is specialized to only handle keyword activation.

First, the object needs to be instantiated:

auto audioConfig = AudioConfig::FromMicrophoneInput(); // Or an alternative input
auto recognizer = KeywordRecognizer::FromConfig(audioConfig);

(optional) Then, the events need to be wired in order to receive notifications:

recognizer->Recognized += [](const KeywordRecognitionEventArgs& event)
    // Your logic here...

And finally, recognition needs to be started.

auto keywordModel = KeywordRecognitionModel::FromFile(modelPath);
auto resultFuture = recognizer->RecognizeKeywordOnceAsync(keywordModel);
auto result = resultFuture.get();



Syntax: public EventSignal< const KeywordRecognitionEventArgs & > Recognized;

Signal for events related to the recognition of keywords.


Syntax: public EventSignal< const SpeechRecognitionCanceledEventArgs & > Canceled;

Signal for events relating to the cancellation of an interaction. The event indicates if the reason is a direct cancellation or an error.


Syntax: public const PropertyCollection & Properties;

A collection of properties and their values defined for this KeywordRecognizer.


Syntax: public inline ~KeywordRecognizer ( );



Syntax: public inline std::future< std::shared_ptr< KeywordRecognitionResult > > RecognizeOnceAsync ( std::shared_ptr< KeywordRecognitionModel > model );

Starts a keyword recognition session. This session will last until the first keyword is recognized. When this happens, a Recognized event will be raised and the session will end. To rearm the keyword, the method needs to be called again after the event is emitted.



A future that resolves to a KeywordRecognitionResult that resolves once a keyword is detected.

Note that if no keyword is detected in the input, the task will never resolve (unless StopRecognition is called.


Syntax: public inline std::future< void > StopRecognitionAsync ( );

Stops a currently active keyword recognition session.


A future that resolves when the active session (if any) is stopped.


Syntax: public inline static std::shared_ptr< KeywordRecognizer > FromConfig ( std::shared_ptr< Audio::AudioConfig > audioConfig );

Creates a KeywordRecognizer from an AudioConfig. The config is intended to define the audio input to be used by the recognizer object.


  • audioConfig Defines the audio input to be used by the recognizer.


A new KeywordRecognizer that will consume audio from the specified input.

If no audio config is provided, it will be equivalent to calling with a config constructed with AudioConfig::FromDefaultMicrophoneInput