public
class
TextToSpeech.Engine
extends Object
java.lang.Object | |
↳ | android.speech.tts.TextToSpeech.Engine |
Constants and parameter names for controlling text-to-speech. These include:
KEY_PARAM_UTTERANCE_ID
, KEY_PARAM_STREAM
.
KEY_FEATURE_NETWORK_SYNTHESIS
. These values may be passed in to
speak(CharSequence, int, Bundle, String)
and synthesizeToFile(CharSequence, Bundle, File, String)
to modify
engine behaviour. The engine can be queried for the set of features it supports
through getFeatures(java.util.Locale)
.
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_GET_SAMPLE_TEXT
Activity intent for getting some sample text to use for demonstrating TTS. |
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 change in the list of available languages or/and their features. |
int |
CHECK_VOICE_DATA_BAD_DATA
This constant was deprecated in API level 18. Use CHECK_VOICE_DATA_FAIL instead. |
int |
CHECK_VOICE_DATA_FAIL
Indicates failure when checking the installation status of the resources used by the
TextToSpeech engine with the |
int |
CHECK_VOICE_DATA_MISSING_DATA
This constant was deprecated in API level 18. Use CHECK_VOICE_DATA_FAIL instead. |
int |
CHECK_VOICE_DATA_MISSING_VOLUME
This constant was deprecated in API level 18. Use CHECK_VOICE_DATA_FAIL instead. |
int |
CHECK_VOICE_DATA_PASS
Indicates success when checking the installation status of the resources used by the
TextToSpeech engine with the |
int |
DEFAULT_STREAM
Default audio stream used when playing synthesized speech. |
String |
EXTRA_AVAILABLE_VOICES
Extra information received with the |
String |
EXTRA_CHECK_VOICE_DATA_FOR
This constant was deprecated in API level 18. Redundant functionality, checking for existence of specific sets of voice data can be done on client side. |
String |
EXTRA_SAMPLE_TEXT
Extra information received with the |
String |
EXTRA_TTS_DATA_INSTALLED
This constant was deprecated in API level 18. No longer in use. If client ise interested in information about what changed, is should send ACTION_CHECK_TTS_DATA intent to discover available voices. |
String |
EXTRA_UNAVAILABLE_VOICES
Extra information received with the |
String |
EXTRA_VOICE_DATA_FILES
This constant was deprecated in API level 18. TTS engine implementation detail, this information has no use for text-to-speech API client. |
String |
EXTRA_VOICE_DATA_FILES_INFO
This constant was deprecated in API level 18. TTS engine implementation detail, this information has no use for text-to-speech API client. |
String |
EXTRA_VOICE_DATA_ROOT_DIRECTORY
This constant was deprecated in API level 18. TTS engine implementation detail, this information has no use for text-to-speech API client. |
String |
INTENT_ACTION_TTS_SERVICE
Intent for starting a TTS service. |
String |
KEY_FEATURE_EMBEDDED_SYNTHESIS
This constant was deprecated
in API level 21.
Starting from API level 21, to select embedded synthesis, call
( |
String |
KEY_FEATURE_NETWORK_RETRIES_COUNT
Feature key that indicates that network request retries count can be set for the request. |
String |
KEY_FEATURE_NETWORK_SYNTHESIS
This constant was deprecated
in API level 21.
Starting from API level 21, to select network synthesis, call
|
String |
KEY_FEATURE_NETWORK_TIMEOUT_MS
Feature key that indicate that a network timeout can be set for the request. |
String |
KEY_FEATURE_NOT_INSTALLED
Feature key that indicates that the voice may need to download additional data to be fully functional. |
String |
KEY_PARAM_PAN
Parameter key to specify how the speech is panned from left to right when speaking text. |
String |
KEY_PARAM_SESSION_ID
Parameter key to specify an audio session identifier (obtained from
|
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
|
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()
|
Inherited methods | |
---|---|
From
class
java.lang.Object
|
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. 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 ArrayListEXTRA_UNAVAILABLE_VOICES
which contains an ArrayListConstant Value: "android.speech.tts.engine.CHECK_TTS_DATA"
String ACTION_GET_SAMPLE_TEXT
Activity intent for getting some sample text to use for demonstrating TTS. Specific locale have to be requested by passing following extra parameters:
EXTRA_SAMPLE_TEXT
which contains an String with sample text.Constant Value: "android.speech.tts.engine.GET_SAMPLE_TEXT"
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. 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"
String ACTION_TTS_DATA_INSTALLED
Broadcast Action: broadcast to signal the change in the list of available languages or/and their features.
Constant Value: "android.speech.tts.engine.TTS_DATA_INSTALLED"
int CHECK_VOICE_DATA_BAD_DATA
This constant was deprecated
in API level 18.
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.
Constant Value: -1 (0xffffffff)
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.
Constant Value: 0 (0x00000000)
int CHECK_VOICE_DATA_MISSING_DATA
This constant was deprecated
in API level 18.
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.
Constant Value: -2 (0xfffffffe)
int CHECK_VOICE_DATA_MISSING_VOLUME
This constant was deprecated
in API level 18.
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.
Constant Value: -3 (0xfffffffd)
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.
Constant Value: 1 (0x00000001)
int DEFAULT_STREAM
Default audio stream used when playing synthesized speech.
Constant Value: 3 (0x00000003)
String EXTRA_AVAILABLE_VOICES
Extra information received with the ACTION_CHECK_TTS_DATA
intent result where
the TextToSpeech engine returns an ArrayList
Constant Value: "availableVoices"
String EXTRA_CHECK_VOICE_DATA_FOR
This constant was deprecated
in API level 18.
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
Constant Value: "checkVoiceDataFor"
String EXTRA_SAMPLE_TEXT
Extra information received with the ACTION_GET_SAMPLE_TEXT
intent result where
the TextToSpeech engine returns an String with sample text for requested voice
Constant Value: "sampleText"
String EXTRA_TTS_DATA_INSTALLED
This constant was deprecated
in API level 18.
No longer in use. If client ise interested in information about what
changed, is should send 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
SUCCESS
and ERROR
.
Constant Value: "dataInstalled"
String EXTRA_UNAVAILABLE_VOICES
Extra information received with the ACTION_CHECK_TTS_DATA
intent result where
the TextToSpeech engine returns an ArrayList
Constant Value: "unavailableVoices"
String EXTRA_VOICE_DATA_FILES
This constant was deprecated
in API level 18.
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.
Constant Value: "dataFiles"
String EXTRA_VOICE_DATA_FILES_INFO
This constant was deprecated
in API level 18.
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.
Constant Value: "dataFilesInfo"
String EXTRA_VOICE_DATA_ROOT_DIRECTORY
This constant was deprecated
in API level 18.
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.
Constant Value: "dataRoot"
String INTENT_ACTION_TTS_SERVICE
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"
String KEY_FEATURE_EMBEDDED_SYNTHESIS
This constant was deprecated
in API level 21.
Starting from API level 21, to select embedded synthesis, call
(getVoices()
, find a suitable embedded voice
(isNetworkConnectionRequired()
) and pass it
to setVoice(Voice)
).
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).
See also:
Constant Value: "embeddedTts"
String KEY_FEATURE_NETWORK_RETRIES_COUNT
Feature key that indicates that network request retries count can be set for the request.
If set and supported as per getFeatures(Locale)
or
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.
Constant Value: "networkRetriesCount"
String KEY_FEATURE_NETWORK_SYNTHESIS
This constant was deprecated
in API level 21.
Starting from API level 21, to select network synthesis, call
getVoices()
, find a suitable network voice
(isNetworkConnectionRequired()
) and pass it
to setVoice(Voice)
.
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.
See also:
Constant Value: "networkTts"
String KEY_FEATURE_NETWORK_TIMEOUT_MS
Feature key that indicate that a network timeout can be set for the request. If set and
supported as per getFeatures(Locale)
or 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.
Constant Value: "networkTimeoutMs"
String KEY_FEATURE_NOT_INSTALLED
Feature key that indicates that the voice may need to download additional data to be fully
functional. The download will be triggered by calling
setVoice(Voice)
or setLanguage(Locale)
.
Until download is complete, each synthesis request will either report
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.
Constant Value: "notInstalled"
String KEY_PARAM_PAN
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"
String KEY_PARAM_SESSION_ID
Parameter key to specify an audio session identifier (obtained from
generateAudioSessionId()
) that will be used by the request audio
output. It can be used to associate one of the AudioEffect
objects with the synthesis (or earcon) output.
Constant Value: "sessionId"
String KEY_PARAM_STREAM
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"
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.
See also:
Constant Value: "utteranceId"
String KEY_PARAM_VOLUME
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"
String SERVICE_META_DATA
Name under which a text to speech engine publishes information about itself.
This meta-data should reference an XML resource containing a
<
tag.
tts-engine
>
Constant Value: "android.speech.tts"