Learn to develop an application that converts text into speech in android


In this tutorial we will learn how to convert text into speech using Android programming.
Here we are going to develop an application whose layout consists an EditText which will accept the text as input and Image button which will perform some event on the click i.e. whenever you provide the text as input and press on the image button, it will convert the text into speech.

  • To convert text into speech follow the steps given below :

  1. First of all download the ADT- Bundle from developer.android.com and extract it .
  2. For downloading and installation of eclipse you can follow the following link Installing Android SDK
  3. Now open up eclipse and click on File -> create new Android Application Projects

  4. Provide a project name for example ” TextSpeech ” and set the Minimum Required and Target SDK for the project as ” 19 “.
  5. Click on Next and select Blank from the appeared dialog box
  6. Now Click on Next and it will show you the dialog box which contains your java file i.e MainActivity and xml layout name : activity_main
  7. Click on Finish and your MainActivity.java and activity_main.xml files will be generated.
  8. Now just move to activity_main.xml file i.e in its Graphical Layout and drag and drop TextView on the layout as shown in the image and for example set the text as Text To Speech

  9. Similarly drag an Plain text i.e an EditText and Image button .
  10. Hence, your layout will look like as shown below :

  11. Now go to the activity_main.xml file the tab besides the graphical layout and change the id’s of the EditText, TextView, ImageButton, etc for simplicity of understanding.
  12. Hence the complete code for your activity_main.xml file is given below :
  13. Here is the ImageView of the above code :

  14. text

  15. Now just move to MainActivity.java file and extend your class with Activity implements TextToSpeech.OnInitListener
  16. Hence, the complete code is given below which is self explanatory :
  17. Here is the image view of the above code :

  18. convert text to speech


    speech application

  19. Now run your project and you will get your application running on the emulator as shown below :

  20. Just type some text in the given EditText and click on the ImageButton i.e. image of a Boy in this example.

  21. Click on the image button and it will transform your text into speech.

Hence, we have successfully learnt to develop an application that converts text into speech in android.



Please enter your comment!
Please enter your name here