public class TextToSpeech.Engine extends Object
KEY_PARAM_UTTERANCE_ID
, KEY_PARAM_STREAM
.
KEY_FEATURE_NETWORK_SYNTHESIS
. These values may be passed in to
TextToSpeech.speak(java.lang.CharSequence, int, android.os.Bundle, java.lang.String)
and TextToSpeech.synthesizeToFile(java.lang.CharSequence, android.os.Bundle, java.io.File, java.lang.String)
to modify
engine behaviour. The engine can be queried for the set of features it supports
through TextToSpeech.getFeatures(java.util.Locale)
.
Modifier and Type | Field and Description |
---|---|
static 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.
|
static String |
ACTION_GET_SAMPLE_TEXT
Activity intent for getting some sample text to use for demonstrating TTS.
|
static 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.
|
static String |
ACTION_TTS_DATA_INSTALLED
Broadcast Action: broadcast to signal the change in the list of available
languages or/and their features.
|
static int |
CHECK_VOICE_DATA_BAD_DATA
Deprecated.
Use CHECK_VOICE_DATA_FAIL instead.
|
static 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. |
static int |
CHECK_VOICE_DATA_MISSING_DATA
Deprecated.
Use CHECK_VOICE_DATA_FAIL instead.
|
static int |
CHECK_VOICE_DATA_MISSING_VOLUME
Deprecated.
Use CHECK_VOICE_DATA_FAIL instead.
|
static 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. |
static String |
DEFAULT_ENGINE
Deprecated.
No longer in use, the default engine is determined by
the sort order defined in
TtsEngines . Note that
this doesn't "break" anything because there is no guarantee that
the engine specified below is installed on a given build, let
alone be the default. |
static float |
DEFAULT_PAN
Default pan (centered).
|
static int |
DEFAULT_PITCH
Default pitch.
|
static int |
DEFAULT_RATE
Default speech rate.
|
static int |
DEFAULT_STREAM
Default audio stream used when playing synthesized speech.
|
static float |
DEFAULT_VOLUME
Default volume.
|
static String |
EXTRA_AVAILABLE_VOICES
Extra information received with the
ACTION_CHECK_TTS_DATA intent result where
the TextToSpeech engine returns an ArrayList |
static String |
EXTRA_CHECK_VOICE_DATA_FOR
Deprecated.
Redundant functionality, checking for existence of specific sets of voice
data can be done on client side.
|
static 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 |
static String |
EXTRA_TTS_DATA_INSTALLED
Deprecated.
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.
|
static String |
EXTRA_UNAVAILABLE_VOICES
Extra information received with the
ACTION_CHECK_TTS_DATA intent result where
the TextToSpeech engine returns an ArrayList |
static String |
EXTRA_VOICE_DATA_FILES
Deprecated.
TTS engine implementation detail, this information has no use for
text-to-speech API client.
|
static String |
EXTRA_VOICE_DATA_FILES_INFO
Deprecated.
TTS engine implementation detail, this information has no use for
text-to-speech API client.
|
static String |
EXTRA_VOICE_DATA_ROOT_DIRECTORY
Deprecated.
TTS engine implementation detail, this information has no use for
text-to-speech API client.
|
static String |
INTENT_ACTION_TTS_SERVICE
Intent for starting a TTS service.
|
static String |
KEY_FEATURE_EMBEDDED_SYNTHESIS
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) ). |
static String |
KEY_FEATURE_NETWORK_RETRIES_COUNT
Feature key that indicates that network request retries count can be set for the request.
|
static String |
KEY_FEATURE_NETWORK_SYNTHESIS
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) . |
static String |
KEY_FEATURE_NETWORK_TIMEOUT_MS
Feature key that indicate that a network timeout can be set for the request.
|
static String |
KEY_FEATURE_NOT_INSTALLED
Feature key that indicates that the voice may need to download additional data to be fully
functional.
|
static String |
KEY_PARAM_AUDIO_ATTRIBUTES
Parameter key to specify the audio attributes to be used when
speaking text or playing back a file.
|
static String |
KEY_PARAM_COUNTRY |
static String |
KEY_PARAM_ENGINE |
static String |
KEY_PARAM_LANGUAGE |
static String |
KEY_PARAM_PAN
Parameter key to specify how the speech is panned from left to right when speaking text.
|
static String |
KEY_PARAM_PITCH |
static String |
KEY_PARAM_RATE |
static String |
KEY_PARAM_SESSION_ID
Parameter key to specify an audio session identifier (obtained from
AudioManager.generateAudioSessionId() ) that will be used by the request audio
output. |
static String |
KEY_PARAM_STREAM
Parameter key to specify the audio stream type to be used when speaking text
or playing back a file.
|
static 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. |
static String |
KEY_PARAM_VARIANT |
static String |
KEY_PARAM_VOICE_NAME |
static String |
KEY_PARAM_VOLUME
Parameter key to specify the speech volume relative to the current stream type
volume used when speaking text.
|
static String |
SERVICE_META_DATA
Name under which a text to speech engine publishes information about itself.
|
static int |
USE_DEFAULTS
Default value for
Settings.Secure#TTS_USE_DEFAULTS . |
Constructor and Description |
---|
Engine() |
public static final int DEFAULT_RATE
public static final int DEFAULT_PITCH
public static final float DEFAULT_VOLUME
public static final float DEFAULT_PAN
public static final int USE_DEFAULTS
Settings.Secure#TTS_USE_DEFAULTS
.@Deprecated public static final String DEFAULT_ENGINE
TtsEngines
. Note that
this doesn't "break" anything because there is no guarantee that
the engine specified below is installed on a given build, let
alone be the default.public static final int DEFAULT_STREAM
public static final int CHECK_VOICE_DATA_PASS
ACTION_CHECK_TTS_DATA
intent.public static final int CHECK_VOICE_DATA_FAIL
ACTION_CHECK_TTS_DATA
intent.@Deprecated public static final int CHECK_VOICE_DATA_BAD_DATA
ACTION_CHECK_TTS_DATA
intent.@Deprecated public static final int CHECK_VOICE_DATA_MISSING_DATA
ACTION_CHECK_TTS_DATA
intent.@Deprecated public static final int CHECK_VOICE_DATA_MISSING_VOLUME
ACTION_CHECK_TTS_DATA
intent.public static final String INTENT_ACTION_TTS_SERVICE
TextToSpeechService
. Normal applications should not use this intent
directly, instead they should talk to the TTS service using the the methods in this
class.public static final String SERVICE_META_DATA
<tts-engine
>
tag.public static final String ACTION_INSTALL_TTS_DATA
ACTION_CHECK_TTS_DATA
.public static final String ACTION_TTS_DATA_INSTALLED
public static final String ACTION_CHECK_TTS_DATA
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 ArrayListpublic static final String ACTION_GET_SAMPLE_TEXT
EXTRA_SAMPLE_TEXT
which contains an String with sample text.public static final String EXTRA_SAMPLE_TEXT
ACTION_GET_SAMPLE_TEXT
intent result where
the TextToSpeech engine returns an String with sample text for requested voicepublic static final String EXTRA_AVAILABLE_VOICES
ACTION_CHECK_TTS_DATA
intent result where
the TextToSpeech engine returns an ArrayListpublic static final String EXTRA_UNAVAILABLE_VOICES
ACTION_CHECK_TTS_DATA
intent result where
the TextToSpeech engine returns an ArrayList@Deprecated public static final String EXTRA_VOICE_DATA_ROOT_DIRECTORY
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.@Deprecated public static final String EXTRA_VOICE_DATA_FILES
ACTION_CHECK_TTS_DATA
intent result where
the TextToSpeech engine specifies the file names of its resources under the
resource path.@Deprecated public static final String EXTRA_VOICE_DATA_FILES_INFO
ACTION_CHECK_TTS_DATA
intent result where
the TextToSpeech engine specifies the locale associated with each resource file.@Deprecated public static final String EXTRA_CHECK_VOICE_DATA_FOR
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@Deprecated public static final String EXTRA_TTS_DATA_INSTALLED
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
.public static final String KEY_PARAM_RATE
public static final String KEY_PARAM_VOICE_NAME
public static final String KEY_PARAM_LANGUAGE
public static final String KEY_PARAM_COUNTRY
public static final String KEY_PARAM_VARIANT
public static final String KEY_PARAM_ENGINE
public static final String KEY_PARAM_PITCH
public static final String KEY_PARAM_STREAM
AudioManager
.public static final String KEY_PARAM_AUDIO_ATTRIBUTES
TextToSpeech.setAudioAttributes(AudioAttributes)
.public static final String KEY_PARAM_UTTERANCE_ID
TextToSpeech.OnUtteranceCompletedListener
after text has been
spoken, a file has been played back or a silence duration has elapsed.public static final String KEY_PARAM_VOLUME
public static final String KEY_PARAM_PAN
@Deprecated public static final String KEY_FEATURE_NETWORK_SYNTHESIS
TextToSpeech.getVoices()
, find a suitable network voice
(Voice.isNetworkConnectionRequired()
) and pass it
to TextToSpeech.setVoice(Voice)
.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.@Deprecated public static final String KEY_FEATURE_EMBEDDED_SYNTHESIS
TextToSpeech.getVoices()
, find a suitable embedded voice
(Voice.isNetworkConnectionRequired()
) and pass it
to TextToSpeech.setVoice(Voice)
).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).public static final String KEY_PARAM_SESSION_ID
AudioManager.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.public static final String KEY_FEATURE_NOT_INSTALLED
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.public static final String KEY_FEATURE_NETWORK_TIMEOUT_MS
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.public static final String KEY_FEATURE_NETWORK_RETRIES_COUNT
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.