Class SPXIntentRecognizer

Declaration

@class SPXIntentRecognizer : SPXRecognizer;

Description

Performs intent recognition on speech input. It returns both recognized text and recognized intent.

Methods

init:

Initializes a new instance of intent recognizer using the specified speech configuration.

- (instancetype _Nullable)init:(SPXSpeechConfiguration * _Nonnull)speechConfiguration

Parameters

  • speechConfiguration - speech recognition configuration.

Returns

an intent recognizer.

init:error:

Initializes a new instance of intent recognizer using the specified speech configuration.

Added in version 1.6.0.

- (instancetype _Nullable)init:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • speechConfiguration - speech recognition configuration.
  • outError - error information.

Returns

an intent recognizer.

initWithSpeechConfiguration:audioConfiguration:

Initializes a new instance of an intent recognizer using the specified speech and audio configurations.

- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
    audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration

Parameters

  • speechConfiguration - speech recognition configuration.
  • audioConfiguration - audio configuration.

Returns

an intent recognizer.

initWithSpeechConfiguration:audioConfiguration:error:

Initializes a new instance of an intent recognizer using the specified speech and audio configurations.

Added in version 1.6.0.

- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
    audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • speechConfiguration - speech recognition configuration.
  • audioConfiguration - audio configuration.
  • outError - error information.

Returns

an intent recognizer.

addIntentFromPhrase:

Adds a simple phrase that may be spoken by the user, indicating a specific user intent.

- (void)addIntentFromPhrase:(NSString * _Nonnull)simplePhrase

Parameters

  • simplePhrase - The phrase corresponding to the intent.

addIntentFromPhrase:mappingToId:

Adds a simple phrase that may be spoken by the user, indicating a specific user intent, and maps it to the provided identifier.

- (void)addIntentFromPhrase:(NSString * _Nonnull)simplePhrase
    mappingToId:(NSString * _Nonnull)intentId

Parameters

  • simplePhrase - The phrase corresponding to the intent.
  • intentId - A custom id string to be returned in the SPXIntentRecognitionResult's getIntentId() method.

addIntent:fromModel:

Adds a single intent by name from the specified Language Understanding Model.

- (void)addIntent:(NSString * _Nonnull)intentName
    fromModel:(SPXLanguageUnderstandingModel * _Nonnull)model

Parameters

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

addIntent:fromModel:mappingToId:

Adds a single intent by name from the specified Language Understanding Model, and maps the intent name to the provided identifier.

- (void)addIntent:(NSString * _Nonnull)intentName
    fromModel:(SPXLanguageUnderstandingModel * _Nonnull)model
    mappingToId:(NSString * _Nonnull)intentId

Parameters

  • intentName - The name of the single intent to be included from the language understanding model.
  • model - The language understanding model containing the intent.
  • intentId - A custom id string to be returned in the SPXIntentRecognitionResult's getIntentId() method.

addAllIntentsFromModel:

Adds all intents from the specified Language Understanding Model.

- (void)addAllIntentsFromModel:(SPXLanguageUnderstandingModel * _Nonnull)model

Parameters

  • model - The language understanding model containing the intents.

addAllIntentsFromModel:mappingToId:

Adds all intents from the specified Language Understanding Model, and maps them to the provided identifier.

- (void)addAllIntentsFromModel:(SPXLanguageUnderstandingModel * _Nonnull)model
    mappingToId:(NSString * _Nonnull)intentId

Parameters

  • model - The language understanding model containing the intents.
  • intentId - A custom id string to be returned in the SPXIntentRecognitionResult's getIntentId() method.

recognizeOnce

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 recognizeOnce() 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.

- (SPXIntentRecognitionResult * _Nonnull)recognizeOnce

Returns

the result of intent recognition.

recognizeOnce:

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 recognizeOnce() 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.

Added in version 1.6.0.

- (SPXIntentRecognitionResult * _Nullable)recognizeOnce:(NSError * _Nullable * _Nullable)outError

Parameters

  • outError - error information.

Returns

the result of intent recognition.

recognizeOnceAsync:

Starts speech 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.

- (void)recognizeOnceAsync:(void (^ _Nonnull)(SPXIntentRecognitionResult * _Nonnull))resultReceivedHandler

Parameters

  • resultReceivedHandler - the block function to be called when the first utterance has been recognized.

recognizeOnceAsync:error:

Starts speech 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.

Added in version 1.6.0.

- (BOOL)recognizeOnceAsync:(void (^ _Nonnull)(SPXIntentRecognitionResult * _Nonnull))resultReceivedHandler
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • resultReceivedHandler - the block function to be called when the first utterance has been recognized.
  • outError - error information.

startContinuousRecognition

Starts speech recognition on a continuous audio stream, until stopContinuousRecognition() is called. User must subscribe to events to receive recognition results.

- (void)startContinuousRecognition

startContinuousRecognition:

Starts speech recognition on a continuous audio stream, until stopContinuousRecognition() is called. User must subscribe to events to receive recognition results.

Added in version 1.6.0.

- (BOOL)startContinuousRecognition:(NSError * _Nullable * _Nullable)outError

Parameters

  • outError - error information.

stopContinuousRecognition

Stops continuous intent recognition.

- (void)stopContinuousRecognition

stopContinuousRecognition:

Stops continuous intent recognition.

Added in version 1.6.0.

- (BOOL)stopContinuousRecognition:(NSError * _Nullable * _Nullable)outError

Parameters

  • outError - error information.

addRecognizedEventHandler:

Subscribes to the Recognized event which indicates that a final result has been recognized.

- (void)addRecognizedEventHandler:(SPXIntentRecognitionEventHandler _Nonnull)eventHandler

addRecognizingEventHandler:

Subscribes to the Recognizing event which indicates an that intermediate result has been recognized.

- (void)addRecognizingEventHandler:(SPXIntentRecognitionEventHandler _Nonnull)eventHandler

addCanceledEventHandler:

Subscribes to the Canceled event which indicates that an error occurred during recognition.

- (void)addCanceledEventHandler:(SPXIntentRecognitionCanceledEventHandler _Nonnull)eventHandler

Properties

authorizationToken

@property (readwrite, copy, nonatomic) NSString * _Nullable authorizationToken;

The authorization token used to communicate with the intent recognition 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.