次の方法で共有


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 about 30 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 about 30 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 about 30 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 about 30 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.

startKeywordRecognition:error:

Begins a speech-to-text interaction with this recognizer using a keyword. This interaction will use the provided keyword model to listen for a keyword indefinitely, during which audio is not sent to the speech service and all processing is performed locally. When a keyword is recognized, IntentRecognizer will automatically connect to the speech service and begin sending audio data from just before the keyword. When received, speech-to-text results may be processed by the provided result handler or retrieved via a subscription to the recognized event.

- (BOOL)startKeywordRecognition:(SPXKeywordRecognitionModel * _Nonnull)keywordModel
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • keywordModel - the keyword recognition model.
  • outError - error information.

Returns

a value indicating whether the requested keyword recognition successfully started. If NO, outError may contain additional information.

startKeywordRecognition:

Begins a speech-to-text interaction with this recognizer using a keyword. This interaction will use the provided keyword model to listen for a keyword indefinitely, during which audio is not sent to the speech service and all processing is performed locally. When a keyword is recognized, IntentRecognizer will automatically connect to the speech service and begin sending audio data from just before the keyword. When received, speech-to-text results may be processed by the provided result handler or retrieved via a subscription to the recognized event.

- (void)startKeywordRecognition:(SPXKeywordRecognitionModel * _Nonnull)keywordModel

Parameters

  • keywordModel - the keyword recognition model.

startKeywordRecognitionAsync:completionHandler:error:

Asynchronously begins a speech-to-text interaction with this recognizer and immediately returns execution to the calling thread. This interaction will use the provided keyword model to listen for a keyword indefinitely, during which audio is not sent to the speech service and all processing is performed locally. When a keyword is recognized, IntentRecognizer will automatically connect to the speech service and begin sending audio data from just before the keyword. When received, speech-to-text results may be processed by the provided result handler or retrieved via a subscription to the recognized event.

- (BOOL)startKeywordRecognitionAsync:(SPXKeywordRecognitionModel * _Nonnull)keywordModel
    completionHandler:(SPXIntentRecognitionAsyncCompletionHandler _Nonnull)completionHandler
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • keywordModel - the keyword recognition model.
  • completionHandler - the handler function called when keyword recognition has started.
  • outError - error information.

Returns

a value indicating whether the request to start keyword recognition was received successfully. If NO, additional information may available in outError.

startKeywordRecognitionAsync:completionHandler:

Asynchronously begins a speech-to-text interaction with this recognizer and immediately returns execution to the calling thread. This interaction will use the provided keyword model to listen for a keyword indefinitely, during which audio is not sent to the speech service and all processing is performed locally. When a keyword is recognized, IntentRecognizer will automatically connect to the speech service and begin sending audio data from just before the keyword. When received, speech-to-text results may be processed by the provided result handler or retrieved via a subscription to the recognized event.

- (void)startKeywordRecognitionAsync:(SPXKeywordRecognitionModel * _Nonnull)keywordModel
    completionHandler:(SPXIntentRecognitionAsyncCompletionHandler _Nonnull)completionHandler

Parameters

  • keywordModel - the keyword recognition model.
  • completionHandler - the handler function called when keyword recognition has started.

stopKeywordRecognition:

Stops any active keyword recognition.

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

Parameters

  • outError - error information.

Returns

a value indicating whether keyword recognition was stopped successfully. If NO, additional information may be available in outError.

stopKeywordRecognition

Stops any active keyword recognition.

- (void)stopKeywordRecognition

stopKeywordRecognitionAsync:error:

Stops any active keyword recognition.

- (BOOL)stopKeywordRecognitionAsync:(SPXIntentRecognitionAsyncCompletionHandler _Nonnull)completionHandler
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • completionHandler - the handler function called when keyword recognition has stopped.
  • outError - error information.

Returns

a value indicating whether the request to stop was received successfully. If NO, additional error information may be available in outError.

stopKeywordRecognitionAsync:

Stops any active keyword recognition.

- (void)stopKeywordRecognitionAsync:(SPXIntentRecognitionAsyncCompletionHandler _Nonnull)completionHandler

Parameters

  • completionHandler - the handler function called when keyword recognition has stopped.

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 that an 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.