EclipseMars中的java文本到语音程序无法使用google translator

EclipseMars中的java文本到语音程序无法使用google translator,java,eclipse,youtube,Java,Eclipse,Youtube,我是一名java初学者,在下面的链接中,我学习了有关java文本到语音的视频教程: 在这里,我在编译这个程序时遇到了eclipse mars的一个问题。它说: 这是我的密码: import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net

我是一名java初学者,在下面的链接中,我学习了有关java文本到语音的视频教程:

在这里,我在编译这个程序时遇到了eclipse mars的一个问题。它说:

这是我的密码:

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.text.MessageFormat;

import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
import us.monoid.web.BinaryResource;
import us.monoid.web.Resty;

//here,we loaded the javaLayer and resty lib files to this project

public class TextToSpeech
{   
    //base url from google translator to get the sound,
    //tts-text to speech ,q-translating text,tl-translating language
    private static final String Base_URL="http://translate.google.com/translate_tts?ie=UTF-8&q={0}&tl={1}&prev=input";


    public static void main(String[] args) 
    {
        speech("hello kalanka");
    }
    public static void speech(String text)
    {

        try 
        {
            File file=new File("temp.mp3");//temp file to save the sound from google

            String sentence= URLEncoder.encode(text,"UTF-8");//encoding the text we send as utf-8

            String urlString=MessageFormat.format(Base_URL,sentence,"en");// filling the baseUrl with arguments 
            //"en" means the English language

            BinaryResource res=new Resty().bytes(new URI(urlString));//creating a rest object for the binary resources to get the mp3 file 
            //which will receive from google

            res.save(file);//saving the binary res file in file that we created

            FileInputStream in=new FileInputStream(file);

            Player pp=new Player(in);//creating the Player object

            pp.play();//playing the file 
            pp.close();//closing the play
            file.delete();//deleting the file

        } 
        catch (UnsupportedEncodingException e) 
        {
            e.printStackTrace();
        } 
        catch (IOException e)
        {
            e.printStackTrace();
        } 
        catch (URISyntaxException e)
        {
            e.printStackTrace();
        } catch (JavaLayerException e)
        {
            e.printStackTrace();
        }


    }

}
以下是完整的错误:

    java.io.IOException: Error while reading from GET: [503] Service Unavailable
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="initial-scale=1"><title>http://translate.google.com/translate_tts?ie=UTF-8&amp;q=hello+kalanka&amp;tl=en&amp;prev=input</title></head>
<body style="font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px;" onload="e=document.getElementById('captcha');if(e){e.focus();}">
<div style="max-width:400px;">
 <hr noshade size="1" style="color:#ccc; background-color:#ccc;"><br>

  To continue, please type the characters below:<br><br>
  <img src="/sorry/image?id=15657022896595218819&amp;q=CGMSBGf3MFUY-PWSuQUiGQDxp4NLgYkSgFOxxcQGJWJm5jZQLxCJi6c&amp;hl=en&amp;continue=http://translate.google.com/translate_tts%3Fie%3DUTF-8%26q%3Dhello%2Bkalanka%26tl%3Den%26prev%3Dinput" border="1" alt="Please enable images"><br><br><form action="CaptchaRedirect" method="get"><input type='hidden' name='q' value='CGMSBGf3MFUY-PWSuQUiGQDxp4NLgYkSgFOxxcQGJWJm5jZQLxCJi6c'><input type="hidden" name="continue" value="http://translate.google.com/translate_tts?ie=UTF-8&amp;q=hello+kalanka&amp;tl=en&amp;prev=input"><input type="hidden" name="id" value="15657022896595218819"><input type="text" name="captcha" value="" id="captcha" size="12" style="font-size:16px; padding:3px 0 3px 5px; margin-left:0px;"><input type="submit" name="submit" value="Submit" style="font-size:18px; padding:4px 0;"><br><br><br></form>
  <hr noshade size="1" style="color:#ccc; background-color:#ccc;">

   <div style="font-size:13px;">
    <b>About this page</b><br><br>Our systems have detected unusual traffic from your computer network.  This page checks to see if it&#39;s really you sending the requests, and not a robot.  <a href="#" onclick="document.getElementById('infoDiv').style.display='block';">Why did this happen?</a><br><br>
    <div id="infoDiv" style="display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;">
     This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the <a href="//www.google.com/policies/terms/">Terms of Service</a>. The block will expire shortly after those requests stop.  In the meantime, solving the above CAPTCHA will let you continue to use our services.<br><br>This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests.  If you share your network connection, ask your administrator for help &mdash; a different computer using the same IP address may be responsible.  <a href="//support.google.com/websearch/answer/86640">Learn more</a><br><br>Sometimes you may be asked to solve the CAPTCHA if you are using advanced terms that robots are known to use, or sending requests very quickly.
    </div>




 IP address: 103.247.48.85<br>Time: 2016-04-30T14:02:34Z<br>URL: http://translate.google.com/translate_tts?ie=UTF-8&amp;q=hello+kalanka&amp;tl=en&amp;prev=input<br>
 </div>
