次の方法で共有


Class SPXKeywordRecognizer

Declaration

@class SPXKeywordRecognizer : NSObject;

Description

Recognizer type that is specialized to only handle keyword activation.

Added in version 1.15.0.

Methods

init:

Initializes a new instance of keyword recognizer using the specified audio configuration.

- (instancetype _Nullable)init:(SPXAudioConfiguration * _Nonnull)audioConfiguration

Parameters

  • audioConfiguration - audio configuration.

Returns

an keyword recognizer.

init:error:

Initializes a new instance of keyword recognizer using the specified audio configuration.

- (instancetype _Nullable)init:(SPXAudioConfiguration * _Nonnull)audioConfiguration
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • audioConfiguration - audio configuration.
  • outError - error information.

Returns

an keyword recognizer.

recognizeOnceAsync:keywordModel:

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.

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

- (void)recognizeOnceAsync:(void (^ _Nonnull)(SPXKeywordRecognitionResult * _Nonnull))resultReceivedHandler
    keywordModel:(SPXKeywordRecognitionModel * _Nonnull)keywordModel

Parameters

  • resultReceivedHandler - the block function to be called when the keyword has been recognized.
  • keywordModel - the keyword recognition model.

recognizeOnceAsync:keywordModel:error:

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.

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

- (BOOL)recognizeOnceAsync:(void (^ _Nonnull)(SPXKeywordRecognitionResult * _Nonnull))resultReceivedHandler
    keywordModel:(SPXKeywordRecognitionModel * _Nonnull)keywordModel
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • resultReceivedHandler - the block function to be called when the keyword has been recognized.
  • keywordModel - the keyword recognition model.
  • outError - error information.

stopRecognitionAsync:

Stops a currently active keyword recognition session.

- (void)stopRecognitionAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler

Parameters

  • completedHandler - the block function to be called when async operation has been completed.

stopRecognitionAsync:error:

Stops a currently active keyword recognition session.

- (BOOL)stopRecognitionAsync:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completedHandler
    error:(NSError * _Nullable * _Nullable)outError

Parameters

  • completedHandler - the block function to be called when async operation has been completed.
  • outError - error information.

addRecognizedEventHandler:

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

- (void)addRecognizedEventHandler:(SPXKeywordRecognitionEventHandler _Nonnull)eventHandler

addCanceledEventHandler:

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

- (void)addCanceledEventHandler:(SPXKeywordRecognitionCanceledEventHandler _Nonnull)eventHandler

Properties

properties

@property (readonly, atomic) id<SPXPropertyCollection> _Nullable properties;

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