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
All Methods Static Methods Instance Methods Concrete Methods 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
.
-
-
-
Method Detail
-
__constructor__
@Implementation protected void __constructor__(Context context, TextToSpeech.OnInitListener listener, String engine, String packageName, boolean useFallback)
-
initTts
@Implementation protected int initTts()
-
speak
@Implementation protected int speak(String text, int queueMode, HashMap<String,String> params)
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
@Implementation protected void shutdown()
-
stop
@Implementation protected int stop()
-
isLanguageAvailable
@Implementation protected int isLanguageAvailable(Locale lang)
-
setLanguage
@Implementation protected int setLanguage(Locale locale)
-
synthesizeToFile
@Implementation(minSdk=21) protected int synthesizeToFile(CharSequence text, Bundle params, File file, String utteranceId)
Storestext
and returnsTextToSpeech.SUCCESS
.- See Also:
getLastSynthesizeToFileText()
-
setVoice
@Implementation(minSdk=21) protected int setVoice(Voice voice)
-
getVoices
@Implementation(minSdk=21) protected Set<Voice> getVoices()
-
getUtteranceProgressListener
public UtteranceProgressListener getUtteranceProgressListener()
-
getContext
public Context getContext()
-
getOnInitListener
public TextToSpeech.OnInitListener getOnInitListener()
-
getLastSpokenText
public String 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
public Locale getCurrentLanguage()
ReturnsLocale
set usingTextToSpeech.setLanguage(Locale)
or null if not set.
-
getLastSynthesizeToFileText
public String getLastSynthesizeToFileText()
Returns last textCharSequence
passed toTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String)
.
-
getSpokenTextList
public 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>)
.
-
addLanguageAvailability
public static void addLanguageAvailability(Locale locale)
MakesLocale
an available language returned byTextToSpeech.isLanguageAvailable(Locale)
. The value returned byisLanguageAvailable(Locale)
will vary depending on language, country, and variant.
-
addVoice
public static void addVoice(Voice voice)
MakesVoice
an available voice returned byTextToSpeech.getVoices()
.
-
getCurrentVoice
public Voice getCurrentVoice()
ReturnsVoice
set usingTextToSpeech.setVoice(Voice)
, or null if not set.
-
getLastTextToSpeechInstance
public static TextToSpeech getLastTextToSpeechInstance()
Returns the most recently instantiatedTextToSpeech
or null if none exist.
-
reset
@Resetter public static void reset()
-
-