IntentRecognizer class

Intent recognizer.

Extends

Constructors

IntentRecognizer(SpeechConfig, AudioConfig)

Initializes an instance of the IntentRecognizer.

Properties

authorizationToken

Gets/Sets the authorization token used to communicate with the service. Note: Please use a token derived from your LanguageUnderstanding subscription key for the Intent recognizer.

canceled

The event canceled signals that an error occurred during recognition.

properties

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

recognized

The event recognized signals that a final recognition result is received.

recognizing

The event recognizing signals that an intermediate recognition result is received.

sessionStarted

Defines event handler for session started events.

sessionStopped

Defines event handler for session stopped events.

speechEndDetected

Defines event handler for speech stopped events.

speechRecognitionLanguage

Gets the spoken language of recognition.

speechStartDetected

Defines event handler for speech started events.

telemetryEnabled

This method returns the current state of the telemetry setting.

Methods

addAllIntents(LanguageUnderstandingModel, string)
addIntent(string, string)

Adds a phrase that should be recognized as intent.

addIntentWithLanguageModel(string, LanguageUnderstandingModel, string)

Adds an intent from Language Understanding service for recognition.

close()

closes all external resources held by an instance of this class.

enableTelemetry(boolean)

This method globally enables or disables telemetry.

recognizeOnceAsync((e: IntentRecognitionResult) => void, (e: string) => void)

Starts intent recognition, and stops after the first utterance is recognized. The task returns the recognition text and intent as result. Note: RecognizeOnceAsync() returns when the first utterance has been recognized, so it is suitable only for single shot recognition like command or query. For long-running recognition, use StartContinuousRecognitionAsync() instead.

startContinuousRecognitionAsync(() => void, (e: string) => void)

Starts speech recognition, until stopContinuousRecognitionAsync() is called. User must subscribe to events to receive recognition results.

startKeywordRecognitionAsync(KeywordRecognitionModel, () => void, (e: string) => void)

Starts speech recognition with keyword spotting, until stopKeywordRecognitionAsync() is called. User must subscribe to events to receive recognition results. Note: Key word spotting functionality is only available on the Speech Devices SDK. This functionality is currently not included in the SDK itself.

stopContinuousRecognitionAsync(() => void, (e: string) => void)

Stops continuous intent recognition.

stopKeywordRecognitionAsync(() => void, (e: string) => void)

Stops continuous speech recognition. Note: Key word spotting functionality is only available on the Speech Devices SDK. This functionality is currently not included in the SDK itself.

Constructor Details

IntentRecognizer(SpeechConfig, AudioConfig)

Initializes an instance of the IntentRecognizer.

new IntentRecognizer(speechConfig: SpeechConfig, audioConfig?: AudioConfig)

Parameters

speechConfig
SpeechConfig

The set of configuration properties.

audioConfig
AudioConfig

An optional audio input config associated with the recognizer

Property Details

authorizationToken

Gets/Sets the authorization token used to communicate with the service. Note: Please use a token derived from your LanguageUnderstanding subscription key for the Intent recognizer.

public authorizationToken: string

Property Value

string

canceled

The event canceled signals that an error occurred during recognition.

public canceled: (sender: IntentRecognizer, event: IntentRecognitionCanceledEventArgs) => void

Property Value

(sender: IntentRecognizer, event: IntentRecognitionCanceledEventArgs) => void

properties

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

public properties: PropertyCollection

Property Value

recognized

The event recognized signals that a final recognition result is received.

public recognized: (sender: IntentRecognizer, event: IntentRecognitionEventArgs) => void

Property Value

(sender: IntentRecognizer, event: IntentRecognitionEventArgs) => void

recognizing

The event recognizing signals that an intermediate recognition result is received.

public recognizing: (sender: IntentRecognizer, event: IntentRecognitionEventArgs) => void

Property Value

(sender: IntentRecognizer, event: IntentRecognitionEventArgs) => void

sessionStarted

Defines event handler for session started events.

public sessionStarted: (sender: Recognizer, event: SessionEventArgs) => void

Property Value

(sender: Recognizer, event: SessionEventArgs) => void

sessionStopped

Defines event handler for session stopped events.

public sessionStopped: (sender: Recognizer, event: SessionEventArgs) => void

Property Value

(sender: Recognizer, event: SessionEventArgs) => void

speechEndDetected

Defines event handler for speech stopped events.

