Class YSKRecognizerDialogController

UI dialog for speech recognition.

Makes it easier to embed speech recognition in an app. YSKRecognizerDialogController manages the entire recognition process:
YSKRecognizerDialogController uses YSKRecognizerDialogControllerDelegate for notification of significant events in the recognition process. YSKRecognizerDialogController starts recognition immediately after opening. The dialog closes automatically if:
  • The recognition result was received.

  • An error occurred.

  • The user closed or minimized the app.

YSKRecognizerDialogController handles when the screen is rotated, the app is minimized, and any other events that may affect the appearance of the dialog or the behavior of the YSKOnlineRecognizer object. The YSKRecognizerDialogController class object can be reused. All necessary resources are captured when the window opens, and they are released when closed. Before working with an object of the YSKRecognizerDialogController class, set the developer's API key using the apiKey property.

Instance Methods

-dismissRecognizerDialogAnimated:

Force closes the dialog.

-initWithRecognizer:

Initializes an object of the YSKRecognizerDialogController class with no settings specified.

-initWithRecognizer:phraseSpotter:

Initializes an object of the YSKRecognizerDialogController class with the specified settings.

-initWithRecognizerSettings:

Initializes an object of the YSKRecognizerDialogController class.

-initWithRecognizerSettings:audioProcessingMode:

Initializes an object of the YSKRecognizerDialogController class with the mode of additional audio processing.

-initWithRecognizerSettings:phraseSpotterSettings:audioProcessingMode:

Initializes an object of the YSKRecognizerDialogController class with the settings for voice activation on the error screen and additional audio processing mode.

-presentRecognizerDialogOverPresentingController:animated:completion:

Opens the dialog and starts speech recognition.

Properties

audioProcessingMode

Processing mode of incoming audio. The modes are described in the YSKAudioProcessingMode class.

biometry

Estimated biometrics of the user, such as age, gender, and age group.

delegate

The delegate that will receive notifications when the recognition result is received, an error occurs, and the dialog is closed.

earcons

The list of sounds played during the YSKRecognizerDialogController operation.

requestId

Request ID.

shouldDisplayHypothesesList

Display of the screen with a list of all hypotheses if there are several variants of recognition. Acceptable values: YES - the list will be shown; NO - the list will not be shown.

shouldDisplayPartialResults

Display of partial recognition results. Acceptable values: YES - the result will be shown; NO - the result will not be shown.

skin

Appearance of the dialog.

Method Detail

-dismissRecognizerDialogAnimated:

- (void)dismissRecognizerDialogAnimated:(BOOL)animated 

Force closes the dialog.

You only need to call this method explicitly if you want to close the dialog immediately. In all other cases, it will be called automatically when recognition is complete, the user closes the dialog, or the app is minimized.
Parameters:
animated

The dialog will close with or without animation. Acceptable values: YES - the dialog closes with animation; NO - the dialog closes without animation.

-initWithRecognizer:

- (instancetype)initWithRecognizer:(id< YSKRecognizing >)recognizer 

Initializes an object of the YSKRecognizerDialogController class with no settings specified.

When using this method, an object of the YSKPhraseSpotter class is equal to nil and voice activation on the error screen is disabled. This method is a designated initializer for the YSKRecognizerDialogController class.
Note.

This method is deprecated and does not allow setting the mode for sound suppression at the start of speech recording. Use the initWithRecognizerSettings:audioProcessingMode: method to create an object of the YSKRecognizerDialogController class.

Parameters:
recognizer

Object of the class that implements the YSKRecognizing protocol used for speech recognition.

Returns:

An object of the YSKRecognizerDialogController class.

-initWithRecognizer:phraseSpotter:

- (instancetype)initWithRecognizer:(id< YSKRecognizing >)recognizer
                     phraseSpotter:(YSKPhraseSpotter *)phraseSpotter 

Initializes an object of the YSKRecognizerDialogController class with the specified settings.

The method sets an object of the YSKPhraseSpotter class that will be used for voice activation on the error screen.
Note.

This method is deprecated and does not allow setting the mode for sound suppression at the start of speech recording. Use the initWithRecognizerSettings:phraseSpotterSettings:audioProcessingMode: method to create the YSKRecognizerDialogController class.

Parameters:
recognizer

An object of the class that implements the YSKRecognizing protocol used for speech recognition.

phraseSpotter

An object of the YSKPhraseSpotter class for voice activation.

Returns:

An object of the YSKRecognizerDialogController class.

-initWithRecognizerSettings:

