Added in API level 4

Engine

open class Engine
kotlin.Any
   ↳ android.speech.tts.TextToSpeech.Engine

Constants and parameter names for controlling text-to-speech. These include:

Apps targeting Android 11 that use text-to-speech should declare android.speech.tts.TextToSpeech.Engine#INTENT_ACTION_TTS_SERVICE in the queries elements of their manifest:
<queries>
    ...
   <intent>
       <action android:name="android.intent.action.TTS_SERVICE" />
   </intent>
  </queries>
  

Summary

Constants
static String

Activity Action: Starts the activity from the platform TextToSpeech engine to verify the proper installation and availability of the resource files on the system.

static String

Activity intent for getting some sample text to use for demonstrating TTS.

static String

Activity Action: Triggers the platform TextToSpeech engine to start the activity that installs the resource files on the device that are required for TTS to be operational.

static String

Broadcast Action: broadcast to signal the change in the list of available languages or/and their features.

static Int

Indicates erroneous data when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.

static Int

Indicates failure when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.

static Int

Indicates missing resources when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.

static Int

Indicates missing storage volume when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.

static Int

Indicates success when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.

static Int

Default audio stream used when playing synthesized speech.

static String

Extra information received with the ACTION_CHECK_TTS_DATA intent result where the TextToSpeech engine returns an ArrayList of all the available voices. The format of each voice is: lang-COUNTRY-variant where COUNTRY and variant are optional (ie, "eng" or "eng-USA" or "eng-USA-FEMALE").

static String

Extra information sent with the ACTION_CHECK_TTS_DATA intent where the caller indicates to the TextToSpeech engine which specific sets of voice data to check for by sending an ArrayList of the voices that are of interest. The format of each voice is: lang-COUNTRY-variant where COUNTRY and variant are optional (ie, "eng" or "eng-USA" or "eng-USA-FEMALE").

static String

Extra information received with the ACTION_GET_SAMPLE_TEXT intent result where the TextToSpeech engine returns an String with sample text for requested voice

static String

Extra information received with the ACTION_TTS_DATA_INSTALLED intent result.

static String

Extra information received with the ACTION_CHECK_TTS_DATA intent result where the TextToSpeech engine returns an ArrayList of all the unavailable voices. The format of each voice is: lang-COUNTRY-variant where COUNTRY and variant are optional (ie, "eng" or "eng-USA" or "eng-USA-FEMALE").

static String

Extra information received with the ACTION_CHECK_TTS_DATA intent result where the TextToSpeech engine specifies the file names of its resources under the resource path.

static String

Extra information received with the ACTION_CHECK_TTS_DATA intent result where the TextToSpeech engine specifies the locale associated with each resource file.

static String

Extra information received with the ACTION_CHECK_TTS_DATA intent result where the TextToSpeech engine specifies the path to its resources.

static String

Intent for starting a TTS service.

static String

Feature key for embedded synthesis.

static String

Feature key that indicates that network request retries count can be set for the request.

static String

Feature key for network synthesis.

static String

Feature key that indicate that a network timeout can be set for the request.

static String

Feature key that indicates that the voice may need to download additional data to be fully functional.

static String

Parameter key to specify how the speech is panned from left to right when speaking text.

static String

