Class RecognizerActivity

ru.yandex.speechkit.gui

java.lang.Object ⇽ android.content.Context ⇽ android.content.ContextWrapper ⇽ android.view.ContextThemeWrapper ⇽ android.app.Activity ⇽ android.support.v4.app.FragmentActivity ⇽ RecognizerActivity

public  class  RecognizerActivity  extends android.support.v4.app.FragmentActivity

All Implemented Interfaces:
android.view.KeyEvent.Callback, android.view.Window.Callback, android.content.ComponentCallbacks, android.content.ComponentCallbacks2, android.view.LayoutInflater.Factory, android.view.LayoutInflater.Factory2, android.view.View.OnCreateContextMenuListener

Activity for speech recognition.

Makes it easier to embed speech recognition in an app. An object of the RecognizerActivity class manages the entire recognition process, including the recognition user interface, and the lifecycle of the Recognizer and PhraseSpotter objects in use.

To activate RecognizerActivity, the app should start the android.content.Intent system class object with RecognizerActivity as an argument. To get recognition results, the app should redefine the onActivityResult(int, int, Intent) method of the android.app.Activity system class.

The android.content.Intent system class object that starts RecognizerActivity will receive a set of additional parameters for recognition configuration:

If the recognition is successful, the resultCode value in the onActivityResult(int, int, Intent) method of the android.app.Activity system class will be RESULT_OK and the recognition result itself can be obtained through the getStringExtra(String) method of the android.content.Intent system class using the EXTRA_RESULT and EXTRA_LANGUAGE keys.

If an error occurs, the resultCode value will be RESULT_ERROR and error details can be obtained through the EXTRA_ERROR key.

If the user cancels the recognition, the resultCode value in the onActivityResult(int, int, Intent) method of the android.app.Activity system class will be RESULT_CANCELED.

Methods

RecognizerUIEarcons getEarcons()
void onBackPressed()
void onConfigurationChanged(final android.content.res.Configuration newConfig)
void onRequestPermissionsResult(final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults)

Fields

final String EXTRA_ALLOW_PLATFORM_RECOGNIZER

Flag (boolean) that is used to set up the setUsePlatformRecognizer (boolean).

final String EXTRA_AUDIO_PROCESSING_MODE

Processing mode of incoming audio (AudioProcessingMode).

final String EXTRA_BIOMETRY_RESULTS

Key for getting an object of the Biometry class with the user's estimated biometrics in case of successful speech recognition.

final String EXTRA_CUSTOM_GRAMMAR

Grammar for the "on-the-fly" model.

final String EXTRA_DISABLE_ANTIMAT

Flag (boolean) that is used to set up the setDisableAntimat (boolean).

final String EXTRA_ENABLE_PUNCTUATION

Flag (boolean) that is used to set up the setEnablePunctuation (boolean).

final String EXTRA_ERROR

Key for getting an error as an object of the Error class in the event of a recognition error.

final String EXTRA_LANGUAGE

The language used for setting up (Builder(Language, OnlineModel, RecognizerListener)).

final String EXTRA_MODEL

The model used for setting up recognition (Builder(Language, OnlineModel, RecognizerListener)).

final String EXTRA_NIGHT_THEME

Flag (boolean) that sets the appearance of the dialog.

final String EXTRA_REQUEST_BIOMETRY

Flag (boolean) that includes in a response the Biometry object with estimated biometrics of the user.

final String EXTRA_RESULT

Key for getting recognition results as a string if speech recognition is successful.

final String EXTRA_RETRY_ACTIVATION_MODEL

The model used for configuration (Builder (String, PhraseSpotterListener)).

final String EXTRA_SHOW_HYPOTHESES

Flag (boolean) that sets up the "Hypotheses Screen" display option (the screen for displaying recognition hypotheses).

final String EXTRA_SHOW_PARTIAL_RESULTS

Flag (boolean) that sets up the option to display partial results on the "Speak Screen" (the main screen to wait for speech for recognition).

final int RESULT_ERROR

Code that identifies whether speech recognition failed or was interrupted by the user.

Method Detail

getEarcons

public RecognizerUIEarcons getEarcons ()

onBackPressed

public void onBackPressed ()

onConfigurationChanged

public void onConfigurationChanged (final android.content.res.Configuration newConfig)

onRequestPermissionsResult

