Search code examples
androidtext-to-speechspeech-synthesis

How can I convert a text to speech?


I want my app to read out the message contained in the push notification. I already searched the internet but I was not able to find some code which was working.

I expect that the text is translated to speech and automatically played.


Solution

  • If you need an easy approach, you can use SpeakerBox Library. It's very easy to use.

    Just create a new instance

    Speakerbox speakerbox = new Speakerbox(activity);

    Now you are all set. If you want to make a speech from the text "Hello World"

    Just do this - Speakerbox speakerbox = new Speakerbox(activity); speakerbox.play("Hello World"); You will find more details from the mentioned link

    The gradle dependency for this library is -

    implementation 'com.mapzen.android:speakerbox:1.4.1'