1

trying to implement Text-to-Speech in android but this subject has a confusing topic which i hope someone could kindly clear up for me.

So according to this

http://android-developers.blogspot.pt/2009/09/introduction-to-text-to-speech-in.html

All android devices ship with the Google TTS engine but some devices have limited storage and may lack a language specific resource.

And then it talks about an intent which simply checks if a language is available which takes me to this answer

Why is the ACTION_CHECK_TTS_DATA Intent "awkward to use"?

Where the check does not have to be via an intent but a simple if statement just checking if the language is available by calling isLanguageAvailable()

So my problem is:

The Google text to speech engine is on the Play Store and has updates released to it. How would i know if the user needs to update their text to speech engine? And how would i know if its acutally installed because samsung devices have samsung voice by default and not google version.

https://play.google.com/store/apps/details?id=com.google.android.tts&hl=en

And then to throw another spanner we have this article which says

Google has recently updated its Text-to-Speech app on the Play Store to take away features. With the update, you can no longer download the high quality voices on the Text-to-Speech app

And

According to Google, the standard voice engine "now surpass[es] the quality of the high quality voices from our previous release."

http://www.androidcentral.com/google-removes-high-quality-voices-text-speech-update-thats-not-bad-thing

So how would i know if they have Google Text to speech installed and whether its updated because it looks like the updates would offer enhancements to the voice system

Community
  • 1
  • 1
Ersen Osman
  • 7,067
  • 8
  • 47
  • 80
  • Why don't you use the default TTS given by android – Sheychan Aug 17 '15 at 09:44
  • @Sheychan Is there any difference between this one and the one provided by Google via this app? – Ersen Osman Aug 17 '15 at 09:47
  • Hmmm I thought you should be trying to implement the default so you won't be needing to dig in engines in playstore.. Coz it is already a device scope – Sheychan Aug 17 '15 at 09:51
  • @Sheychan , hi i have another question, how i am supposed to call getMaxSpeechInputLength () if the min SDK required is 18 and i am supporting 14? It makes no sense if one the speak calls supports API 4 so devices below 18 have no way to handle the limit? – Ersen Osman Aug 17 '15 at 10:58

1 Answers1

0

The reason why I don't use the default text to speech engine for Android is Android doesn't have support for Mandarin Chinese. This may not be your case, but I find my answer pretty simple to implement and it may be worth trying out. You don't have to make any checks for updates or whatever. This solution is not permanent, because Google may change this unofficial API. Anyways, here it is:

    String url = "http://translate.google.com/translate_tts?ie=utf-8&tl=zh-TW&q=";
    mPlayer = new MediaPlayer();
    mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

    try{

        mPlayer.setDataSource(url);
        mPlayer.prepareAsync();
        Log.i("url", url);

    }catch(Exception e){
        Log.e("mediaPlayer", e.toString());
    }

You will have to change the url to fit your needs. For example, if you want english text to speech, change 'tl=zh-TW' to 'tl=en'. You will also have to fill in something for 'q=' to something like 'q=hello'.

Also this API is blocked by a captcha. To get around it, see this answer Google Translate TTS API blocked.

Also do a

mPlayer.play();

on a button click or something to hear it from the phone.

Community
  • 1
  • 1
ginsengtang
  • 751
  • 1
  • 7
  • 17