Android TextToSpeech Tutorial
In android, you can convert your text into speech by the help of TextToSpeech class. After completion of the conversion, you can playback or create the sound file.
Constructor of TextToSpeech class
Methods of TextToSpeech class
The commonly used methods of TextToSpeech class are as follows:
You need to implement TextToSpeech.OnInitListener interface, for performing event handling on TextToSpeech engine.
Method of TextToSpeech.OnInitListener Interface
There is only one method in this interface.
Android TextToSpeech Example
Let's write the code to convert text into voice.
Drag one textview, one edittext and one button for the layout. Now the activity_main.xml file will look like this:
Let's see the code to speak the given text.
You need to run it on the Real Device (e.g. Mobile) to test the application.
Next: TextToSpeech example with speed and pitch optionTextToSpeech example with speed and pitch option