YSKRecognizer class

#import <YSKRecognizer.h>

Creates a single-use object for requests to the speech recognition system.

The created object manages the entire recognition process, including recording audio, detecting voice activity, communicating with the server, and so on.

The YSKRecognizer object is intended for single sessions of speech recognition and cannot be reused. Each subsequent recognition requires instantiating a new YSKRecognizer object. YSKRecognizer initializes and uses shared resources, so two instances of the YSKRecognizer class may not exist simultaneously. A new recognizer can be created only after the current one has finished working and called either recognizer:didCompleteWithResults: or recognizer:didFailWithError:.

YSKRecognizer uses the YSKRecognizerDelegate interface for notification of significant events in the recognition process.

Note.

SpeechKit must be initialized using configureWithAPIKey: before instantiating the first instance of YSKRecognizer.

Note.

The YSKRecognizer object can be created before performing initialization (see the description of YSKInitializer). In this case, the recognizer launches the initialization process itself before the actual start of recognition.

Instance methods

-cancel

Cancels the recognition request.

-dealloc

Releases the resources used by YSKRecognizer.

-finishRecording

Force finish audio recording and send the request out.

-initWithLanguage:model:

Initializes a single-use object for speech recognition.

-initWithLanguage:model:dictationMode:

Initializes a single-use object for speech recognition.

-start

Starts the recognition process.

Class methods

+isRecognitionAvailable

Checks whether the recognition is currently available.

Properties

delegate

The delegate will receive notifications when recording starts and finishes, recognition results are received, and errors occur.

language
model
VADEnabled

If the VAD is disabled, SpeechKit does not detect the end of speech automatically. In this case, call finishRecording in order to stop recording and switch to recognition.

Method descriptions

-cancel

- (void) cancel

Cancels the recognition request.

This method cancels the recognition request at any stage of the operation. Audio stops being recorded, and the network connection is terminated if necessary.
Note.

This method cancels the request asynchronously. This means that recognition does not end immediately after calling the method, and delegate callbacks still might be invoked.

Note.

The method does not unlock the YSKRecognizer object. The recognizer will be destroyed automatically after recognizer:didFailWithError: or recognizer:didCompleteWithResults: is called.

-dealloc

- (void) dealloc

Releases the resources used by YSKRecognizer.

-finishRecording

- (void) finishRecording

Force finish audio recording and send the request out.

In most cases, this method does not need to be called, since the Voice Activity Detector (VAD) automatically detects the end of speech. However, the method may be useful when the VAD is disabled or incorrectly detects the end of speech.

-initWithLanguage:model:

- (instancetype) initWithLanguage:(NSString *) language
model:(NSString *) model

Initializes a single-use object for speech recognition.

To start speech recognition, call the start method. This method creates an object for recognizing short queries. The query length is limited to 20 seconds. If no speech is detected within 5 seconds after the start of recording, the recognizer:didFailWithError: callback method is called with the kYSKErrorNoSpeech error.
Note.

Don't forget to initialize the delegate field.

Parameters:
language

Language in BCP 47 format: http://en.wikipedia.org/wiki/IETF_language_tag. In BCP 47 format, the language is indicated using the language code in ISO 639 format, followed by a dash (-), followed by the country code in ISO 3166-1 format. For example, an English-speaking user from the US is denoted as en-US.

-initWithLanguage:model:dictationMode:

- (instancetype) initWithLanguage:(NSString *) language
model:(NSString *) model
dictationMode:(BOOL) dictation

Initializes a single-use object for speech recognition.

To start the recognition operation, call the start method. Use this method to explicitly set the YSKRecognizer mode: short query recognition mode, or dictation mode.

+isRecognitionAvailable

+ (BOOL) isRecognitionAvailable

Checks whether the recognition is currently available.

Note.

If initialization has not been completed, the function always returns YES.

-start

- (void) start

Starts the recognition process.

It takes some time to open the audio device, establish a connection with the server, and possibly execute the initialization process. For this reason, recording never starts immediately after invoking the function. When recording starts, the recognizerDidStartRecording: callback method is called.

Property descriptions

delegate

(weak, readwrite) id< YSKRecognizerDelegate > delegate

Delegate for notification about the progress of speech recognition.

The delegate will receive notifications when recording starts and finishes, recognition results are received, and errors occur.

language

(assign, readonly, getter=getLanguge) NSString * language

The language of the recognition request.

model

(assign, readonly, getter=getModel) NSString * model

The model of the recognition request.

VADEnabled

(assign, readwrite, getter=isVADEnabled) BOOL VADEnabled

Controls the behavior of the Voice Activity Detector (VAD).

If the VAD is disabled, SpeechKit does not detect the end of speech automatically. In this case, call finishRecording in order to stop recording and switch to recognition.