-
Notifications
You must be signed in to change notification settings - Fork 598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Allow user to configure the Operation polling interval #1886
Comments
For some APIs, like Speech, we can solve this by upgrading to the latest |
Thank you for opening this issue. I was just about to do it myself, having spent all day today finding the problem and bringing attention to it on the google speech discussion thread. Could I get a timeline of when this will be fixed? I'm currently working on something time-sensitive and I'm debating between waiting for this to be fixed or switching to the python library (where this doesn't seem to be a problem). |
@kbyatnal What version |
@jmdobry |
Are you reading the file into memory yourself or just passing the file path string to |
I'm passing it the File object (from Google Cloud Storage/Bucket). I actually saw the discussion thread regarding this topic and have implemented the temporary workaround. It seems to be working for now. |
Right, but if you're using |
I don't think the exponential multiplier is in place for this version. I made 3 requests to the API yesterday before I started getting quota errors, so I checked my console and saw that it had registered 2000+ hits for the API. |
Try this: return speech.api.Speech({
config: speechConfig,
audio: {
uri: 'gs://YOUR_BUCKET_NAME/YOUR_FILE_NAME'
}
}, {
longrunning: {
// Try fiddling with the first two numbers
initialRetryDelayMillis: 100, // This is the initial delay
retryDelayMultiplier: 1.3, // This is the multiplier that increases the delay over time
maxRetryDelayMillis: 60000,
initialRpcTimeoutMillis: null,
rpcTimeoutMultiplier: null,
maxRpcTimeoutMillis: null,
totalTimeoutMillis: 600000
}
}, (err, operation, apiResponse) => {
if (err){
return cb(err);
}
operation
.on('complete', function (response) {
console.log(response.results[0].alternatives[0]);
});
}); |
@kbyatnal it might help to double-check the version of $ npm cache clean
$ npm install --save @google-cloud/speech
$ npm ls google-gax
[email protected] /Users/stephen/dev/play/play-1481768017
└─┬ @google-cloud/[email protected]
└── [email protected] |
Thanks for the suggestion! I updated to 0.10.4, but now I'm getting the following error while running the code:
Here is my code: ` return speech.startRecognition(file, speechConfig, (err, operation, apiResponse) => { The file is a Google Cloud Storage File object. Edit: In fact, updating to this new version of google-gax seems to have broken the code which was working yesterday (w/ manual polling) and gives the same error. I can't get the speech transcription to work at all now. |
cc @jmuk |
cc @landrito |
Sorry for that. The error message might look like protobuf.js decodes the data as a typed array while our code assumes it's a NodeJS Buffer? 😞 @landrito -- please look into this, and please try using Speech API with your patch before sending PRs. |
I'll look into it. Sorry about that! |
Seems like Speech system tests in this repo would have caught that no? |
@kbyatnal Which version of node are you using? |
googleapis/gax-nodejs#90 should solve this problem! It appears I was using a method in Node that does not work for node versions @jmdobry I suspect this is why it slipped through the system tests. |
I'm on node version 5.5.0 right now. |
@kbyatnal I just published google-gax 0.10.5 which should fix the issue! |
Awesome, that part seems to be fixed now! I guess this brings us back to the original issue. I just tried calling the async method in the API with a 1 minute raw audio file and I got the "quota exceeded issue". I checked my API console and that one request resulted in a quota usage of 486 requests, which leads me to believe that the exponential backoff isn't working. This is with the latest google-gax version 0.10.5. |
@kbyatnal Can you try calling the async method on google-gax version |
The quota exceeded issue is resolved with @kbyatnal, just want to make sure you try |
Let's call it resolved, but please let us know if anything is not functioning as expected. |
Right now Operations poll every 0.5 seconds. Unfortunately for some APIs the
GetOperation
rpc call counts against the user's quota. In the case ofSpeech#startRecognition
when the user uploads a large amount of audio, use ofoperation.on('complete', ...
can result in hundreds of API calls, decimating the user's quota (which isn't that big).google-cloud-node should allow the user to configure the polling interval, or even use exponential backoff.
The text was updated successfully, but these errors were encountered: