AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.TextToSpeech Class Reference
Inheritance diagram for com.google.appinventor.components.runtime.TextToSpeech:
com.google.appinventor.components.runtime.AndroidNonvisibleComponent com.google.appinventor.components.runtime.Component com.google.appinventor.components.runtime.OnStopListener com.google.appinventor.components.runtime.OnResumeListener com.google.appinventor.components.runtime.OnDestroyListener com.google.appinventor.components.runtime.Component

Public Member Functions

 TextToSpeech (ComponentContainer container)
 
boolean Result ()
 
void Language (String language)
 
void Pitch (float pitch)
 
float Pitch ()
 
void SpeechRate (float speechRate)
 
float SpeechRate ()
 
String Language ()
 
void Country (String country)
 
String Country ()
 
YailList AvailableLanguages ()
 
YailList AvailableCountries ()
 
void prepareLanguageAndCountryProperties ()
 
void Speak (final String message)
 
void BeforeSpeaking ()
 
void AfterSpeaking (boolean result)
 
void onStop ()
 
void onResume ()
 
void onDestroy ()
 
- Public Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
HandlesEventDispatching getDispatchDelegate ()
 

Additional Inherited Members

- Static Public Attributes inherited from com.google.appinventor.components.runtime.Component
static final String ASSET_DIRECTORY = "component"
 
static final int ALIGNMENT_NORMAL = 0
 
static final int ALIGNMENT_CENTER = 1
 
static final int ALIGNMENT_OPPOSITE = 2
 
static final int ACCELEROMETER_SENSITIVITY_WEAK = 1
 
static final int ACCELEROMETER_SENSITIVITY_MODERATE = 2
 
static final int ACCELEROMETER_SENSITIVITY_STRONG = 3
 
static final int BUTTON_SHAPE_DEFAULT = 0
 
static final int BUTTON_SHAPE_ROUNDED = 1
 
static final int BUTTON_SHAPE_RECT = 2
 
static final int BUTTON_SHAPE_OVAL = 3
 
static final int COLOR_NONE = 0x00FFFFFF
 
static final int COLOR_BLACK = 0xFF000000
 
static final int COLOR_BLUE = 0xFF0000FF
 
static final int COLOR_CYAN = 0xFF00FFFF
 
static final int COLOR_DKGRAY = 0xFF444444
 
static final int COLOR_GRAY = 0xFF888888
 
static final int COLOR_GREEN = 0xFF00FF00
 
static final int COLOR_LTGRAY = 0xFFCCCCCC
 
static final int COLOR_MAGENTA = 0xFFFF00FF
 
static final int COLOR_ORANGE = 0xFFFFC800
 
static final int COLOR_PINK = 0xFFFFAFAF
 
static final int COLOR_RED = 0xFFFF0000
 
static final int COLOR_WHITE = 0xFFFFFFFF
 
static final int COLOR_YELLOW = 0xFFFFFF00
 
static final int COLOR_DEFAULT = 0x00000000
 
static final String DEFAULT_VALUE_COLOR_NONE = "&H00FFFFFF"
 
static final String DEFAULT_VALUE_COLOR_BLACK = "&HFF000000"
 
static final String DEFAULT_VALUE_COLOR_BLUE = "&HFF0000FF"
 
static final String DEFAULT_VALUE_COLOR_CYAN = "&HFF00FFFF"
 
static final String DEFAULT_VALUE_COLOR_DKGRAY = "&HFF444444"
 
static final String DEFAULT_VALUE_COLOR_GRAY = "&HFF888888"
 
static final String DEFAULT_VALUE_COLOR_GREEN = "&HFF00FF00"
 
static final String DEFAULT_VALUE_COLOR_LTGRAY = "&HFFCCCCCC"
 
static final String DEFAULT_VALUE_COLOR_MAGENTA = "&HFFFF00FF"
 
static final String DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800"
 
static final String DEFAULT_VALUE_COLOR_PINK = "&HFFFFAFAF"
 
static final String DEFAULT_VALUE_COLOR_RED = "&HFFFF0000"
 
static final String DEFAULT_VALUE_COLOR_WHITE = "&HFFFFFFFF"
 