- (instancetype)initWithRecognizerSettings:(YSKOnlineRecognizerSettings *)recognizerSetting 

Initializes an object of the YSKRecognizerDialogController class.

When using this method, voice activation on the error screen and additional processing of incoming audio are disabled.
Parameters:
recognizerSetting

Settings of the YSKOnlineRecognizer class object that is used for speech recognition.

Returns:

An object of the YSKRecognizerDialogController class.

-initWithRecognizerSettings:audioProcessingMode:

- (instancetype)initWithRecognizerSettings:(YSKOnlineRecognizerSettings *)recognizerSetting
                       audioProcessingMode:(nullable YSKAudioProcessingMode *)mode 

Initializes an object of the YSKRecognizerDialogController class with the mode of additional audio processing.

When using this method, voice activation is disabled on the error screen. You can set additional audio processing through the mode parameter:
  • No recording while the audio is played (the mute mode).

  • Apply the acoustic echo cancellation algorithm to the audio (the echoCancel mode). This method is a designated initializer for the YSKRecognizerDialogController class.
    Parameters:
    recognizerSetting

    Settings of the YSKOnlineRecognizer class object that is used for speech recognition.

    mode

    Mode of additional audio processing. The modes are described in the YSKAudioProcessingMode class.

    Returns:

    An object of the YSKRecognizerDialogController class.

-initWithRecognizerSettings:phraseSpotterSettings:audioProcessingMode:

- (instancetype)initWithRecognizerSettings:(YSKOnlineRecognizerSettings *)recognizerSettings
                     phraseSpotterSettings:(YSKPhraseSpotterSettings *)phraseSpotterSettings
                       audioProcessingMode:(nullable YSKAudioProcessingMode *)mode 

Initializes an object of the YSKRecognizerDialogController class with the settings for voice activation on the error screen and additional audio processing mode.

Specifies the settings of the YSKPhraseSpotter class object that will be used for voice activation on the error screen, and additional audio processing.
Parameters:
recognizerSettings

Settings of the YSKOnlineRecognizer class object that is used for speech recognition.

phraseSpotterSettings

Settings of the YSKPhraseSpotter class object for voice activation on the error screen.

mode

Mode of additional audio processing. The modes are described in the YSKAudioProcessingMode class.

Returns:

An object of the YSKRecognizerDialogController class.

-presentRecognizerDialogOverPresentingController:animated:completion:

- (void)presentRecognizerDialogOverPresentingController:(UIViewController *)presentingController
                                               animated:(BOOL)animated
                                             completion:(nullable void(^)(void))completion 

Opens the dialog and starts speech recognition.

You should only use this method to display the dialog window, because it calls the settings needed for speech recognition.
Note.

Using standard methods for opening UIViewController may cause the dialog to function incorrectly.

Parameters:
presentingController

The controller on top of which the dialog opens.

animated

The dialog will close with or without animation. Acceptable values: YES - the dialog closes with animation; NO - the dialog closes without animation.

completion

The block that will be called at the end of the animation for closing the dialog.

Property Detail

audioProcessingMode

(copy, readonly) YSKAudioProcessingMode * audioProcessingMode

Processing mode of incoming audio. The modes are described in the YSKAudioProcessingMode class.

Default value: mute.

biometry

(copy, readonly) YSKBiometry * biometry

Estimated biometrics of the user, such as age, gender, and age group.

The YSKBiometry object is returned not equal to nil in the recognizer:didReceivePartialResults:withEndOfUtterance: method if the following conditions are met:

delegate

(weak, readwrite) id< YSKRecognizerDialogControllerDelegate > delegate

The delegate that will receive notifications when the recognition result is received, an error occurs, and the dialog is closed.

earcons

(copy, readwrite) YSKRecognizerDialogEarcons * earcons

The list of sounds played during the YSKRecognizerDialogController operation.

requestId

(copy, readonly) NSString * requestId

Request ID.

shouldDisplayHypothesesList

(assign, readwrite) BOOL shouldDisplayHypothesesList

Display of the screen with a list of all hypotheses if there are several variants of recognition. Acceptable values: YES - the list will be shown; NO - the list will not be shown.

shouldDisplayPartialResults

(assign, readwrite) BOOL shouldDisplayPartialResults

Display of partial recognition results. Acceptable values: YES - the result will be shown; NO - the result will not be shown.

skin

(strong, readwrite) id< YSKDialogSkin > skin

Appearance of the dialog.

Default value: YSKLightDialogSkin. When you change this property, the dialog immediately changes its appearance.