Cloud “线程中的异常”;“主要”;com.google.api.gax.rpc.deadlineExceedexception:io.grpc.StatusRuntimeException:DEADLINE\u已超过

Cloud “线程中的异常”;“主要”;com.google.api.gax.rpc.deadlineExceedexception:io.grpc.StatusRuntimeException:DEADLINE\u已超过,cloud,speech-to-text,google-cloud-speech,Cloud,Speech To Text,Google Cloud Speech,我在使用公司代理连接到google cloud speech to text api时遇到了这个问题: io.grpc.internal.ManagedChannel Impl$NameResolverListenerImpl onError 警告:[io.grpc.internal.ManagedChannel Impl-1]无法解析 名称状态=状态{code=UNAVAILABLE,description=null, 原因=java.net.UnknownHostException:这通常是

我在使用公司代理连接到google cloud speech to text api时遇到了这个问题:

io.grpc.internal.ManagedChannel Impl$NameResolverListenerImpl onError 警告:[io.grpc.internal.ManagedChannel Impl-1]无法解析 名称状态=状态{code=UNAVAILABLE,description=null, 原因=java.net.UnknownHostException:这通常是一个临时错误 主机名解析期间,表示本地服务器没有 从权威服务器接收响应 (speech.googleapis.com)

这是我的密码

/*try {
    Credentials creds = GoogleCredentials.getApplicationDefault();
    System.out.println(" "+creds);
} catch (IOException e2) {
    e2.printStackTrace();
}*/
System.setProperty("http.proxyHost", "X.X.X.X");
System.setProperty("http.proxyPort", "3128");
System.setProperty("https.proxyHost", "x.x.x.x");
System.setProperty("https.proxyPort", "3128");

/*String encoded = new String(Base64.encodeBase64(new String("username:password").getBytes()));
String base64encodedCredentials = "Basic " + encoded;*/

SpeechClient speech = null;
try {
    speech = SpeechClient.create();
} catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}
//speech.getRequestFactory().setPrivateHeader("Proxy-Authorization", base64encodedCredentials);

// The path to the audio file to transcribe
String fileName = "D:\\RecordAudio1.flac";//D:\\Voice\\RecordAudio.wav
System.out.println("path "+fileName);

// Reads the audio file into memory
Path path = Paths.get(fileName);
byte[] data = null;
try {
    data = Files.readAllBytes(path);
} catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}
ByteString audioBytes = ByteString.copyFrom(data);

// Builds the sync recognize request
RecognitionConfig config = RecognitionConfig.newBuilder()
    .setEncoding(AudioEncoding.FLAC)
    .setSampleRateHertz(16000)
    .setLanguageCode("en-US")
    .build();
RecognitionAudio audio = RecognitionAudio.newBuilder()
    .setContent(audioBytes)
    //.setUri(("gs://cloud-samples-tests/speech/brooklyn.flac"))
    .build();

// Performs speech recognition on the audio file
RecognizeResponse response = speech.recognize(config, audio);
List<SpeechRecognitionResult> results = response.getResultsList();
System.out.println("came to line 69 "+results.size());
try
{
  for (SpeechRecognitionResult result: results) {
    // There can be several alternative transcripts for a given chunk of speech. Just use the
    // first (most likely) one here.
    SpeechRecognitionAlternative alternative = result.getAlternativesList().get(0);
    System.out.printf("Transcription: %s%n", alternative.getTranscript());
  }
    speech.close();
} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
/*试试看{
Credentials creds=GoogleCredentials.getApplicationDefault();
系统输出打印项次(“+creds);
}捕获(IOE2异常){
e2.printStackTrace();
}*/
System.setProperty(“http.proxyHost”、“X.X.X.X”);
setProperty(“http.proxyPort”、“3128”);
System.setProperty(“https.proxyHost”、“x.x.x.x”);
System.setProperty(“https.proxyPort”、“3128”);
/*字符串编码=新字符串(Base64.encodeBase64(新字符串(“用户名:密码”).getBytes());
字符串base64encodedCredentials=“Basic”+已编码*/
SpeechClient speech=null;
试一试{
SpeechClient.create();
}捕获(IOE1异常){
//TODO自动生成的捕捉块
e1.printStackTrace();
}
//speech.getRequestFactory().setPrivateHeader(“代理授权”,base64encodedCredentials);
//要转录的音频文件的路径
String fileName=“D:\\RecordAudio1.flac”;//D:\\Voice\\RecordAudio.wav
System.out.println(“路径”+文件名);
//将音频文件读入内存
Path Path=Path.get(文件名);
字节[]数据=null;
试一试{
数据=文件。readAllBytes(路径);
}捕获(IOE1异常){
//TODO自动生成的捕捉块
e1.printStackTrace();
}
ByteString audioBytes=ByteString.copyFrom(数据);
//生成同步识别请求
RecognitionConfig=RecognitionConfig.newBuilder()
.setEncoding(AudioEncoding.FLAC)
.setSampleRateHertz(16000)
.setLanguageCode(“en-US”)
.build();
RecognitionAudio=RecognitionAudio.newBuilder()
.setContent(音频字节)
//.setUri(((“gs://cloud-samples-tests/speech/brooklyn.flac”))
.build();
//对音频文件执行语音识别
RecognizeResponse response=speech.recognize(配置,音频);
列表结果=response.getResultsList();
System.out.println(“来到第69行+results.size());
尝试
{
for(SpeechRecognitionResult:results){
//对于给定的一段演讲,可以有多个备选文本。只需使用
//第一个(很可能)在这里。
speechrecognitionalAlternative=result.getAlternativesList().get(0);
System.out.printf(“转录:%s%n”,alternative.getTranscript());
}
speech.close();
}捕获(例外e){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
我尝试在系统变量中设置
GRPC\u PROXY\u EXP=“http.proxyHost:port”
环境变量,但仍然出现相同的错误


请帮助..

您使用Speech API获得此错误,因为此API正在尝试解决这一问题,这意味着本地服务器没有收到来自授权服务器(Speech.googleapis.com)的响应。 因此,我认为问题与客户本地DNS配置有关