Android Text to Speech Tutorial

Android allows you convert your text into voice. Therefore, Android providing a feature/class to translate text to speech called (TTS) which can speak the text in different languages. The user can also adjust the speech speed and pitch during the time of generating the text to voice. TTS is good for education purpose in general so that it will provide the user the proper pronunciation of the language. The user can select which language they want to translate such as English, Chinese, Tamil and more. In this tutorial, I will tell you how to implement android text to speech feature in your project.

Creating a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “SpeechExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Activity” and Click Next button
5. Lastly, press finish button.

Edit activity_main.xml layout

Go to the mainactivity layout and add two seekbar to adjust the pitch and speed of the voice generated by the text. You can follow the sample at the bottom.

Edit MainActivity.java class

After modifying the layout, go to this class and performs the text to speech feature when the user clicks the speech image button. Copy and paste the sample below in your MainActivity class.

Run Your Project

Lastly, you can now run this project in your real device to test out this feature is working anot. Please make sure you volumn up your mobile device.

(Android Text to Speech)

Source Code

(Visited 275 times, 1 visits today)
Advertisements

Kristofer Ng

A crazy android and web developer. Passion on developing android application and exploring new technology as a hobby.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

GET YOUR EBOOK FOR FREE

Unlock free ebook "Beginning Programming ALL-IN-ONE Desk Reference for DUMMIES" now!

We will send a copy to your email