public speechEndDetected: (sender: Recognizer, event: RecognitionEventArgs) => void

Property Value

(sender: Recognizer, event: RecognitionEventArgs) => void

speechRecognitionLanguage

Gets the spoken language of recognition.

public speechRecognitionLanguage: string

Property Value

string

speechStartDetected

Defines event handler for speech started events.

public speechStartDetected: (sender: Recognizer, event: RecognitionEventArgs) => void

Property Value

(sender: Recognizer, event: RecognitionEventArgs) => void

telemetryEnabled

This method returns the current state of the telemetry setting.

public static telemetryEnabled: boolean

Property Value

boolean

Method Details

addAllIntents(LanguageUnderstandingModel, string)

function addAllIntents(model: LanguageUnderstandingModel, intentId?: string)

Parameters

model
LanguageUnderstandingModel

The language understanding model containing the intents.

intentId
string

A custom id String to be returned in the IntentRecognitionResult's getIntentId() method.

addIntent(string, string)

Adds a phrase that should be recognized as intent.

function addIntent(simplePhrase: string, intentId?: string)

Parameters

simplePhrase
string
intentId
string

A String that represents the identifier of the intent to be recognized.

addIntentWithLanguageModel(string, LanguageUnderstandingModel, string)

Adds an intent from Language Understanding service for recognition.

function addIntentWithLanguageModel(intentId: string, model: LanguageUnderstandingModel, intentName?: string)

Parameters

intentId
string

A String that represents the identifier of the intent to be recognized. Ignored if intentName is empty.

model
LanguageUnderstandingModel

The intent model from Language Understanding service.

intentName
string

The intent name defined in the intent model. If it is empty, all intent names defined in the model will be added.

close()

closes all external resources held by an instance of this class.

function close()

enableTelemetry(boolean)

This method globally enables or disables telemetry.

static function enableTelemetry(enabled: boolean)

Parameters

enabled
boolean

Global setting for telemetry collection. If set to true, telemetry information like microphone errors, recognition errors are collected and sent to Microsoft. If set to false, no telemetry is sent to Microsoft.

recognizeOnceAsync((e: IntentRecognitionResult) => void, (e: string) => void)

Starts intent recognition, and stops after the first utterance is recognized. The task returns the recognition text and intent as result. Note: RecognizeOnceAsync() returns when the first utterance has been recognized, so it is suitable only for single shot recognition like command or query. For long-running recognition, use StartContinuousRecognitionAsync() instead.

function recognizeOnceAsync(cb?: (e: IntentRecognitionResult) => void, err?: (e: string) => void)

Parameters

cb
(e: IntentRecognitionResult) => void

Callback that received the recognition has finished with an IntentRecognitionResult.

err
(e: string) => void

Callback invoked in case of an error.

startContinuousRecognitionAsync(() => void, (e: string) => void)

Starts speech recognition, until stopContinuousRecognitionAsync() is called. User must subscribe to events to receive recognition results.

function startContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void)

Parameters

cb
() => void

Callback invoked once the recognition has started.

err
(e: string) => void

Callback invoked in case of an error.

startKeywordRecognitionAsync(KeywordRecognitionModel, () => void, (e: string) => void)

Starts speech recognition with keyword spotting, until stopKeywordRecognitionAsync() is called. User must subscribe to events to receive recognition results. Note: Key word spotting functionality is only available on the Speech Devices SDK. This functionality is currently not included in the SDK itself.

function startKeywordRecognitionAsync(model: KeywordRecognitionModel, cb?: () => void, err?: (e: string) => void)

Parameters

model
KeywordRecognitionModel

The keyword recognition model that specifies the keyword to be recognized.

cb
() => void

Callback invoked once the recognition has started.

err
(e: string) => void

Callback invoked in case of an error.

stopContinuousRecognitionAsync(() => void, (e: string) => void)

Stops continuous intent recognition.

function stopContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void)

Parameters

cb
() => void

Callback invoked once the recognition has stopped.

err
(e: string) => void

Callback invoked in case of an error.

stopKeywordRecognitionAsync(() => void, (e: string) => void)

Stops continuous speech recognition. Note: Key word spotting functionality is only available on the Speech Devices SDK. This functionality is currently not included in the SDK itself.

function stopKeywordRecognitionAsync(cb?: () => void, err?: (e: string) => void)

Parameters

cb
() => void

Callback invoked once the recognition has stopped.

err
(e: string) => void

Callback invoked in case of an error.