Class SPXSpeechRecognizer
@class SPXSpeechRecognizer : SPXRecognizer;
Performs speech recognition on the specified audio input, and gets transcribed text as result.
Initializes a new instance of speech recognizer.
- (instancetype _Nullable)init:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
speechConfiguration
- speech recognition configuration.
an instance of speech recognizer.
Initializes a new instance of speech recognizer.
Added in version 1.6.0.
- (instancetype _Nullable)init:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- speech recognition configuration.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer.
- (instancetype _Nullable)initWithEmbeddedSpeechConfiguration:(SPXEmbeddedSpeechConfiguration * _Nonnull)speechConfiguration
speechConfiguration
- embedded speech recognition configuration.
an instance of speech recognizer.
Initializes a new instance of speech recognizer.
- (instancetype _Nullable)initWithEmbeddedSpeechConfiguration:(SPXEmbeddedSpeechConfiguration * _Nonnull)speechConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- embedded speech recognition configuration.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified audio config.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
speechConfiguration
- speech recognition configuration.audioConfiguration
- audio configuration.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified audio config.
Added in version 1.6.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- speech recognition configuration.audioConfiguration
- audio configuration.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified audio config.
- (instancetype _Nullable)initWithEmbeddedSpeechConfiguration:(SPXEmbeddedSpeechConfiguration * _Nonnull)speechConfiguration
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
speechConfiguration
- embedded speech recognition configuration.audioConfiguration
- audio configuration.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified audio config.
- (instancetype _Nullable)initWithEmbeddedSpeechConfiguration:(SPXEmbeddedSpeechConfiguration * _Nonnull)speechConfiguration
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- embedded speech recognition configuration.audioConfiguration
- audio configuration.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified source language.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
language:(NSString * _Nonnull)language
speechConfiguration
- speech recognition configuration.language
- source language.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified source language.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
language:(NSString * _Nonnull)language error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- speech recognition configuration.language
- source language.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified source language and audio configuration.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
language:(NSString * _Nonnull)language
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
speechConfiguration
- speech recognition configuration.language
- source language.audioConfiguration
- audio configuration.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified source language and audio configuration.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
language:(NSString * _Nonnull)language
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- speech recognition configuration.language
- source language.audioConfiguration
- audio configuration.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified source language configuration.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
sourceLanguageConfiguration:(SPXSourceLanguageConfiguration * _Nonnull)sourceLanguageConfiguration
speechConfiguration
- speech recognition configuration.sourceLanguageConfiguration
- the source language configuration.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified source language configuration.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
sourceLanguageConfiguration:(SPXSourceLanguageConfiguration * _Nonnull)sourceLanguageConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- speech recognition configuration.sourceLanguageConfiguration
- the source language configuration.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified source language configuration and audio configuration.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
sourceLanguageConfiguration:(SPXSourceLanguageConfiguration * _Nonnull)sourceLanguageConfiguration
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
speechConfiguration
- speech recognition configuration.sourceLanguageConfiguration
- the source language configuration.audioConfiguration
- audio configuration.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified source language configuration and audio configuration.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
sourceLanguageConfiguration:(SPXSourceLanguageConfiguration * _Nonnull)sourceLanguageConfiguration
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- speech recognition configuration.sourceLanguageConfiguration
- the source language configuration.audioConfiguration
- audio configuration.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified configuration for auto language detection.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
autoDetectSourceLanguageConfiguration:(SPXAutoDetectSourceLanguageConfiguration * _Nonnull)autoDetectSourceLanguageConfiguration
speechConfiguration
- speech recognition configuration.autoDetectSourceLanguageConfiguration
- the configuration for auto language detection.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified configuration for auto language detection.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
autoDetectSourceLanguageConfiguration:(SPXAutoDetectSourceLanguageConfiguration * _Nonnull)autoDetectSourceLanguageConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- speech recognition configuration.autoDetectSourceLanguageConfiguration
- the configuration for auto language detection.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified configuration for auto language detection.
- (instancetype _Nullable)initWithEmbeddedSpeechConfiguration:(SPXEmbeddedSpeechConfiguration * _Nonnull)speechConfiguration
autoDetectSourceLanguageConfiguration:(SPXAutoDetectSourceLanguageConfiguration * _Nonnull)autoDetectSourceLanguageConfiguration
speechConfiguration
- embedded speech recognition configuration.autoDetectSourceLanguageConfiguration
- the configuration for auto language detection.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified configuration for auto language detection.
- (instancetype _Nullable)initWithEmbeddedSpeechConfiguration:(SPXEmbeddedSpeechConfiguration * _Nonnull)speechConfiguration
autoDetectSourceLanguageConfiguration:(SPXAutoDetectSourceLanguageConfiguration * _Nonnull)autoDetectSourceLanguageConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- embedded speech recognition configuration.autoDetectSourceLanguageConfiguration
- the configuration for auto language detection.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified configuration for auto language detection and audio configuration.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
autoDetectSourceLanguageConfiguration:(SPXAutoDetectSourceLanguageConfiguration * _Nonnull)autoDetectSourceLanguageConfiguration
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
speechConfiguration
- speech recognition configuration.autoDetectSourceLanguageConfiguration
- the configuration for auto language detection.audioConfiguration
- audio configuration.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified configuration for auto language detection and audio configuration.
Added in version 1.12.0.
- (instancetype _Nullable)initWithSpeechConfiguration:(SPXSpeechConfiguration * _Nonnull)speechConfiguration
autoDetectSourceLanguageConfiguration:(SPXAutoDetectSourceLanguageConfiguration * _Nonnull)autoDetectSourceLanguageConfiguration
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- speech recognition configuration.autoDetectSourceLanguageConfiguration
- the configuration for auto language detection.audioConfiguration
- audio configuration.outError
- error information.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified configuration for auto language detection and audio configuration.
- (instancetype _Nullable)initWithEmbeddedSpeechConfiguration:(SPXEmbeddedSpeechConfiguration * _Nonnull)speechConfiguration
autoDetectSourceLanguageConfiguration:(SPXAutoDetectSourceLanguageConfiguration * _Nonnull)autoDetectSourceLanguageConfiguration
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
speechConfiguration
- embedded speech recognition configuration.autoDetectSourceLanguageConfiguration
- the configuration for auto language detection.audioConfiguration
- audio configuration.
an instance of speech recognizer.
Initializes a new instance of speech recognizer using the specified configuration for auto language detection and audio configuration.
- (instancetype _Nullable)initWithEmbeddedSpeechConfiguration:(SPXEmbeddedSpeechConfiguration * _Nonnull)speechConfiguration
autoDetectSourceLanguageConfiguration:(SPXAutoDetectSourceLanguageConfiguration * _Nonnull)autoDetectSourceLanguageConfiguration
audioConfiguration:(SPXAudioConfiguration * _Nonnull)audioConfiguration
error:(NSError * _Nullable * _Nullable)outError
speechConfiguration
- embedded speech recognition configuration.autoDetectSourceLanguageConfiguration
- the configuration for auto language detection.audioConfiguration
- audio configuration.outError
- error information.
an instance of speech recognizer.
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 startContinuousRecognition() instead.
- (SPXSpeechRecognitionResult * _Nonnull)recognizeOnce
the result of speech recognition.
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 startContinuousRecognition() instead.
Added in version 1.6.0.
- (SPXSpeechRecognitionResult * _Nullable)recognizeOnce:(NSError * _Nullable * _Nullable)outError
outError
- error information.
the result of speech recognition.
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 startContinuousRecognition() instead.
- (void)recognizeOnceAsync:(void (^ _Nonnull)(SPXSpeechRecognitionResult * _Nonnull))resultReceivedHandler
resultReceivedHandler
- the block function to be called when the first utterance has been recognized.
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 startContinuousRecognition() instead.
Added in version 1.6.0.
- (BOOL)recognizeOnceAsync:(void (^ _Nonnull)(SPXSpeechRecognitionResult * _Nonnull))resultReceivedHandler
error:(NSError * _Nullable * _Nullable)outError
resultReceivedHandler
- the block function to be called when the first utterance has been recognized.outError
- error information.
Starts speech recognition on a continuous audio stream, until stopContinuousRecognition() is called. User must subscribe to events to receive recognition results.
- (void)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
outError
- error information.
Stops continuous speech recognition.
- (void)stopContinuousRecognition
Stops continuous speech recognition.
Added in version 1.6.0.
- (BOOL)stopContinuousRecognition:(NSError * _Nullable * _Nullable)outError
outError
- error information.
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, SpeechRecognizer 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
keywordModel
- the keyword recognition model.outError
- error information.
a value indicating whether the requested keyword recognition successfully started. If NO, outError may contain additional information.
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, SpeechRecognizer 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
keywordModel
- the keyword recognition model.
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, SpeechRecognizer 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:(SPXSpeechRecognitionAsyncCompletionHandler _Nonnull)completionHandler
error:(NSError * _Nullable * _Nullable)outError
keywordModel
- the keyword recognition model.completionHandler
- the handler function called when keyword recognition has started.outError
- error information.
a value indicating whether the request to start keyword recognition was received successfully. If NO, additional information may available in outError.
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, SpeechRecognizer 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:(SPXSpeechRecognitionAsyncCompletionHandler _Nonnull)completionHandler
keywordModel
- the keyword recognition model.completionHandler
- the handler function called when keyword recognition has started.
Stops any active keyword recognition.
- (BOOL)stopKeywordRecognition:(NSError * _Nullable * _Nullable)outError
outError
- error information.
a value indicating whether keyword recognition was stopped successfully. If NO, additional information may be available in outError.
Stops any active keyword recognition.
- (void)stopKeywordRecognition
Stops any active keyword recognition.
- (BOOL)stopKeywordRecognitionAsync:(SPXSpeechRecognitionAsyncCompletionHandler _Nonnull)completionHandler
error:(NSError * _Nullable * _Nullable)outError
completionHandler
- the handler function called when keyword recognition has stopped.outError
- error information.
a value indicating whether the request to stop was received successfully. If NO, additional error information may be available in outError.
Stops any active keyword recognition.
- (void)stopKeywordRecognitionAsync:(SPXSpeechRecognitionAsyncCompletionHandler _Nonnull)completionHandler
completionHandler
- the handler function called when keyword recognition has stopped.
Subscribes to the Recognized event which indicates that a final result has been recognized.
- (void)addRecognizedEventHandler:(SPXSpeechRecognitionEventHandler _Nonnull)eventHandler
Subscribes to the Recognizing event which indicates that an intermediate result has been recognized.
- (void)addRecognizingEventHandler:(SPXSpeechRecognitionEventHandler _Nonnull)eventHandler
Subscribes to the Canceled event which indicates that an error occurred during recognition.
- (void)addCanceledEventHandler:(SPXSpeechRecognitionCanceledEventHandler _Nonnull)eventHandler
@property (readwrite, copy, nonatomic) NSString * _Nullable authorizationToken;
Authorization token used to communicate with the speech 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.
@property (readonly, copy, nonatomic) NSString * _Nullable endpointId;
Endpoint ID of a customized speech model that is used for speech recognition.