Build an Android text to speech app in under 10 minutes

5 min read

Build an Android text to speech app in under 10 minutes

This post describes how you can add Watson’s cognitive service to an Android app in under 10 minutes. The voice user interface is a great way to enhance the user interface of IoT devices, robots, or a voice-controlled vehicle. IBM Watson Text-To-Speech service is available from the IBM Bluemix catalog.


Note: If you haven’t done so already, please skim my prior post “Connect native Android app to Watson Sentiment Analysis in under 10 minutes” since it covers steps in more detail than in this post.


Overview of steps

Below is an overview of the steps:

  1. Create a typical Android application in Java

  2. Add the Watson lib: Watson-Developer-Cloud SDK for Java

  3. Instantiate the Bluemix Watson service and get the key token to it

  4. Add some code in your Android app to invoke the cognitive service

  5. Quick test of the app.

You’ll build a simple application with a submit button, an editable text field, and an output field. The video below shows the steps:

The results from the emulator:


Run the test to see if the fields work as planned and you see the debug println in the console as well as in the ViewText field.

The entire code for the UI is shown below:

The following video covers the steps for connecting the UI with the Watson Text to Speech service:

Android App Watson TTS part 2/2

Below is the code from the video:

And a quick screenshot of the editor upon completion:

Android App Watson TTS part 2/2

The section of code invoking the Text to Speed service is excerpted below for easy reference:

TextToSpeech textToSpeech = initTextToSpeechService();<br>
           streamPlayer = new StreamPlayer();<br>


That’s it! You are ready to run and hear the voice of IBM Watson!

Sign up for Bluemix. It’s free!

Please follow me on Twitter: @blumareks, and check my blog on


Be the first to hear about news, product updates, and innovation from IBM Cloud