I am having issue when using Google asynchronous speech recognition long running API. The operation.done
is not returning true.
I had modified the objective-C sample program https://github.com/GoogleCloudPlatform/ios-docs-samples/blob/master/speech/Objective-C/Speech-gRPC-Nonstreaming/Speech/SpeechRecognitionService.m to use longruning API.
Here are the modified snippet -
// prepare a single gRPC call to make the request
GRPCProtoCall *call = [client RPCToLongRunningRecognizeWithRequest:recognizeRequest
handler:
^(Operation *operation, NSError *nserror) {
if (nserror) {
NSLog(@"ERROR: %@", nserror);
completion([nserror description]);
} else {
NSLog(@"RESPONSE name %@", operation.name);
while (!operation.done) {
NSLog(@"operation done - %d", operation.done);
usleep(2000000);
}
GPBAny *gpbAny = operation.response;
NSLog(@"RESPONSE typeURL %@", gpbAny.typeURL);
NSLog(@"RESPONSE deescription %@", gpbAny.value.description);
GPBMessage *longRunningResponse = [gpbAny unpackMessageClass:LongRunningRecognizeResponse.class error:nil];
NSLog(@"RESPONSE RECEIVED %@", longRunningResponse);
completion(longRunningResponse);
}
}];
It never come out from the while (!operation.done)
loop. operation.name
return the correct operation id. I was able to verify using gcloud ml speech operations describe 2104003022050949209
command that call went to google speech API and it return the transcribed message. But objective-C code does not return the operation.done true.