0

我试图围绕从您的帮助页面逐字复制的 Google Text-to-Speech 创建一个包装器。从日志看来,它似乎试图创建一个 Jetty 实例(将呼叫转发到另一个服务?)但失败了,因为它无法通过从默认值读取来为其分配网络地址。我将包括日志输出供您参考。您能否建议在使用 Cloudfunctions 时更改代码或使用不同的策略?

日志输出如下:

   "textPayload": "java.io.IOException: com.google.api.gax.rpc.DeadlineExceededException: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED: deadline exceeded after 19.821560546s. [buffered_nanos=2713815445, buffered_nanos=17108132243, waiting_for_connection]\n\tat com.gcp.cloudfunctions.Test.service(Test.java:91)\n\tat com.google.cloud.functions.invoker.NewHttpFunctionExecutor.service(NewHttpFunctionExecutor.java:67)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:755)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:547)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1297)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:485)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1212)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)\n\tat com.google.cloud.functions.invoker.runner.Invoker$NotFoundHandler.handle(Invoker.java:379)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:500)\n\tat org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)\n\tat org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:547)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:270)\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)\n\tat org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)\n\tat java.base/java.lang.Thread.run(Thread.java:834)\nCaused by: com.google.api.gax.rpc.DeadlineExceededException: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED: deadline exceeded after 19.821560546s. [buffered_nanos=2713815445, buffered_nanos=17108132243, waiting_for_connection]\n\tat com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:51)\n\tat com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:72)\n\tat com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:60)\n\tat com.google.api.gax.grpc.GrpcExceptionCallable$ExceptionTransformingFuture.onFailure(GrpcExceptionCallable.java:97)\n\tat com.google.api.core.ApiFutures$1.onFailure(ApiFutures.java:68)\n\tat com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:982)\n\tat com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30)\n\tat com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1138)\n\tat com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:957)\n\tat com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:748)\n\tat io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:522)\n\tat io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:497)\n\tat io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:426)\n\tat io.grpc.internal.ClientCallImpl.access$500(ClientCallImpl.java:66)\n\tat io.grpc.internal.ClientCallImpl$1CloseInContext.runInContext(ClientCallImpl.java:416)\n\tat io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)\n\tat io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\t... 1 more\n\tSuppressed: com.google.api.gax.rpc.AsyncTaskException: Asynchronous task failed\n\t\tat com.google.api.gax.rpc.ApiExceptions.callAndTranslateApiException(ApiExceptions.java:57)\n\t\tat com.google.api.gax.rpc.UnaryCallable.call(UnaryCallable.java:112)\n\t\tat com.google.cloud.texttospeech.v1beta1.TextToSpeechClient.synthesizeSpeech(TextToSpeechClient.java:268)\n\t\tat com.google.cloud.texttospeech.v1beta1.TextToSpeechClient.synthesizeSpeech(TextToSpeechClient.java:241)\n\t\tat com.gcp.cloudfunctions.CloudTextToSpeech.getSpeech(CloudTextToSpeech.java:97)\n\t\tat com.gcp.cloudfunctions.Test.service(Test.java:53)\n\t\tat com.google.cloud.functions.invoker.NewHttpFunctionExecutor.service(NewHttpFunctionExecutor.java:67)\n\t\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\t\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:755)\n\t\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:547)\n\t\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)\n\t\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1297)\n\t\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)\n\t\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:485)\n\t\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)\n\t\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1212)\n\t\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)\n\t\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)\n\t\tat com.google.cloud.functions.invoker.runner.Invoker$NotFoundHandler.handle(Invoker.java:379)\n\t\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)\n\t\tat org.eclipse.jetty.server.Server.handle(Server.java:500)\n\t\tat org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)\n\t\tat org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:547)\n\t\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)\n\t\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:270)\n\t\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)\n\t\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)\n\t\tat org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)\n\t\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)\n\t\tat org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)\n\t\t... 1 more\nCaused by: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED: deadline exceeded after 19.821560546s. [buffered_nanos=2713815445, buffered_nanos=17108132243, waiting_for_connection]\n\tat io.grpc.Status.asRuntimeException(Status.java:533)\n\t... 12 more",
   "insertId": "000000-a16ab144-e2f2-4fe6-ae1a-fc939a327991",
   "resource": {
     "type": "cloud_function",
     "labels": {
       "region": "us-central1",
       "function_name": "function-1",
       "project_id": "nice-theater-281908"
     }
   },....

更新:

事实证明,导致 DEADLINE_EXCEEDED 错误的行是罪魁祸首。谷歌搜索错误表明这可能是因为客户端没有及时收到服务器的响应(在超时之前)。这是导致错误的行。

SynthesizeSpeechResponse response = textToSpeechClient.synthesizeSpeech(input, voice, audioConfig);

关于如何解决它或如何增加进程超时的任何建议?愿意试一试。

4

1 回答 1

1

SynthesizeSpeech 是一种同步方法,因此您必须等待响应。Cloud Functions 具有默认超时,但您可以延长超时。您还可以尝试拆分文本,使其更小,从而更有可能在 Cloud Function 时间限制内完成。

于 2020-07-06T06:16:03.877 回答