class Intent::IntentRecognizer

class Intent::IntentRecognizer
  : public AsyncRecognizer< IntentRecognitionResult, IntentRecognitionEventArgs, IntentRecognitionCanceledEventArgs >

In addition to performing speech-to-text recognition, the IntentRecognizer extracts structured information about the intent of the speaker, which can be used to drive further actions using dedicated intent triggers (see IntentTrigger).

Members

Properties

Syntax: public PropertyCollection & Properties;

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

IntentRecognizer

Syntax: public inline explicit IntentRecognizer ( SPXRECOHANDLE hreco );

Internal constructor. Creates a new instance using the provided handle.

Parameters

  • hreco Recognizer handle.

~IntentRecognizer

Syntax: public inline ~IntentRecognizer ( );

destructor

RecognizeOnceAsync

Syntax: public inline virtual std::future< std::shared_ptr< IntentRecognitionResult > > RecognizeOnceAsync ( );

Starts intent recognition, and returns after a single utterance is recognized. The end of a single utterance is determined by listening for silence at the end or until a maximum of 15 seconds of audio is processed. The task returns the recognition text as result. Note: Since RecognizeOnceAsync() returns only a single utterance, it is suitable only for single shot recognition like command or query. For long-running multi-utterance recognition, use StartContinuousRecognitionAsync() instead..

Returns

Future containing result value (a shared pointer to IntentRecognitionResult) of the asynchronous intent recognition.

RecognizeOnceAsync

Syntax: public inline std::future< std::shared_ptr< IntentRecognitionResult > > RecognizeOnceAsync ( std::string text );

Starts intent recognition, and generates a result from the text passed in. This is useful for testing and other times when the speech input is not tied to the IntentRecognizer. Note: The Intent Service does not currently support this so it is only valid for offline pattern matching or exact matching intents.

Parameters

  • text The text to be evaluated.

Returns

Future containing result value (a shared pointer to IntentRecognitionResult) of the asynchronous intent recognition.

StartContinuousRecognitionAsync

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

Asynchronously initiates continuous intent recognition operation.

Returns

An empty future.

StopContinuousRecognitionAsync

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

Asynchronously terminates ongoing continuous intent recognition operation.

Returns

An empty future.

StartKeywordRecognitionAsync

Syntax: public inline virtual std::future< void > StartKeywordRecognitionAsync ( std::shared_ptr< KeywordRecognitionModel > model );

Asynchronously initiates keyword recognition operation.

Parameters

  • model Specifies the keyword model to be used.

Returns

An empty future.

StopKeywordRecognitionAsync

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

Asynchronously terminates keyword recognition operation.

Returns

An empty future.

AddIntent

Syntax: public inline void AddIntent ( const std::string & simplePhrase );

Adds a simple phrase that may be spoken by the user, indicating a specific user intent. This simple phrase can be a pattern including and enitity surrounded by braces. Such as "click the {checkboxName} checkbox".

Parameters

  • simplePhrase The phrase corresponding to the intent.

Once recognized, the IntentRecognitionResult's IntentId property will match the simplePhrase specified here. If any entities are specified and matched, they will be available in the IntentResult->GetEntities() call.

AddIntent

Syntax: public inline void AddIntent ( const std::string & simplePhrase , const std::string & intentId );

Adds a simple phrase that may be spoken by the user, indicating a specific user intent. This simple phrase can be a pattern including and enitity surrounded by braces. Such as "click the {checkboxName} checkbox".

Parameters

  • simplePhrase The phrase corresponding to the intent.

  • intentId A custom id string to be returned in the IntentRecognitionResult's IntentId property.

Once recognized, the result's intent id will match the id supplied here. If any entities are specified and matched, they will be available in the IntentResult->GetEntities() call.

AddIntent

Syntax: public inline void AddIntent ( std::shared_ptr< LanguageUnderstandingModel > model , const std::string & intentName );

Adds a single intent by name from the specified Language Understanding Model. For PatternMatchingModel and ConversationalLanguageUnderstandingModel types, this will clear any existing models before enabling it. For these types, the intentName is ignored.