public void onRequestPermissionsResult (final int requestCode, @NonNull final String[] permissions, @NonNull final int[] grantResults)

Field Detail

EXTRA_ALLOW_PLATFORM_RECOGNIZER

public static EXTRA_ALLOW_PLATFORM_RECOGNIZER = "ru.yandex.speechkit.gui.allow_platform_recognizer"

Flag (boolean) that is used to set up the setUsePlatformRecognizer (boolean).

Default value: false.

EXTRA_AUDIO_PROCESSING_MODE

public static EXTRA_AUDIO_PROCESSING_MODE = "ru.yandex.speechkit.gui.audio_processing_mode"

Processing mode of incoming audio (AudioProcessingMode).

Default value: 1.

EXTRA_BIOMETRY_RESULTS

public static EXTRA_BIOMETRY_RESULTS = "ru.yandex.speechkit.biometry_results"

Key for getting an object of the Biometry class with the user's estimated biometrics in case of successful speech recognition.

To get it, set EXTRA_REQUEST_BIOMETRY to true.

EXTRA_CUSTOM_GRAMMAR

public static EXTRA_CUSTOM_GRAMMAR = "ru.yandex.speechkit.gui.custom_grammar"

Grammar for the "on-the-fly" model.

Note.

Don't use numbers, "upper case".

Default value: "" (empty string).

EXTRA_DISABLE_ANTIMAT

public static EXTRA_DISABLE_ANTIMAT = "ru.yandex.speechkit.gui.disable_antimat"

Flag (boolean) that is used to set up the setDisableAntimat (boolean).

Default value: false.

EXTRA_ENABLE_PUNCTUATION

public static EXTRA_ENABLE_PUNCTUATION = "ru.yandex.speechkit.gui.enable_punctuation"

Flag (boolean) that is used to set up the setEnablePunctuation (boolean).

Default value: true.

EXTRA_ERROR

public static EXTRA_ERROR = "ru.yandex.speechkit.gui.error"

Key for getting an error as an object of the Error class in the event of a recognition error.

EXTRA_LANGUAGE

public static EXTRA_LANGUAGE = "ru.yandex.speechkit.gui.language"

The language used for setting up (Builder(Language, OnlineModel, RecognizerListener)).

The default value depends on the values returned in the getLanguage() and getCountry() methods of the Locale system class.

EXTRA_MODEL

public static EXTRA_MODEL = "ru.yandex.speechkit.gui.model"

The model used for setting up recognition (Builder(Language, OnlineModel, RecognizerListener)).

Default value: QUERIES.

EXTRA_NIGHT_THEME

public static EXTRA_NIGHT_THEME = "ru.yandex.speechkit.gui.night_theme"

Flag (boolean) that sets the appearance of the dialog.

Acceptable values: false - a light theme is used; true - a dark theme is used.Default value: false.

EXTRA_REQUEST_BIOMETRY

public static EXTRA_REQUEST_BIOMETRY = "ru.yandex.speechkit.gui.request_biometry"

Flag (boolean) that includes in a response the Biometry object with estimated biometrics of the user.

Default value: false.

EXTRA_RESULT

public static EXTRA_RESULT = "ru.yandex.speechkit.gui.result"

Key for getting recognition results as a string if speech recognition is successful.

EXTRA_RETRY_ACTIVATION_MODEL

public static EXTRA_RETRY_ACTIVATION_MODEL = "ru.yandex.speechkit.gui.retry_activation_model"

The model used for configuration (Builder (String, PhraseSpotterListener)).

Default value: null.

EXTRA_SHOW_HYPOTHESES

public static EXTRA_SHOW_HYPOTHESES = "ru.yandex.speechkit.gui.show_hypotheses"

Flag (boolean) that sets up the "Hypotheses Screen" display option (the screen for displaying recognition hypotheses).

Default value: true.

EXTRA_SHOW_PARTIAL_RESULTS

public static EXTRA_SHOW_PARTIAL_RESULTS = "ru.yandex.speechkit.gui.show_partial_results"

Flag (boolean) that sets up the option to display partial results on the "Speak Screen" (the main screen to wait for speech for recognition).

Default value: true.

RESULT_ERROR

public static RESULT_ERROR = FragmentActivity.RESULT_FIRST_USER

Code that identifies whether speech recognition failed or was interrupted by the user.