to top
Android APIs
public class

TextToSpeech.Engine

extends Object
java.lang.Object
   ↳ android.speech.tts.TextToSpeech.Engine

Class Overview

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

Summary

Constants
String ACTION_CHECK_TTS_DATA Activity Action: Starts the activity from the platform TextToSpeech engine to verify the proper installation and availability of the resource files on the system.
String ACTION_INSTALL_TTS_DATA 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.
String ACTION_TTS_DATA_INSTALLED Broadcast Action: broadcast to signal the completion of the installation of the data files used by the synthesis engine.
int CHECK_VOICE_DATA_BAD_DATA Indicates erroneous data when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.
int CHECK_VOICE_DATA_FAIL Indicates failure when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.
int CHECK_VOICE_DATA_MISSING_DATA Indicates missing resources when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.
int CHECK_VOICE_DATA_MISSING_VOLUME Indicates missing storage volume when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.
int CHECK_VOICE_DATA_PASS Indicates success when checking the installation status of the resources used by the TextToSpeech engine with the ACTION_CHECK_TTS_DATA intent.
int DEFAULT_STREAM Default audio stream used when playing synthesized speech.
String EXTRA_AVAILABLE_VOICES Extra information received with the ACTION_CHECK_TTS_DATA intent where the TextToSpeech engine returns an ArrayList of all the available voices.
String EXTRA_CHECK_VOICE_DATA_FOR 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.
String EXTRA_TTS_DATA_INSTALLED Extra information received with the ACTION_TTS_DATA_INSTALLED intent.
String EXTRA_UNAVAILABLE_VOICES Extra information received with the ACTION_CHECK_TTS_DATA intent where the TextToSpeech engine returns an ArrayList of all the unavailable voices.
String EXTRA_VOICE_DATA_FILES Extra information received with the ACTION_CHECK_TTS_DATA intent where the TextToSpeech engine specifies the file names of its resources under the resource path.
String EXTRA_VOICE_DATA_FILES_INFO Extra information received with the ACTION_CHECK_TTS_DATA intent where the TextToSpeech engine specifies the locale associated with each resource file.
String EXTRA_VOICE_DATA_ROOT_DIRECTORY Extra information received with the ACTION_CHECK_TTS_DATA intent where the TextToSpeech engine specifies the path to its resources.
String INTENT_ACTION_TTS_SERVICE Intent for starting a TTS service.
String KEY_FEATURE_EMBEDDED_SYNTHESIS Feature key for embedded synthesis.
String KEY_FEATURE_NETWORK_SYNTHESIS Feature key for network synthesis.
String KEY_PARAM_PAN Parameter key to specify how the speech is panned from left to right when speaking text.
String KEY_PARAM_STREAM Parameter key to specify the audio stream type to be used when speaking text or playing back a file.
String KEY_PARAM_UTTERANCE_ID 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.
String KEY_PARAM_VOLUME Parameter key to specify the speech volume relative to the current stream type volume used when speaking text.
String SERVICE_META_DATA Name under which a text to speech engine publishes information about itself.
Public Constructors
TextToSpeech.Engine()
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_CHECK_TTS_DATA

Added in API level 4

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, CHECK_VOICE_DATA_BAD_DATA, CHECK_VOICE_DATA_MISSING_DATA, or CHECK_VOICE_DATA_MISSING_VOLUME.

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

  • EXTRA_VOICE_DATA_ROOT_DIRECTORY which indicates the path to the location of the resource files,
  • EXTRA_VOICE_DATA_FILES which contains the list of all the resource files,
  • and EXTRA_VOICE_DATA_FILES_INFO which contains, for each resource file, the description of the language covered by the file in the xxx-YYY format, where xxx is the 3-letter ISO language code, and YYY is the 3-letter ISO country code.

Constant Value: "android.speech.tts.engine.CHECK_TTS_DATA"

public static final String ACTION_INSTALL_TTS_DATA

Added in API level 4

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.

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

public static final String ACTION_TTS_DATA_INSTALLED

Added in API level 4

Broadcast Action: broadcast to signal the completion of the installation of the data files used by the synthesis engine. Success or failure is indicated in the EXTRA_TTS_DATA_INSTALLED extra.

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

public static final int CHECK_VOICE_DATA_BAD_DATA

Added in API level 4

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

Constant Value: -1 (0xffffffff)

public static final int CHECK_VOICE_DATA_FAIL

Added in API level 4

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

Constant Value: 0 (0x00000000)

public static final int CHECK_VOICE_DATA_MISSING_DATA

Added in API level 4

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

Constant Value: -2 (0xfffffffe)

public static final int CHECK_VOICE_DATA_MISSING_VOLUME

Added in API level 4

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

Constant Value: -3 (0xfffffffd)

public static final int CHECK_VOICE_DATA_PASS

Added in API level 4

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

Constant Value: 1 (0x00000001)

public static final int DEFAULT_STREAM

Added in API level 4

Default audio stream used when playing synthesized speech.

Constant Value: 3 (0x00000003)

public static final String EXTRA_AVAILABLE_VOICES

Added in API level 8

Extra information received with the ACTION_CHECK_TTS_DATA intent 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").

Constant Value: "availableVoices"

public static final String EXTRA_CHECK_VOICE_DATA_FOR

Added in API level 8

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

Constant Value: "checkVoiceDataFor"

public static final String EXTRA_TTS_DATA_INSTALLED

Added in API level 4

Extra information received with the ACTION_TTS_DATA_INSTALLED intent. 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 SUCCESS and ERROR.

Constant Value: "dataInstalled"

public static final String EXTRA_UNAVAILABLE_VOICES

Added in API level 8

Extra information received with the ACTION_CHECK_TTS_DATA intent 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").

Constant Value: "unavailableVoices"

public static final String EXTRA_VOICE_DATA_FILES

Added in API level 4

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

Constant Value: "dataFiles"

public static final String EXTRA_VOICE_DATA_FILES_INFO

Added in API level 4

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

Constant Value: "dataFilesInfo"

public static final String EXTRA_VOICE_DATA_ROOT_DIRECTORY

Added in API level 4

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

Constant Value: "dataRoot"

public static final String INTENT_ACTION_TTS_SERVICE

Added in API level 14

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.

Constant Value: "android.intent.action.TTS_SERVICE"

public static final String KEY_FEATURE_EMBEDDED_SYNTHESIS

Added in API level 15

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

Constant Value: "embeddedTts"

public static final String KEY_FEATURE_NETWORK_SYNTHESIS

Added in API level 15

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

Constant Value: "networkTts"

public static final String KEY_PARAM_PAN

Added in API level 11

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.

Constant Value: "pan"

public static final String KEY_PARAM_STREAM

Added in API level 4

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.

Constant Value: "streamType"

public static final String KEY_PARAM_UTTERANCE_ID

Added in API level 4

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.

Constant Value: "utteranceId"

public static final String KEY_PARAM_VOLUME

Added in API level 11

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

Constant Value: "volume"

public static final String SERVICE_META_DATA

Added in API level 14

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.

Constant Value: "android.speech.tts"

Public Constructors

public TextToSpeech.Engine ()

Added in API level 4