Class TextSpeaker

  • All Implemented Interfaces:
    android.speech.tts.TextToSpeech.OnInitListener, ITextSpeaker, java.lang.AutoCloseable

    public class TextSpeaker
    extends java.lang.Object
    implements ITextSpeaker, java.lang.AutoCloseable, android.speech.tts.TextToSpeech.OnInitListener
    Speaks text
    Since:
    1.21.0
    • Constructor Detail

      • TextSpeaker

        public TextSpeaker​(android.content.Context context)
        Constructor
        Parameters:
        context - Context for the speaker
        Since:
        1.21.0
    • Method Detail

      • setup

        public static void setup​(android.content.Context context)
        Set up an instance of text speaker
        Parameters:
        context - Speaker context
        Since:
        1.21.0
      • destroy

        public static void destroy()
        Destroy an instance of text speaker
        Since:
        1.21.0
      • getInstance

        public static ITextSpeaker getInstance()
        Get a singleton instance of speaker
        Returns:
        Speaker instance
        Since:
        1.21.0
      • speak

        public void speak​(java.lang.String text,
                          java.util.Locale locale,
                          boolean interrupt)
        Speak text
        Specified by:
        speak in interface ITextSpeaker
        Parameters:
        text - Text to be spoken
        locale - Locale of the spoken text
        interrupt - true to interrupt current speech
        Since:
        1.21.0
      • close

        public void close()
        Close the speaker and free its resources
        Specified by:
        close in interface java.lang.AutoCloseable
        Since:
        1.21.0
      • onInit

        public void onInit​(int i)
        Description copied from interface: android.speech.tts.TextToSpeech.OnInitListener
        Called to signal the completion of the TextToSpeech engine initialization.
        Specified by:
        onInit in interface android.speech.tts.TextToSpeech.OnInitListener
        Parameters:
        i - TextToSpeech.SUCCESS or TextToSpeech.ERROR.