static final String DEFAULT_VALUE_COLOR_YELLOW = "&HFFFFFF00"
 
static final String DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000"
 
static final float FONT_DEFAULT_SIZE = 14
 
static final int LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL
 
static final int LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL
 
static final int SCALING_SCALE_PROPORTIONALLY = 0
 
static final int SCALING_SCALE_TO_FIT = 1
 
static final int TYPEFACE_DEFAULT = 0
 
static final int TYPEFACE_SANSSERIF = 1
 
static final int TYPEFACE_SERIF = 2
 
static final int TYPEFACE_MONOSPACE = 3
 
static final int LENGTH_PREFERRED = -1
 
static final int LENGTH_FILL_PARENT = -2
 
static final int LENGTH_UNKNOWN = -3
 
static final int LENGTH_PERCENT_TAG = -1000
 
static final int TOAST_LENGTH_SHORT = 0
 
static final int TOAST_LENGTH_LONG = 1
 
static final int DIRECTION_NORTH = 1
 
static final int DIRECTION_NORTHEAST = 2
 
static final int DIRECTION_EAST = 3
 
static final int DIRECTION_SOUTHEAST = 4
 
static final int DIRECTION_SOUTH = -1
 
static final int DIRECTION_SOUTHWEST = -2
 
static final int DIRECTION_WEST = -3
 
static final int DIRECTION_NORTHWEST = -4
 
static final int DIRECTION_NONE = 0
 
static final int DIRECTION_MIN = -4
 
static final int DIRECTION_MAX = 4
 
static float SLIDER_MIN_VALUE = 10
 
static float SLIDER_MAX_VALUE = 50
 
static float SLIDER_THUMB_VALUE = (SLIDER_MIN_VALUE + SLIDER_MAX_VALUE) / 2.0f
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_COUNTRY = ""
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_LANGUAGE = ""
 
- Protected Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
 AndroidNonvisibleComponent (Form form)
 
- Protected Attributes inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
final Form form
 

Detailed Description

The TextToSpeech component speaks a given text aloud. You can set the pitch and the rate of speech.

You can also set a language by supplying a language code. This changes the pronunciation of words, not the actual language spoken. For example, setting the Language() to French and speaking English text will sound like someone speaking English (en) with a French accent.

You can also specify a country by supplying a Country() code. This can affect the pronunciation. For example, British English (GBR) will sound different from US English (USA). Not every country code will affect every language.

The languages and countries available depend on the particular device, and can be listed with the AvailableLanguages() and AvailableCountries() properties.

Author
markf.nosp@m.@goo.nosp@m.gle.c.nosp@m.om (Mark Friedman)

Definition at line 71 of file TextToSpeech.java.

Constructor & Destructor Documentation

◆ TextToSpeech()

com.google.appinventor.components.runtime.TextToSpeech.TextToSpeech ( ComponentContainer  container)

Creates a TextToSpeech component.

Parameters
containercontainer, component will be placed in

Definition at line 132 of file TextToSpeech.java.

Member Function Documentation

◆ AfterSpeaking()

void com.google.appinventor.components.runtime.TextToSpeech.AfterSpeaking ( boolean  result)

Event to raise after the message is spoken. The result{:.variable.block} will be true{:.logic.block} if the message is spoken successfully, otherwise it will be false{:.logic.block}.

Parameters
resultwhether the message was successfully spoken

Definition at line 462 of file TextToSpeech.java.

◆ AvailableCountries()

YailList com.google.appinventor.components.runtime.TextToSpeech.AvailableCountries ( )

Definition at line 376 of file TextToSpeech.java.

◆ AvailableLanguages()

YailList com.google.appinventor.components.runtime.TextToSpeech.AvailableLanguages ( )

Definition at line 368 of file TextToSpeech.java.

◆ BeforeSpeaking()

void com.google.appinventor.components.runtime.TextToSpeech.BeforeSpeaking ( )

Event to raise when Speak is invoked, before the message is spoken.

Definition at line 449 of file TextToSpeech.java.

◆ Country() [1/2]

