YSKRecognizer class

#import <YSKRecognizer.h>

The interface to a single-use recognizer.

The recognizer 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 uses the YSKRecognizerDelegate interface for notification of significant events in the recognition process.

Note.

SpeechKit must be initialized using YSKSpeechKit::configureWithAPIKey: before instantiating the first recognizer.

Note.

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

Note.

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 its work and called either YSKRecognizerDelegate::recognizer:didCompleteWithResults: or YSKRecognizerDelegate::recognizer:didFailWithError:.

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 recognizer (YSKRecognizer).

- 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 such cases, call the finishRecording() function to end 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 is destroyed automatically after either YSKRecognizerDelegate::recognizer:didFailWithError: or YSKRecognizerDelegate::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 recognizer (YSKRecognizer).

To start the recognition operation, call the start method.
Parameters:
language

The user's 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 speaker from the US would be written as "en-US".

model

The language model to be used for speech recognition. Allows the server to better anticipate the type of phrases that the user will most likely utter and enable the appropriate dictionary, thereby improving the recognition accuracy.

Returns:

An instance of the YSKRecognizer class for performing recognition with the specified parameters.

+ 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.

Note.

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 callback method YSKRecognizerDelegate::recognizerDidStartRecording: 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=getLangauge) 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 such cases, call the finishRecording() function to end recording and switch to recognition.