Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text to Speech not working in Android 4.2 Jelly Bean

Tags:

android

We added voice prompts to our app using the Text to Speech API a couple years ago and it has been working well. Recently, we started receiving email from users that upgraded to Android 4.2 Jelly Bean saying that voice prompts are not working and that they are getting a message that the voice data is missing and they need to download it. When they click to download they are given the option of downloading languages other than English.

We implemented text to speech following this post on the Android Developer's Blog. We are invoking the TextToSpeech.Engine.ACTION_CHECK_TTS_DATA intent and if anything other than TextToSpeech.Engine.CHECK_VOICE_DATA_PASS is returned we invoke the TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA intent.

We don't have access to a device running 4.2. I went into a local store today and downloaded the app on a Nexus 7 tablet with 4.2 installed and was able to reproduce the problem. However, when we create an AVD based on the Nexus 7 and run the emulator the voice prompts work fine and we are not able to reproduce the issue.

like image 533
Bryan Bedard Avatar asked Nov 26 '12 03:11

Bryan Bedard


1 Answers

TTS checking with Android OS4.1 and OS 4.2 is, being polite, different.

OS 4.1 does not correctly handle the intent to install data*

TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA

OS 4.2 does not correctly handle the intent to check for voice data*

TextToSpeech.Engine.ACTION_CHECK_TTS_DATA

* By this I mean that it doesn't return the correct status codes as per the old versions. For example, CHECK_TTS_DATA returns CHECK_VOICE_DATA_MISSING_DATA when it clearly does have voice data installed. It's possible that there is some other intent data that now needs to be passed, but I'm not sure where this is documented.

In my apps I have had to disable these checks for newer OS versions. I suspect Google may have done this because their terms to use Android now mandate TTS (but I can't verify this - I'm sure there's a site out there that describes exactly what must be implemented to be called 'Android')

Update

As I suspected, Android OS 4.1 now mandates Text-to-Speech be included in every Android device, thus the checks are now somewhat redundant. From this link: Android 4.1 Compatibility Definition

3.11 Text-to-Speech
Android 4.1 includes APIs that allow applications to make use of text-to-speech (TTS) services, and allows service providers to provide implementations of TTS services [Resources, 32]. Device implementations MUST meet these requirements related to the Android TTS framework:

  • Device implementations MUST support the Android TTS framework APIs and SHOULD include a TTS engine supporting the languages available on the device. Note that the upstream Android open source software includes a full-featured TTS engine implementation.
  • Device implementations MUST support installation of third-party TTS engines.
  • Device implementations MUST provide a user-accessible interface that allows users to select a TTS engine for use at the system level.
like image 75
SoftWyer Avatar answered Oct 05 '22 15:10

SoftWyer