</div>
</body>
</html>

    at us.monoid.web.AbstractResource.fill(AbstractResource.java:51)
    at us.monoid.web.Resty.fillResourceFromURL(Resty.java:432)
    at us.monoid.web.Resty.doGET(Resty.java:388)
    at us.monoid.web.Resty.bytes(Resty.java:355)
    at main.TextToSpeech.speech(TextToSpeech.java:42)
    at main.TextToSpeech.main(TextToSpeech.java:28)
Caused by: java.io.IOException: Server returned HTTP response code: 503 for URL: http://ipv4.google.com/sorry/IndexRedirect?continue=http://translate.google.com/translate_tts%3Fie%3DUTF-8%26q%3Dhello%2Bkalanka%26tl%3Den%26prev%3Dinput&q=CGMSBGf3MFUY-PWSuQUiGQDxp4NLgYkSgFOxxcQGJWJm5jZQLxCJi6c
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
    at us.monoid.web.AbstractResource.fill(AbstractResource.java:30)
    ... 5 more
java.io.IOException:读取GET:[503]服务时出错不可用
http://translate.google.com/translate_tts?ie=UTF-八,;q=你好+卡兰卡&;tl=en&;prev=输入


要继续,请键入以下字符:







关于此页面

我们的系统检测到来自您计算机网络的异常流量。此页面检查是否为';他真的是你在发送请求,而不是机器人

当Google自动检测到来自您的计算机网络的请求时,会显示此页面,这些请求似乎违反了。这些请求停止后,该块将很快过期。同时,解决上述验证码将允许您继续使用我们的服务。

此流量可能是由恶意软件、浏览器插件或发送自动请求的脚本发送的。如果共享网络连接,请向管理员寻求帮助&mdash;可能是使用相同IP地址的不同计算机造成的

如果您使用的是已知机器人使用的高级术语,或者发送请求非常快,有时可能会要求您解决验证码问题。 IP地址:103.247.48.85
时间:2016-04-30T14:02:34Z
URL:http://translate.google.com/translate_tts?ie=UTF-八,;q=你好+卡兰卡&;tl=en&;prev=输入
位于us.monoid.web.AbstractResource.fill(AbstractResource.java:51) 位于us.monoid.web.Resty.fillResourceFromURL(Resty.java:432) 位于us.monoid.web.Resty.doGET(Resty.java:388) 位于us.monoid.web.Resty.bytes(Resty.java:355) 位于main.TextToSpeech.speech(TextToSpeech.java:42) 位于main.TextToSpeech.main(TextToSpeech.java:28) 原因:java.io.IOException:服务器返回了URL的HTTP响应代码:503:http://ipv4.google.com/sorry/IndexRedirect?continue=http://translate.google.com/translate_tts%3Fie%3DUTF-8%26q%3Dhello%2Bkalanka%26tl%3Den%26prev%3Dinput&q=CGMSBGf3MFUY-PWSUQUIGQDXP4NLGYKSGFOxCQGJWJM5JZQLXCJI6C 位于sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840) 位于sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) 位于us.monoid.web.AbstractResource.fill(AbstractResource.java:30) ... 还有5个

请帮我输入这段代码。…

您收到的验证码阻止了您的请求。这是因为你是按程序访问该网站的,而该网站是为手动使用而设计的

查看此处的讨论和潜在解决方案:

或考虑寻找替代API:


给出完整的异常堆栈跟踪。这包括第一行,它告诉您实际抛出了什么异常。@bcsb1001我已经用完整的错误消息编辑了这个问题。但是我认为eclipse在连接到google translator时有些问题。我不知道该怎么办。netbeans也会出现同样的错误消息。请帮助。。。