shakeelrajput54 / java-google-translate-text-to-speech

Automatically exported from code.google.com/p/java-google-translate-text-to-speech
0 stars 0 forks source link

Server returned HTTP response code: 503 on translating even one word #8

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. First would thank you for this library. Have tested translating few 
properties file into different languages. Using the following code:

Translator translate = Translator.getInstance();
String text = "";
try{
 text = translate.translate(str, Language.ENGLISH, Language.CHINESE_SIMPLIFIED);
}catch (Exception e) {
            String message = e.getMessage();
            System.out.println(message);
             }
2. I was able to use it for one day. And it worked perfectly. Later even for 
one small String translation say like "Hello" it started throwing up following 
error
:
java.io.IOException: Server returned HTTP response code: 503 for URL: 
http://ipv4.google.com/sorry/IndexRedirect?continue=http://translate.google.com.
br/translate_a/t%3Fclient%3Dt%26text%3DHello%26hl%3Den%26sl%3Den%26tl%3Den%26mul
tires%3D1%26prev%3Dbtn%26ssel%3D0%26tsel%3D0%26sc%3D1&q=CGMSBHqsFhAY_L3FqQUiGQDx
p4NLxnAO-gsMAyd56ktUpufqNjEC280

    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1459)
    at com.gtranslate.utils.WebUtils.source(WebUtils.java:24)
    at com.gtranslate.parsing.ParseTextTranslate.parse(ParseTextTranslate.java:19) 

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.
Didnt found any reasons for it. Can someone please explain why is this 
happening. 
Its been 2 weeks since we are not able to translate anything.

Original issue reported on code.google.com by kapil2ka...@gmail.com on 17 Apr 2015 at 7:40

GoogleCodeExporter commented 8 years ago
I am facing the same problem. There is a similar unofficial API in python 
(goslate), and I read that the Google Translate format changed slightly. They 
have updated the code for it to work. Is it possible to do the same workaround 
for this API? Thanks.

Original comment by taninam...@gmail.com on 1 May 2015 at 4:43

GoogleCodeExporter commented 8 years ago
Thanks for your help in stating python API as an alternative. But yes would had 
been better if this existing API could be resolved.

Original comment by kapil2ka...@gmail.com on 1 May 2015 at 4:24

GoogleCodeExporter commented 8 years ago
:D faced the same issue. Now that is a major issue.

Original comment by shashaan...@gmail.com on 2 May 2015 at 5:50

GoogleCodeExporter commented 8 years ago
Ok found a solution, sharing with other.
There is a very minor fix required.

STEP1)
In class com.gtranslate.URLCONSTANT
change public static final String GOOGLE_TRANSLATE_TEXT = 
"http://translate.google.com.br/translate_a/t?";

TO 
        public static final String GOOGLE_TRANSLATE_TEXT1 = "http://translate.google.com.br/translate_a/single?";

STEP2) In the class,
the appendURL function needs to be changed as shown
com.gtranslate.parsing.ParseTextTranslate
@Override
    public void appendURL() {
        Text input = textTranslate.getInput();
        Text output = textTranslate.getOutput();
        url = new StringBuilder(URLCONSTANTS.GOOGLE_TRANSLATE_TEXT);
        /* url.append("client=t&text=" + input.getText().replace(" ", "%20"));
        url.append("&hl=" + input.getLanguage());
        url.append("&sl=" + input.getLanguage());
        url.append("&tl=" + output.getLanguage());
        url.append("&multires=1&prev=btn&ssel=0&tsel=0&sc=1");  */

                url = new StringBuilder(URLCONSTANTS.GOOGLE_TRANSLATE_TEXT); 

        url.append("client=t&sl=auto&tl="+ output.getLanguage()
                        +"&hl=" + input.getLanguage()
                        +"&dt=bd&dt=ex&dt=ld&dt=md&dt=qc&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=1&rom=1&ssel=0&tsel=3&kc=1&tk=620730|996163"
                        + "&q=" + input.getText().replace(" ", "%20"));

    }

Original comment by shashaan...@gmail.com on 3 May 2015 at 10:23

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
How can we edit that code? Its not allowing me editing that file.

Original comment by AnmolYou...@gmail.com on 3 May 2015 at 3:06

GoogleCodeExporter commented 8 years ago
You may find the source code here in the below link create a jar file with 
given changes :

http://java-google-translate-text-to-speech.googlecode.com/svn/

Original comment by kapil2ka...@gmail.com on 3 May 2015 at 7:09

GoogleCodeExporter commented 8 years ago
Superb :) it works. I have created a jar file with those changes, attached with 
below. 

Would be great if you can share the idea how did you come to know the fix and 
some details about the fix will be greatly appreciated. 

Original comment by kapil2ka...@gmail.com on 3 May 2015 at 7:19

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks a lot. It worked. :)

Original comment by AnmolYou...@gmail.com on 3 May 2015 at 7:25

GoogleCodeExporter commented 8 years ago
Thanks a lot :).. it worked.. 

Original comment by iamthego...@gmail.com on 14 May 2015 at 9:30

GoogleCodeExporter commented 8 years ago
Would be great if the fix could be explained. :)

Original comment by kapil2ka...@gmail.com on 14 May 2015 at 10:24

GoogleCodeExporter commented 8 years ago
Shashaan, thank you very match!It worked!

Original comment by stan82s...@mail.ru on 30 May 2015 at 1:09

GoogleCodeExporter commented 8 years ago
Just add "&client=" at the end of your string. 

Original comment by ivanblan...@gmail.com on 6 Aug 2015 at 11:10

GoogleCodeExporter commented 8 years ago
i cant resolve it, please help me

Original comment by xXmAstEr...@gmail.com on 13 Aug 2015 at 2:00

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Please provide updated jar file for thise

Original comment by aanil2...@gmail.com on 23 Aug 2015 at 5:55