nodejs-speech icon indicating copy to clipboard operation
nodejs-speech copied to clipboard

Infinite streaming returns RESOURCE_EXHAUSTED

Open petrnetusil opened this issue 7 years ago • 2 comments

Hi, We're streaming real-time voice from Twilio using their Media streams. We've switched the microphone input to a websocket write stream, adapting the guide from infiniteStreaming.js.

After getting the stream, we write to the transform like: audioInputStreamTransform.write(Buffer.from(msg.media.payload, 'base64'))

The stream restart is set to 30s, considering the 1m issue here: https://github.com/googleapis/nodejs-speech/issues/455 and the recommendation in infiniteStream.js to restart after 1/2 of maximum stream time.

Now, if we speak for 31s (=stream restarts), we're running in issue: Error: 8 RESOURCE_EXHAUSTED: Resource has been exhausted (e.g. check quota)., after which the stream is destroyed.

GCP console Quotas&Limits do not show anything unusual, neither there's more stack trace. Hence, I'm led to believe this is because the cached stream is NOT sent in a pace that approximates real-time and hence STT API complains (as described here https://cloud.google.com/speech-to-text/quotas#content).

Environment details

  • OS: App Engine Flex
  • Node.js version: 10.x
  • @google-cloud/speech version: 3.3.2

Steps to reproduce

In infiniteStreaming.js:

  1. Set timeout for a stream to restart after 30s.
  2. Have a longer voice stream write audio chunks to audioInputStreamTransform [our infrastructure is in AppEngine]
  3. Talk for at least 31s
  4. RESOURCE_EXHAUSTED

Any ideas are much appreciated, Petr

petrnetusil avatar Nov 01 '19 13:11 petrnetusil

I was able to get more stack trace, pasting here in case it helps.

Error: 8 RESOURCE_EXHAUSTED: Resource has been exhausted (e.g. check quota).
    at callErrorFromStatus (/Users/path-to-my-project/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
    at Http2CallStream.<anonymous> (/Users/path-to-my-project/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/call.js:79:34)
    at Http2CallStream.emit (events.js:215:7)
    at /Users/path-to-my-project/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/call-stream.js:75:22
    at processTicksAndRejections (internal/process/task_queues.js:75:11) {
  code: 8,
  details: 'Resource has been exhausted (e.g. check quota).',
  metadata: Metadata { internalRepr: Map {}, options: {} }
}

Speaking for longer that 30s (my streaming limit) now intermittently also returns the following error. Sometimes with RESOURCE_EXHAUSTED, sometimes without.

ApiError: Audio Timeout Error: Long duration elapsed without audio. Audio should be sent close to real time.
    at new ApiError (/Users/path-to-my-project/node_modules/@google-cloud/common/build/src/util.js:60:15)
    at PassThrough.transform [as _transform] (/Users/path-to-my-project/node_modules/@google-cloud/speech/src/helpers.js:112:20)
    at PassThrough.Transform._read (_stream_transform.js:189:10)
    at PassThrough.Transform._write (_stream_transform.js:177:12)
    at doWrite (_stream_writable.js:431:12)
    at writeOrBuffer (_stream_writable.js:415:5)
    at PassThrough.Writable.write (_stream_writable.js:305:11)
    at StreamProxy.ondata (/Users/path-to-my-project/node_modules/readable-stream/lib/_stream_readable.js:619:20)
    at StreamProxy.emit (events.js:210:5)
    at addChunk (/Users/path-to-my-project/node_modules/readable-stream/lib/_stream_readable.js:291:12) {
  code: 11,
  errors: undefined,
  response: undefined,
  message: 'Audio Timeout Error: Long duration elapsed without audio. Audio should be sent close to real time.'
} 

Appreciate any pointers here.

petrnetusil avatar Nov 10 '19 20:11 petrnetusil

Can you verify the original samples works as is without modification? Just ran it on my end and have no issues. It might be when you changed the audio source something got lost in the adaptation from the sample to your code.

Feel free to reopen.

nnegrey avatar Dec 10 '19 21:12 nnegrey