Package org.robolectric.shadows
Class ShadowTextToSpeech
java.lang.Object
org.robolectric.shadows.ShadowTextToSpeech
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void__constructor__(Context context, TextToSpeech.OnInitListener listener, String engine, String packageName, boolean useFallback) static voidaddLanguageAvailability(Locale locale) MakesLocalean available language returned byTextToSpeech.isLanguageAvailable(Locale).static voidMakesVoicean available voice returned byTextToSpeech.getVoices().voidReturnsLocaleset usingTextToSpeech.setLanguage(Locale)or null if not set.ReturnsVoiceset usingTextToSpeech.setVoice(Voice), or null if not set.Returns last fileFilewritten to byTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String).Returns last textCharSequencepassed toTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String).static TextToSpeechReturns the most recently instantiatedTextToSpeechor null if none exist.intcom.google.common.collect.ImmutableList<String>Returns list of all the text spoken byspeak(java.lang.String, int, java.util.HashMap<java.lang.String, java.lang.String>).protected intinitTts()protected intisLanguageAvailable(Locale lang) booleanbooleanstatic voidreset()protected intsetLanguage(Locale locale) protected intprotected voidshutdown()voidsimulateSynthesizeToFileResult(int result) Sets up synthesizeToFile to succeed or fail in the synthesis operation.protected intspeak(CharSequence text, int queueMode, Bundle params, String utteranceId) protected intSpeaks the string using the specified queuing strategy and speech parameters.protected intstop()protected intsynthesizeToFile(CharSequence text, Bundle params, File file, String utteranceId) Storestextand 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) -
simulateSynthesizeToFileResult
public void simulateSynthesizeToFileResult(int result) Sets up synthesizeToFile to succeed or fail in the synthesis operation.This controls calls the relevant callbacks but does not set the return value of synthesizeToFile.
- Parameters:
result- TextToSpeech enum (SUCCESS, ERROR, or one of the ERROR_ codes from TextToSpeech)
-
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) throws IOException Storestextand returnsTextToSpeech.SUCCESS.- Throws:
IOException- See Also:
-
setVoice
-
getVoices
-
getUtteranceProgressListener
-
getContext
-
getOnInitListener
-
getLastSpokenText
-
clearLastSpokenText
public void clearLastSpokenText() -
isShutdown
public boolean isShutdown() -
isStopped
public boolean isStopped()- Returns:
trueif the TTS is stopped.
-
getQueueMode
public int getQueueMode() -
getCurrentLanguage
ReturnsLocaleset usingTextToSpeech.setLanguage(Locale)or null if not set. -
getLastSynthesizeToFileText
Returns last textCharSequencepassed toTextToSpeech.synthesizeToFile(CharSequence, Bundle, File, String). -
getLastSynthesizeToFile
Returns last fileFilewritten to byTextToSpeech.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
MakesLocalean available language returned byTextToSpeech.isLanguageAvailable(Locale). The value returned byisLanguageAvailable(Locale)will vary depending on language, country, and variant. -
addVoice
MakesVoicean available voice returned byTextToSpeech.getVoices(). -
getCurrentVoice
ReturnsVoiceset usingTextToSpeech.setVoice(Voice), or null if not set. -
getLastTextToSpeechInstance
Returns the most recently instantiatedTextToSpeechor null if none exist. -
reset
-