我通过 nodejs sdk(vs 4.4.0)使用 Cloud/Speech API 并且我最初抓住了 node js sample
我的语音通话如下所示,大部分时间一切都按预期运行,但是,我偶尔会在服务器日志中遇到此类未处理的错误。
<块引用>这个错误要么是因为在没有 catch 块的情况下抛出异步函数内部,要么是因为拒绝了一个没有用 .catch() 处理的承诺。承诺被拒绝的原因: 错误:13 内部:收到 RST_STREAM,代码 2 由内部客户端错误触发:读取 ECONNRESET 在 Object.callErrorFromStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call.js:31:26) 在 Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client.js:176:52)...
错误消息不一定是上面这个确切的错误,我实际上有错误被捕获和处理但无法可靠地处理这些错误对我来说是一个大问题。
其中一些错误漏掉的原因可能是什么?
const speech = require('@google-cloud/speech').v1p1beta1;
// Creates a client
const client = new speech.SpeechClient();
const speechAudio = {
uri: `gs://[GCS_BUCKET_PATH]`,
};
// const speechConfig = {
// initialize configuration here
// }
const speechRequest = {
audio: speechAudio,
config: speechConfig,
};
try {
const [operation] = await client.longRunningRecognize(speechRequest);
operation
.on("complete", (longRunningRecognizeResponse) => {
// handle completion
})
.on("progress", async (longRunningRecognizeMetadata) => {
// handle progress
})
.on("error", (error) => {
// handle error
})
}
catch(error) {
// handle uncaught error
}