0

由于我知道此处列出的限制,因此我需要对配额限制进行一些说明。我正在使用 Node.js 库创建一个简单的异步语音到文本 API,使用存储在我的存储桶中的 .raw 文件。请求完成后,在检查API Manager Traffic时,每日请求计数器增加 50 到 100 个请求。我没有使用任何类型的请求库或其他框架。只是 gCloud 文档中的代码。

var file = URL.bucket +  "audio.raw"; //require from upload.
speech.startRecognition(file, config).then((data) => {
    var operation = data[0];

    operation.on('complete', function(transcript) {
        console.log(transcript);
    });
})
4

1 回答 1

0

我相信这与operation.on调用有关,该调用注册了一个侦听器以完成操作,但会继续轮询服务,直到它最终完成。

认为,基于查看一些代码,您可以使用该longrunning.initialRetryDelayMillis设置更改服务轮询的时间间隔,这应该会减少您在配额消耗中看到的请求数量。

一些要看的地方:

  1. 语音客户端构造函数:https ://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/packages/speech/src/index.js#L70

  2. GAX 语音客户端的构造函数:https ://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/packages/speech/src/v1/speech_client.js#L67

  3. 操作客户端:https ://github.com/googleapis/gax-nodejs/blob/master/lib/operations_client.js#L74

  4. GAX的操作:https ://github.com/googleapis/gax-nodejs/blob/master/lib/longrunning.js#L304

于 2017-07-10T11:59:56.463 回答