YSKRecognizer class

#import <YSKRecognizer.h>

Class for single sessions of speech recognition.

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. The YSKRecognizer object 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 independently launches the initialization process before beginning recognition.

Instance methods

-cancel

Cancels the recognition request.

-finishRecording

Force finish audio recording and send the request out.

-initWithLanguage:model:

Initializes a single-use object for speech recognition.

-initWithLanguage:model:continuousMode:

Releases the resources used by YSKRecognizer.

-initWithLanguage:model:dictationMode:

Initializes a single-use object for speech recognition.

-mute

Turns off recording.

-start

Starts the recognition process.

-unmute

Turns on recording that was paused.

Class methods

+isRecognitionAvailable

Checks whether the recognition is currently available.

Properties

delegate

Delegate for notification about the progress of speech recognition.

language

The language of the recognition request. For supported values, see the section Recognition languages.

model

The model of the recognition request.

VADEnabled

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

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.

-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

The language in BCP 47 format. 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 is specified as "en-US", and a Russian speaker from Russia as "ru-RU". Possible values are listed in the section Recognition languages.

model

The language model to be used for speech recognition. It allows the server to better anticipate the type of phrases the user is likely to say and select an appropriate vocabulary. This improves the accuracy of recognition. Possible values are listed in the section Language models for recognition.

Returns:

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

-initWithLanguage:model:continuousMode:

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

Releases the resources used by YSKRecognizer.

This method is called automatically and doesn't need to be called explicitly.

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

Don't forget to initialize the delegate field.

Parameters:
language

The language in BCP 47 format. 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 is specified as "en-US", and a Russian speaker from Russia as "ru-RU".

model

The language model to be used for speech recognition. It allows the server to better anticipate the type of phrases the user is likely to say and select an appropriate vocabulary. This improves the accuracy of recognition. Possible values are listed in the section Language models for recognition.

dictationMode

Recognition mode. There are two recognition modes: short query mode and dictation mode. In short query mode, sound recording stops after the first pause. In dictation mode, recognition continues until the user explicitly ends it. The value YES corresponds to dictation mode, and NO corresponds to short query mode.

Returns:

An instance of the YSKRecognizer class.

+isRecognitionAvailable

+ (BOOL) isRecognitionAvailable

Checks whether the recognition is currently available.

Note.

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

-mute

- (void) mute

Turns off recording.

Temporarily pauses recording, without stopping the recognition session.

See also:

- unmute

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

-unmute

- (void) unmute

Turns on recording that was paused.

Allows audio recording that was temporarily prohibited by calling mute.

See also:

- mute

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. For supported values, see the section Recognition languages.

model

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

The model of the recognition request.

Possible values are listed in the section Language models for recognition.

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. Default value: YES.