Package org.robolectric.shadows
Class ShadowTextToSpeech
java.lang.Object
org.robolectric.shadows.ShadowTextToSpeech
@Implements(android.speech.tts.TextToSpeech.class) public class ShadowTextToSpeech extends Object
-
Constructor Summary
Constructors Constructor Description ShadowTextToSpeech()
-
Method Summary
Modifier and Type Method Description protected void
__constructor__(Context context, TextToSpeech.OnInitListener listener, String engine, String packageName, boolean useFallback)
static void
addLanguageAvailability(Locale locale)
MakesLocale
an available language returned byTextToSpeech.isLanguageAvailable(Locale)
.static void
addVoice(Voice voice)
MakesVoice
an available voice returned byTextToSpeech.getVoices()
.void
clearLastSpokenText()
Context
getContext()
Locale
getCurrentLanguage()
ReturnsLocale
set usingTextToSpeech.setLanguage(Locale)
or null if not set.Voice
getCurrentVoice()
ReturnsVoice
set usingTextToSpeech.setVoice(Voice)
, or null if not set.String
getLastSpokenText()
String
getLastSynthesizeToFileText()
Returns last textCharSequence
passed toTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String)
.static TextToSpeech
getLastTextToSpeechInstance()
Returns the most recently instantiatedTextToSpeech
or null if none exist.TextToSpeech.OnInitListener
getOnInitListener()
int
getQueueMode()
com.google.common.collect.ImmutableList<String>
getSpokenTextList()
Returns list of all the text spoken byspeak(java.lang.String, int, java.util.HashMap<java.lang.String, java.lang.String>)
.UtteranceProgressListener
getUtteranceProgressListener()
protected Set<Voice>
getVoices()
protected int
initTts()
protected int
isLanguageAvailable(Locale lang)
boolean
isShutdown()
boolean
isStopped()
static void
reset()
protected int
setLanguage(Locale locale)
protected int
setVoice(Voice voice)
protected void
shutdown()
protected int
speak(CharSequence text, int queueMode, Bundle params, String utteranceId)
protected int
speak(String text, int queueMode, HashMap<String,String> params)
Speaks the string using the specified queuing strategy and speech parameters.protected int
stop()
protected int
synthesizeToFile(CharSequence text, Bundle params, File file, String utteranceId)
Storestext
and returnsTextToSpeech.SUCCESS
.
-
Constructor Details
-
ShadowTextToSpeech
public ShadowTextToSpeech()
-
-
Method Details
-
__constructor__
@Implementation protected void __constructor__(Context context, TextToSpeech.OnInitListener listener, String engine, String packageName, boolean useFallback) -
initTts
-
speak
Speaks the string using the specified queuing strategy and speech parameters.- Parameters:
params
- The real implementation converts the hashmap into a bundle, but the bundle argument is not used in the shadow implementation.
-
speak
@Implementation(minSdk=21) protected int speak(CharSequence text, int queueMode, Bundle params, String utteranceId) -
shutdown
-
stop
-
isLanguageAvailable
-
setLanguage
-
synthesizeToFile
@Implementation(minSdk=21) protected int synthesizeToFile(CharSequence text, Bundle params, File file, String utteranceId)Storestext
and returnsTextToSpeech.SUCCESS
.- See Also:
getLastSynthesizeToFileText()
-
setVoice
-
getVoices
-
getUtteranceProgressListener
-
getContext
-
getOnInitListener
-
getLastSpokenText
-
clearLastSpokenText
public void clearLastSpokenText() -
isShutdown
public boolean isShutdown() -
isStopped
public boolean isStopped()- Returns:
true
if the TTS is stopped.
-
getQueueMode
public int getQueueMode() -
getCurrentLanguage
ReturnsLocale
set usingTextToSpeech.setLanguage(Locale)
or null if not set. -
getLastSynthesizeToFileText
Returns last textCharSequence
passed toTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String)
. -
getSpokenTextList
Returns list of all the text spoken byspeak(java.lang.String, int, java.util.HashMap<java.lang.String, java.lang.String>)
. -
addLanguageAvailability
MakesLocale
an available language returned byTextToSpeech.isLanguageAvailable(Locale)
. The value returned byisLanguageAvailable(Locale)
will vary depending on language, country, and variant. -
addVoice
MakesVoice
an available voice returned byTextToSpeech.getVoices()
. -
getCurrentVoice
ReturnsVoice
set usingTextToSpeech.setVoice(Voice)
, or null if not set. -
getLastTextToSpeechInstance
Returns the most recently instantiatedTextToSpeech
or null if none exist. -
reset
-