AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.util.InternalTextToSpeech Class Reference
Inheritance diagram for com.google.appinventor.components.runtime.util.InternalTextToSpeech:
com.google.appinventor.components.runtime.util.ITextToSpeech

Public Member Functions

 InternalTextToSpeech (Activity activity, TextToSpeechCallback callback)
 
void speak (final String message, final Locale loc)
 
boolean isInitialized ()
 
void onStop ()
 
void onDestroy ()
 
void onResume ()
 
void setPitch (float pitch)
 
void setSpeechRate (float speechRate)
 
int isLanguageAvailable (Locale loc)
 

Detailed Description

Wrapper class for Android's android.speech.tts.TextToSpeech class, which doesn't exist on pre-1.6 devices.

We need to wrap this because the Dalvik class loader will fail to verify a class that contains references to non-existence classes and therefore we arrange for the failure to occur in this class, rather than the component class which references this. The component class can figure out whether it wants to use this wrapper class or not depending on the SDK level.

See http://android-developers.blogspot.com/2009/04/backward-compatibility-for-android.html for some more about this.

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

Definition at line 34 of file InternalTextToSpeech.java.

Constructor & Destructor Documentation

◆ InternalTextToSpeech()

com.google.appinventor.components.runtime.util.InternalTextToSpeech.InternalTextToSpeech ( Activity  activity,
TextToSpeechCallback  callback 
)

Definition at line 55 of file InternalTextToSpeech.java.

Member Function Documentation

◆ isInitialized()

boolean com.google.appinventor.components.runtime.util.InternalTextToSpeech.isInitialized ( )

◆ isLanguageAvailable()

int com.google.appinventor.components.runtime.util.InternalTextToSpeech.isLanguageAvailable ( Locale  loc)

◆ onDestroy()

void com.google.appinventor.components.runtime.util.InternalTextToSpeech.onDestroy ( )

This will be called when the Activity is destroyed, to give us a chance to cleanup resources, if necessary.

Implements com.google.appinventor.components.runtime.util.ITextToSpeech.

Definition at line 137 of file InternalTextToSpeech.java.

◆ onResume()

void com.google.appinventor.components.runtime.util.InternalTextToSpeech.onResume ( )

This will be called when the Activity is resumed, to give us a chance to re-initialize resources, if necessary.

Implements com.google.appinventor.components.runtime.util.ITextToSpeech.

Definition at line 147 of file InternalTextToSpeech.java.

◆ onStop()

void com.google.appinventor.components.runtime.util.InternalTextToSpeech.onStop ( )

This will be called when the Activity is stopped, to give us a chance to cleanup resources, if necessary.

Implements com.google.appinventor.components.runtime.util.ITextToSpeech.

Definition at line 131 of file InternalTextToSpeech.java.

◆ setPitch()

void com.google.appinventor.components.runtime.util.InternalTextToSpeech.setPitch ( float  pitch)

Sets the speech pitch for the TextToSpeech

Parameters
pitch1.0 is the normal pitch, lower values lower the tone of the synthesized voice, greater values increase it.

Implements com.google.appinventor.components.runtime.util.ITextToSpeech.

Definition at line 153 of file InternalTextToSpeech.java.

◆ setSpeechRate()

void com.google.appinventor.components.runtime.util.InternalTextToSpeech.setSpeechRate ( float  speechRate)

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

Implements com.google.appinventor.components.runtime.util.ITextToSpeech.

Definition at line 158 of file InternalTextToSpeech.java.

◆ speak()

void com.google.appinventor.components.runtime.util.InternalTextToSpeech.speak ( final String  message,
final Locale  loc 
)

Speaks the given message corresponding to the language and country of the given locale.

Parameters
messagethe message to speak
locthe locale to use

Implements com.google.appinventor.components.runtime.util.ITextToSpeech.

Definition at line 76 of file InternalTextToSpeech.java.


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