googleapis / gax-ruby

Google API Extensions for Ruby
https://rubygems.org/gems/google-gax
BSD 3-Clause "New" or "Revised" License
20 stars 22 forks source link

GaxError Exception. Received message larger than max (5371623 vs. 4194304) #133

Closed brianarpie closed 6 years ago

brianarpie commented 6 years ago

I'm sending audio files to Google Speech API and I'm hitting this limit on file size. Is there any way to relax this limit ? It seems wrong that the Google Speech API can handle audio files up to 180 minutes in length but this interim library is limiting the file size to 4.2 MB ? I think I might be interpreting the error message incorrectly.

GaxError Exception occurred in retry method that was not classified as transient, caused by 8:Received message larger than max (5371623 vs. 4194304)
 /Users/brianarpie/.rvm/gems/ruby-2.3.0/gems/google-gax-1.3.0/lib/google/gax/api_callable.rb:369:in `rescue in block in retryable'
 /Users/brianarpie/.rvm/gems/ruby-2.3.0/gems/google-gax-1.3.0/lib/google/gax/api_callable.rb:358:in `block in retryable'
 /Users/brianarpie/.rvm/gems/ruby-2.3.0/gems/google-gax-1.3.0/lib/google/gax/api_callable.rb:230:in `block in create_api_call'
 /Users/brianarpie/.rvm/gems/ruby-2.3.0/gems/google-gax-1.3.0/lib/google/gax/api_callable.rb:260:in `block in create_api_call'
 /Users/brianarpie/.rvm/gems/ruby-2.3.0/gems/google-gax-1.3.0/lib/google/longrunning/operations_client.rb:225:in `get_operation'
jbolinger commented 6 years ago

I don't think this is a problem with this library or the client. There is a limit on payload size that's enforced by the server. However, there are ways to send large files.

Have you looked at the streaming_recognize method in the Speech library to see if it would work for you? You can also upload files to Cloud Storage and then use the uri to process them with the Speech library, like in the examples. Have you tried that?

brianarpie commented 6 years ago

I should have clarified that the audio file is coming from Google Cloud Storage and I am passing the uri to the Speech API. What's interesting is this actually is a transient error. I have this process running inside a delayed job and after about the third or fourth retry the payload makes it through!

Streaming requests have a audio limit of ~ 1 minute according to this documentation: https://cloud.google.com/speech-to-text/quotas though I haven't tried it. I will close this for now because it is working after retrying many times.