Class ShadowTextToSpeech

java.lang.Object
org.robolectric.shadows.ShadowTextToSpeech

@Implements(android.speech.tts.TextToSpeech.class) public class ShadowTextToSpeech extends Object
  • 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

      @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 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)
      Sets the text-to-speech language.

      This method sets the current voice to the default one for the given Locale; getVoice() can be used to retrieve it.

    • synthesizeToFile

      @Implementation protected int synthesizeToFile(CharSequence text, Bundle params, File file, String utteranceId) throws IOException
      Stores text and returns TextToSpeech.SUCCESS.
      Throws:
      IOException
      See Also:
    • setVoice

      @Implementation protected int setVoice(Voice voice)
    • getVoice

      @Implementation protected Voice getVoice()
      Returns the Voice instance describing the voice currently being used for synthesis requests.
    • getVoices

      @Implementation 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()
      Returns Locale set using TextToSpeech.setLanguage(Locale) or null if not set.
    • getLastSynthesizeToFileText

      public String getLastSynthesizeToFileText()
    • getLastSynthesizeToFile

      public File getLastSynthesizeToFile()
    • getSpokenTextList

      public com.google.common.collect.ImmutableList<String> getSpokenTextList()
    • addLanguageAvailability

      public static void addLanguageAvailability(Locale locale)
      Makes Locale an available language returned by TextToSpeech.isLanguageAvailable(Locale). The value returned by isLanguageAvailable(Locale) will vary depending on language, country, and variant.
    • addVoice

      public static void addVoice(Voice voice)
      Makes Voice an available voice returned by TextToSpeech.getVoices().
    • getCurrentVoice

      public Voice getCurrentVoice()
      Returns Voice set using TextToSpeech.setVoice(Voice), or null if not set.
    • getLastTextToSpeechInstance

      public static TextToSpeech getLastTextToSpeechInstance()
      Returns the most recently instantiated TextToSpeech or null if none exist.
    • reset

      @Resetter public static void reset()