7

I'm developing an app for android that uses TTS. I've created a splash screen where I check if the TTS engine is installed and in case that is not installed, it goes to Google Play to download it.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
...
    Intent checkIntent = new Intent();
    checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
    startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
...
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
...
    if (requestCode == PersonalTextToSpeech.MY_DATA_CHECK_CODE)
    {
        if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS)
        {
            mTts = new TextToSpeech(context, this);
        } else
        {
            Intent installIntent = new Intent();
            installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            context.startActivity(installIntent);
        }
    }
}

It was working fine in Samsung devices with 2.2 and 2.3.x OS. It goes to Google Play if needed, but now I've tried with a Samsung Galaxy S3 (with 4.1.1), which has 2 TTS installed by default (Samsung and Google), so I get a dialog asking to select one.

Select TTS

If the user selects Samsung it works perfect, but if the user selects Google, it goes to Settings --> Language and input --> Text-to-speech output --> Google Text-to-speech Engine --> Settings --> Install Voice Data and I get this: TTS Languages installed

So, I have 3 questions/problems:

  1. Is there any way to force programatically to use Samsung TTS without asking?

  2. My device is from Spain, but if I change the language to English, this one is not available in my Google list of TTS languages, and I can't find a way to add it (see screenshot #2).

  3. If I change the language to spanish, this language is supposed to be installed in my device (see screenshot #2), but for some reason TTS resultCode is LANG_NOT_SUPPORTED (-2).

In fact, right now while I write this, I've just found something weird.

If you select Samsung TTS, it will "work" (resultCode = CHECK_VOICE_DATA_PASS (1)), but the "voice sound" will change depending on how you have your setting (view Screenshot #3): TTS Settings

If you choose Samsung, it will use Samsung TTS or Google TTS according to what you have selected in: Settings --> Language and input --> Text-to-speech output.

So, even if you select Samsung TTS, you could be using Google TTS, but if you select Google TTS directly (see Screenshot #1) it will fail.

Can someone explain me what I'm doing wrong?

Thanks for your help.

icedwater
  • 4,701
  • 3
  • 35
  • 50
user897013
  • 165
  • 1
  • 3
  • 9
  • BTW, when I select the TTS Engine (see screenshot#1), I click on "Just once". I don't know if this makes any difference on the TTS behavior. – user897013 Nov 10 '12 at 13:31
  • Sorry don't have the answer. I'm an s3 user. Thought you would be interested to know that I've noticed similar problems with several other apps that use tts. I came across your article looking for a solution. You change the tts (I'm using ivona tts) in the settings menu it directs to as per your description but apps such as SVoice use Samsung tts. Looks like you are not the only developer scratching your head on this one. I haven't found a solution yet, which suggests its not user error. –  Nov 11 '12 at 16:09
  • Thanks @Mik for your comment. Is good to know that I'm not the only one with this issue. Let's wait for somebody else to answer. – user897013 Nov 12 '12 at 09:25
  • 1
    Samsung seems to do weird things. Checking why TTS only partially worked in our app, we found out that with Samsung TTS selected and the needed language pack not installed, it retrieves the audio via some online TTS service. That one sounds good, but isn't of course reliable bcs dependent on the Internet connection. In that case TextToSpeech.LANG_MISSING_DATA is returned when initialiting the TTS service. – didi_X8 May 01 '13 at 19:12
  • Do you have found any solution? – Victor Nov 06 '13 at 11:50

1 Answers1

-1

i too stucked in this problem and i solved it by just replacing a code in my onActivityResult. Instead of checking for TTS Data,i just checked for available voices.

             if (availableLanguages.isEmpty()) {
                // no language data available, prompt for install
                Intent installIntent = new Intent();
                installIntent
                        .setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                startActivity(installIntent);
            } else {
                // some language data is available, create TTS instance
                myTTS = new TextToSpeech(this, this);
            }
Narayan Soni
  • 114
  • 8
  • Hi @narayan-soni. Thank you for your answer (and sorry for my delay answering). When you say availableLanguages.isEmpty() are you talking about isLanguageAvailable (Locale loc)? I can't find the method availableLanguages.isEmpty() – user897013 Sep 21 '13 at 22:05