String com.google.appinventor.components.runtime.TextToSpeech.Country ( )

Gets the country for this TextToSpeech component. This will be either an ISO2 (i.e. 2 letter) or ISO3 (i.e. 3 letter) code depending on which kind of code the property was set with.

@suppressdoc

Returns
country code for this TextToSpeech component.

Definition at line 361 of file TextToSpeech.java.

◆ Country() [2/2]

void com.google.appinventor.components.runtime.TextToSpeech.Country ( String  country)

Country code to use for speech generation. This can affect the pronunciation. For example, British English (GBR) will sound different from US English (USA). Not every country code will affect every language.

Parameters
countryis the ISO2 (i.e. 2 letter) or ISO3 (i.e. 3 letter) country code to set this TextToSpeech component to.

Definition at line 325 of file TextToSpeech.java.

◆ Language() [1/2]

String com.google.appinventor.components.runtime.TextToSpeech.Language ( )

Gets the language for this TextToSpeech component. This will be either an ISO2 (i.e. 2 letter) or ISO3 (i.e. 3 letter) code depending on which kind of code the property was set with.

@suppressdoc

Returns
the language code for this TextToSpeech component.

Definition at line 307 of file TextToSpeech.java.

◆ Language() [2/2]

void com.google.appinventor.components.runtime.TextToSpeech.Language ( String  language)

Sets the language for TextToSpeech. This changes the way that words are pronounced, not the actual language that is spoken. For example, setting the language to French and speaking English text will sound like someone speaking English with a French accent.

Parameters
languageis the ISO2 (i.e. 2 letter) or ISO3 (i.e. 3 letter) language code to set this TextToSpeech component to.

Definition at line 194 of file TextToSpeech.java.

◆ onDestroy()

void com.google.appinventor.components.runtime.TextToSpeech.onDestroy ( )

◆ onResume()

void com.google.appinventor.components.runtime.TextToSpeech.onResume ( )

◆ onStop()

void com.google.appinventor.components.runtime.TextToSpeech.onStop ( )

◆ Pitch() [1/2]

float com.google.appinventor.components.runtime.TextToSpeech.Pitch ( )

Reports the current value of speech pitch. @suppressdoc

Definition at line 256 of file TextToSpeech.java.

◆ Pitch() [2/2]

void com.google.appinventor.components.runtime.TextToSpeech.Pitch ( float  pitch)

Sets the speech pitch for the TextToSpeech.

The values should be between 0 and 2 where lower values lower the tone of synthesized voice and greater values raise it.

The default value is 1.0 for normal pitch.

Parameters
pitcha pitch level between 0 and 2

Definition at line 237 of file TextToSpeech.java.

◆ prepareLanguageAndCountryProperties()

void com.google.appinventor.components.runtime.TextToSpeech.prepareLanguageAndCountryProperties ( )

Definition at line 381 of file TextToSpeech.java.

◆ Result()

boolean com.google.appinventor.components.runtime.TextToSpeech.Result ( )

Returns true{:.logic.block} if the text was successfully converted to speech, otherwise false{:.logic.block}.

Definition at line 176 of file TextToSpeech.java.

◆ Speak()

void com.google.appinventor.components.runtime.TextToSpeech.Speak ( final String  message)

Speaks the given message.

Definition at line 438 of file TextToSpeech.java.

◆ SpeechRate() [1/2]

float com.google.appinventor.components.runtime.TextToSpeech.SpeechRate ( )

Reports the current value of speechRate. @suppressdoc

Definition at line 295 of file TextToSpeech.java.

◆ SpeechRate() [2/2]

void com.google.appinventor.components.runtime.TextToSpeech.SpeechRate ( float  speechRate)

Sets the SpeechRate for TextToSpeech.

The values should be between 0 and 2 where lower values slow down the pitch and greater values accelerate it.

The default value is 1.0 for normal speech rate.

Parameters
speechRateSpeech rate 1.0 is the normal speech rate, lower values slow down the speech (0.5 is half the normal speech rate), greater values accelerate it (2.0 is twice the normal speech rate).

Definition at line 276 of file TextToSpeech.java.


The documentation for this class was generated from the following file: