1

This is my text to speech service part where I fetch my data and this was working fine and now I am getting this error "java.io.FileNotFoundException: http://ipv4.google.com/sorry/IndexRedirect?continue=http://translate.google.com/translate_tts%3Ftl%3Den-AU%26q%3Dhello%2Bhow%2Bare%2Byou%2Btoday%2B&q=CGMSBMpY7fgYhL_crQUiGQDxp4NL6gmQZhZKyI3fztC8pj7G18P2vhg" When I open the same on browser I am getting this and if I am writing the characters I am getting the required data.Is this a common issue or google has changed something please help enter image description here

                                // data
    {

        // Log.e("JUSTLOGGINGURL", text);
        text = URLEncoder.encode(text, "UTF-8");
        String voiceUrl = "http://translate.google.com/translate_tts?tl="
                + lang_to + "&q=" + text;
        // Log.e("JUSTLOGGINGURL", voiceUrl);

        HttpURLConnection con = null;
        InputStream is = null;
        try {

            URL url = new URL(voiceUrl);
            con = (HttpURLConnection) url.openConnection();
            con.setRequestProperty(
                    "User-Agent",
                    "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");
//          con.setRequestProperty(
//                  "User-Agent",
//                  "Mozilla/5.0 (Linux; Android 4.0.0; Nexus 7 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36");
            con.setRequestMethod("GET");
            con.setDoInput(true);
            con.connect();
            is = con.getInputStream();

        } catch (IOException e) {
            e.printStackTrace();
            is = null;
            return is;

        }
        return is;
Sunil Sunny
  • 3,949
  • 4
  • 23
  • 53

1 Answers1

4

You are clever ;)

But you have to remember, when you use link from page source, it will change. Google just block you because you are making to much request or something like this.

You have 3 solutions:

  1. Use Google Translate API and pay - Here you have Pricing.

  2. Use Another API which is FREE for Commercial use - Here you have some free API. But if you want more, you have to look around in Google.

  3. Use Build in TTS service which is in Android (TextToSpeech) - You have to know that it is little buggy.

Eliasz Kubala
  • 3,836
  • 1
  • 23
  • 28
  • 1
    @EliazKubala if I am paying for translate API what will be the change in URL ?Is there a key for it, if yes where to append it in the url? – Sunil Sunny Jul 28 '15 at 07:15
  • Yes. It will be key there. I think it's work with public and secret key. Please accept my answer if I help you. Look here for more info https://console.developers.google.com/project – Eliasz Kubala Jul 28 '15 at 07:23
  • I will accept the answer,If I am not getting any other solutions +1 for your Time :) – Sunil Sunny Jul 28 '15 at 09:01
  • Look, it can be helpful. But you have to make your own service on server. You have to known it's workaround, so it can stop working. There is TTS from Google Translate. https://github.com/soimort/translate-shell – Eliasz Kubala Jul 28 '15 at 09:29
  • Thanks man Found an another work around but I will accept your answer .May be useful for someone else. – Sunil Sunny Jul 28 '15 at 10:25
  • Hi @sunilsunny, please, can you post your workaround here as a answer and select it as well? – asafadd Jul 29 '15 at 04:55
  • @asafadd sorry dude it's a hack I cannot post it here. :P – Sunil Sunny Jul 29 '15 at 05:06
  • @EliaszKubala can you confirm that Google Translate API can actually do TTS? Because I had a look and there's no TTS mentioned in the API docs. Thanks. – Alveoli Jul 29 '15 at 15:09
  • @Ajay http://stackoverflow.com/questions/32053442/google-translate-tts-api-blocked see this question – Sunil Sunny Dec 02 '15 at 06:24