Parameter key to specify an audio session identifier (obtained from AudioManager#generateAudioSessionId()) that will be used by the request audio output.

static String

Parameter key to specify the audio stream type to be used when speaking text or playing back a file.

static String

Parameter key to identify an utterance in the TextToSpeech.OnUtteranceCompletedListener after text has been spoken, a file has been played back or a silence duration has elapsed.

static String

Parameter key to specify the speech volume relative to the current stream type volume used when speaking text.

static String

Name under which a text to speech engine publishes information about itself.

Public constructors

Constants

ACTION_CHECK_TTS_DATA

Added in API level 4
static val ACTION_CHECK_TTS_DATA: String

Activity Action: Starts the activity from the platform TextToSpeech engine to verify the proper installation and availability of the resource files on the system. Upon completion, the activity will return one of the following codes: CHECK_VOICE_DATA_PASS, CHECK_VOICE_DATA_FAIL,

Moreover, the data received in the activity result will contain the following fields:

  • EXTRA_AVAILABLE_VOICES which contains an ArrayList of all the available voices. The format of each voice is: lang-COUNTRY-variant where COUNTRY and variant are optional (ie, "eng" or "eng-USA" or "eng-USA-FEMALE").
  • EXTRA_UNAVAILABLE_VOICES which contains an ArrayList of all the unavailable voices (ones that user can install). The format of each voice is: lang-COUNTRY-variant where COUNTRY and variant are optional (ie, "eng" or "eng-USA" or "eng-USA-FEMALE").
Value: "android.speech.tts.engine.CHECK_TTS_DATA"

ACTION_GET_SAMPLE_TEXT

Added in API level 18
static val ACTION_GET_SAMPLE_TEXT: String

Activity intent for getting some sample text to use for demonstrating TTS. Specific locale have to be requested by passing following extra parameters:

  • language
  • country
  • variant
Upon completion, the activity result may contain the following fields:

Value: "android.speech.tts.engine.GET_SAMPLE_TEXT"

ACTION_INSTALL_TTS_DATA

Added in API level 4
static val ACTION_INSTALL_TTS_DATA: String

Activity Action: Triggers the platform TextToSpeech engine to start the activity that installs the resource files on the device that are required for TTS to be operational. Since the installation of the data can be interrupted or declined by the user, the application shouldn't expect successful installation upon return from that intent, and if need be, should check installation status with ACTION_CHECK_TTS_DATA.

Value: "android.speech.tts.engine.INSTALL_TTS_DATA"

ACTION_TTS_DATA_INSTALLED

Added in API level 4
static val ACTION_TTS_DATA_INSTALLED: String

Broadcast Action: broadcast to signal the change in the list of available languages or/and their features.

Value: "android.speech.tts.engine.TTS_DATA_INSTALLED"

CHECK_VOICE_DATA_BAD_DATA

Added in API level 4
Deprecated in API level 18
static val CHECK_VOICE_DATA_BAD_DATA: Int

Deprecated: Use CHECK_VOICE_DATA_FAIL instead.

Indicates erroneous data when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.

Value: -1

CHECK_VOICE_DATA_FAIL

Added in API level 4
static val CHECK_VOICE_DATA_FAIL: Int

Indicates failure when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.

Value: 0

CHECK_VOICE_DATA_MISSING_DATA

Added in API level 4
Deprecated in API level 18
static val CHECK_VOICE_DATA_MISSING_DATA: Int

Deprecated: Use CHECK_VOICE_DATA_FAIL instead.

Indicates missing resources when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.

Value: -2

CHECK_VOICE_DATA_MISSING_VOLUME

Added in API level 4
Deprecated in API level 18
static val CHECK_VOICE_DATA_MISSING_VOLUME: Int

Deprecated: Use CHECK_VOICE_DATA_FAIL instead.

Indicates missing storage volume when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.

Value: -3

CHECK_VOICE_DATA_PASS

Added in API level 4
static val CHECK_VOICE_DATA_PASS: Int

Indicates success when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.

Value: 1

DEFAULT_STREAM

Added in API level 4
static val DEFAULT_STREAM: Int

Default audio stream used when playing synthesized speech.

Value: 3

EXTRA_AVAILABLE_VOICES

Added in API level 8
static val EXTRA_AVAILABLE_VOICES: String

Extra information received with the ACTION_CHECK_TTS_DATA intent result where the TextToSpeech engine returns an ArrayList of all the available voices. The format of each voice is: lang-COUNTRY-variant where COUNTRY and variant are optional (ie, "eng" or "eng-USA" or "eng-USA-FEMALE").

Value: "availableVoices"

EXTRA_CHECK_VOICE_DATA_FOR

Added in API level 8
Deprecated in API level 18
static val EXTRA_CHECK_VOICE_DATA_FOR: String

Deprecated: Redundant functionality, checking for existence of specific sets of voice data can be done on client side.

Extra information sent with the ACTION_CHECK_TTS_DATA intent where the caller indicates to the TextToSpeech engine which specific sets of voice data to check for by sending an ArrayList of the voices that are of interest. The format of each voice is: lang-COUNTRY-variant where COUNTRY and variant are optional (ie, "eng" or "eng-USA" or "eng-USA-FEMALE").

Value: "checkVoiceDataFor"

EXTRA_SAMPLE_TEXT

Added in API level 18
static val EXTRA_SAMPLE_TEXT: String

Extra information received with the ACTION_GET_SAMPLE_TEXT intent result where the TextToSpeech engine returns an String with sample text for requested voice

Value: "sampleText"

EXTRA_TTS_DATA_INSTALLED

Added in API level 4
Deprecated in API level 18
static val EXTRA_TTS_DATA_INSTALLED: String

Deprecated: No longer in use. If client is interested in information about what changed, it should use the ACTION_CHECK_TTS_DATA intent to discover available voices.

Extra information received with the ACTION_TTS_DATA_INSTALLED intent result. It indicates whether the data files for the synthesis engine were successfully installed. The installation was initiated with the ACTION_INSTALL_TTS_DATA intent. The possible values for this extra are TextToSpeech#SUCCESS and TextToSpeech#ERROR.

Value: "dataInstalled"

EXTRA_UNAVAILABLE_VOICES

Added in API level 8
static val EXTRA_UNAVAILABLE_VOICES: String

Extra information received with the ACTION_CHECK_TTS_DATA intent result where the TextToSpeech engine returns an ArrayList of all the unavailable voices. The format of each voice is: lang-COUNTRY-variant where COUNTRY and variant are optional (ie, "eng" or "eng-USA" or "eng-USA-FEMALE").

Value: "unavailableVoices"

EXTRA_VOICE_DATA_FILES

Added in API level 4
Deprecated in API level 18
static val EXTRA_VOICE_DATA_FILES: String

Deprecated: TTS engine implementation detail, this information has no use for text-to-speech API client.

Extra information received with the ACTION_CHECK_TTS_DATA intent result where the TextToSpeech engine specifies the file names of its resources under the resource path.

Value: "dataFiles"

EXTRA_VOICE_DATA_FILES_INFO

Added in API level 4
Deprecated in API level 18
static val EXTRA_VOICE_DATA_FILES_INFO: String

Deprecated: TTS engine implementation detail, this information has no use for text-to-speech API client.

Extra information received with the ACTION_CHECK_TTS_DATA intent result where the TextToSpeech engine specifies the locale associated with each resource file.

Value: "dataFilesInfo"

EXTRA_VOICE_DATA_ROOT_DIRECTORY

Added in API level 4
Deprecated in API level 18
static val EXTRA_VOICE_DATA_ROOT_DIRECTORY: String

Deprecated: TTS engine implementation detail, this information has no use for text-to-speech API client.

Extra information received with the ACTION_CHECK_TTS_DATA intent result where the TextToSpeech engine specifies the path to its resources. It may be used by language packages to find out where to put their data.

Value: "dataRoot"

INTENT_ACTION_TTS_SERVICE

Added in API level 14
static val INTENT_ACTION_TTS_SERVICE: String

Intent for starting a TTS service. Services that handle this intent must extend TextToSpeechService. Normal applications should not use this intent directly, instead they should talk to the TTS service using the the methods in this class.

Value: "android.intent.action.TTS_SERVICE"

KEY_FEATURE_EMBEDDED_SYNTHESIS

Added in API level 15
Deprecated in API level 21
static val KEY_FEATURE_EMBEDDED_SYNTHESIS: String

Deprecated: Starting from API level 21, to select embedded synthesis, call (TextToSpeech#getVoices(), find a suitable embedded voice (Voice#isNetworkConnectionRequired()) and pass it to TextToSpeech#setVoice(Voice)).

Feature key for embedded synthesis. See TextToSpeech#getFeatures(Locale) for a description of how feature keys work. If set and supported by the engine as per TextToSpeech#getFeatures(Locale), the engine must synthesize text on-device (without making network requests).

Value: "embeddedTts"

KEY_FEATURE_NETWORK_RETRIES_COUNT

Added in API level 21
static val KEY_FEATURE_NETWORK_RETRIES_COUNT: String

Feature key that indicates that network request retries count can be set for the request. If set and supported as per TextToSpeech#getFeatures(Locale) or Voice#getFeatures(), it can be used as a request parameter to set the number of network request retries that are attempted in case of failure. When used as a key of a request parameter, its value should be a string with an integer value.

Value: "networkRetriesCount"

KEY_FEATURE_NETWORK_SYNTHESIS

Added in API level 15
Deprecated in API level 21
static val KEY_FEATURE_NETWORK_SYNTHESIS: String

Deprecated: Starting from API level 21, to select network synthesis, call TextToSpeech#getVoices(), find a suitable network voice (Voice#isNetworkConnectionRequired()) and pass it to TextToSpeech#setVoice(Voice).

Feature key for network synthesis. See TextToSpeech#getFeatures(Locale) for a description of how feature keys work. If set (and supported by the engine as per TextToSpeech#getFeatures(Locale), the engine must use network based synthesis.

Value: "networkTts"

KEY_FEATURE_NETWORK_TIMEOUT_MS

Added in API level 21
static val KEY_FEATURE_NETWORK_TIMEOUT_MS: String

Feature key that indicate that a network timeout can be set for the request. If set and supported as per TextToSpeech#getFeatures(Locale) or Voice#getFeatures(), it can be used as request parameter to set the maximum allowed time for a single request attempt, in milliseconds, before synthesis fails. When used as a key of a request parameter, its value should be a string with an integer value.

Value: "networkTimeoutMs"

KEY_FEATURE_NOT_INSTALLED

Added in API level 21
static val KEY_FEATURE_NOT_INSTALLED: String

Feature key that indicates that the voice may need to download additional data to be fully functional. The download will be triggered by calling TextToSpeech#setVoice(Voice) or TextToSpeech#setLanguage(Locale). Until download is complete, each synthesis request will either report TextToSpeech#ERROR_NOT_INSTALLED_YET error, or use a different voice to synthesize the request. This feature should NOT be used as a key of a request parameter.

Value: "notInstalled"

KEY_PARAM_PAN

Added in API level 11
static val KEY_PARAM_PAN: String

Parameter key to specify how the speech is panned from left to right when speaking text. Pan is specified as a float ranging from -1 to +1 where -1 maps to a hard-left pan, 0 to center (the default behavior), and +1 to hard-right.

Value: "pan"

KEY_PARAM_SESSION_ID

Added in API level 21
static val KEY_PARAM_SESSION_ID: String

Parameter key to specify an audio session identifier (obtained from AudioManager#generateAudioSessionId()) that will be used by the request audio output. It can be used to associate one of the android.media.audiofx.AudioEffect objects with the synthesis (or earcon) output.

Value: "sessionId"

KEY_PARAM_STREAM

Added in API level 4
static val KEY_PARAM_STREAM: String

Parameter key to specify the audio stream type to be used when speaking text or playing back a file. The value should be one of the STREAM_ constants defined in AudioManager.

Value: "streamType"

KEY_PARAM_UTTERANCE_ID

Added in API level 4
static val KEY_PARAM_UTTERANCE_ID: String

Parameter key to identify an utterance in the TextToSpeech.OnUtteranceCompletedListener after text has been spoken, a file has been played back or a silence duration has elapsed.

Value: "utteranceId"

KEY_PARAM_VOLUME

Added in API level 11
static val KEY_PARAM_VOLUME: String

Parameter key to specify the speech volume relative to the current stream type volume used when speaking text. Volume is specified as a float ranging from 0 to 1 where 0 is silence, and 1 is the maximum volume (the default behavior).

Value: "volume"

SERVICE_META_DATA

Added in API level 14
static val SERVICE_META_DATA: String

Name under which a text to speech engine publishes information about itself. This meta-data should reference an XML resource containing a <tts-engine> tag.

Value: "android.speech.tts"

Public constructors

Engine

Engine()