Using Android Text to Speech

To help some of the health workers use the mobile learning application – especially those who may have trouble reading English, we thought it may be useful to give them the facility to have the page content read out using text-to-speech. This has been quite easy to get set up and running (basic instructions), but a couple of things I found may help others trying to get text-to-speech up and running in their apps:

  • I found the onActivityResult method was not being called, but this was due to my variable “MY_DATA_CHECK_CODE” not being set to 0 – once it was set to 0 it worked fine. Also if I used the built in “RESULT_OK” this didn’t work either. See here for more explanation.
  • I wanted to read out the HTML from a webview widget and I thought I’d need to write a load of code to strip out the html headers, tags etc (otherwise the names of the tags and attribute get read out too). But actually it was really simple, using the line: “android.text.Html.fromHtml(instruction).toString()” (more)

It all seems to work quite well, although with the built in voices I find it certainly sounds computer generated, and if I set the speed of the voice to very slow it sounds drunk. So I’m a little unsure if it’s really going to help the health workers, but it’s not taken me much time to set up and maybe it could be useful for some of them.

Leave a Reply