Parameters

  • model The language understanding model containing the intent.

  • intentName The name of the single intent to be included from the language understanding model.

Once recognized, the IntentRecognitionResult's IntentId property will contain the intentName specified here.

AddIntent

Syntax: public inline void AddIntent ( std::shared_ptr< LanguageUnderstandingModel > model , const std::string & intentName , const std::string & intentId );

Adds a single intent by name from the specified Language Understanding Model. For PatternMatchingModel and ConversationalLanguageUnderstandingModel types, this will clear any existing models before enabling it. For these types, the intentName and intentId are ignored.

Parameters

  • model The language understanding model containing the intent.

  • intentName The name of the single intent to be included from the language understanding model.

  • intentId A custom id string to be returned in the IntentRecognitionResult's IntentId property.

AddAllIntents

Syntax: public inline void AddAllIntents ( std::shared_ptr< LanguageUnderstandingModel > model );

Adds all intents from the specified Language Understanding Model. For PatternMatchingModel and ConversationalLanguageUnderstandingModel types, this will clear any existing models before enabling it.

Parameters

  • model The language understanding model containing the intents.

Once recognized, the IntentRecognitionResult's IntentId property will contain the name of the intent recognized.

AddAllIntents

Syntax: public inline void AddAllIntents ( std::shared_ptr< LanguageUnderstandingModel > model , const std::string & intentId );

Adds all intents from the specified Language Understanding Model. For PatternMatchingModel and ConversationalLanguageUnderstandingModel types, this will clear any existing models before enabling it.

Parameters

  • model The language understanding model containing the intents.

  • intentId A custom string id to be returned in the IntentRecognitionResult's IntentId property.

AddIntent

Syntax: public inline void AddIntent ( std::shared_ptr< IntentTrigger > trigger , const std::string & intentId );

Adds the IntentTrigger specified.

Parameters

  • trigger The IntentTrigger corresponding to the intent.

  • intentId A custom string id to be returned in the IntentRecognitionResult's IntentId property.

SetAuthorizationToken

Syntax: public inline void SetAuthorizationToken ( const std::string & token );

Sets the authorization token that will be used for connecting to the service. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. Otherwise, the recognizer will encounter errors during recognition.

Parameters

  • token A string that represents the authorization token.

GetAuthorizationToken

Syntax: public inline std::string GetAuthorizationToken ( );

Gets the authorization token.

Returns

Authorization token

ApplyLanguageModels

Syntax: public inline bool ApplyLanguageModels ( const std::vector< std::shared_ptr< LanguageUnderstandingModel > > & collection );

Takes a collection of language understanding models, makes a copy of them, and applies them to the recognizer. This application happens at different times depending on the language understanding model type. Simple Language Models will become active almost immediately whereas language understanding models utilizing LUIS will become active on the next Speech turn. This replaces any previously applied models.

Parameters

  • collection A vector of shared pointers to LanguageUnderstandingModels.

Returns

True if the application of the models takes effect immediately. Otherwise false.

FromConfig

Syntax: public inline static std::shared_ptr< IntentRecognizer > FromConfig ( std::shared_ptr< SpeechConfig > speechConfig , std::shared_ptr< Audio::AudioConfig > audioInput );

Creates an intent recognizer from a speech config and an audio config. Users should use this function to create a new instance of an intent recognizer.

Parameters

  • speechConfig Speech configuration.

  • audioInput Audio configuration.

Returns

Instance of intent recognizer.

FromConfig

Syntax: public inline static std::shared_ptr< IntentRecognizer > FromConfig ( std::shared_ptr< EmbeddedSpeechConfig > speechConfig , std::shared_ptr< Audio::AudioConfig > audioInput );

Creates an intent recognizer from an embedded speech config and an audio config. Users should use this function to create a new instance of an intent recognizer. Added in version 1.19.0.

Parameters

  • speechConfig Embedded speech configuration.

  • audioInput Audio configuration.

Returns

Instance of intent recognizer.

BaseType

Syntax: typedef BaseType;