scenario:
I am sending a long speech recognition file for speech recognition using speech_v1p1beta1 .
operation = client.long_running_recognize(config, audio)
operation_name = operation._operation.name
Issue
There is another file where I have to use operation_name (returned by google speech API) to get back the response again.
I tried get_operation method of the "Long-Running Operations Client":
from google.api_core import operations_v1
api = operations_v1.OperationsClient()
name = ...
response = api.get_operation(name)
When I poll response to check if the job has been completed or not using response.done. For the time being when the response job is not done, how do I get the progress percentage?
You can access the metadata field of a LRO.
https://cloud.google.com/speech-to-text/docs/reference/rpc/google.longrunning#operation
Though, I don't think there is a guarantee of providing progress other than 0 and 100.
https://cloud.google.com/speech-to-text/docs/reference/rest/v1/LongRunningRecognizeMetadata
Though, this will quickly hit quota, so probably put a delay between the calls.
operation = client.long_running_recognize(config, audio)
while not operation.done():
if operation.metadata is not None:
print(operation.metadata)
I didn't see any percentage info though, just:
start_time {
seconds: 1574186450
nanos: 65031000
}
last_update_time {
seconds: 1574186450
nanos: 271381000
}
Yea, the last one provides:
progress_percent: 100
start_time {
seconds: 1574186758
nanos: 15456000
}
last_update_time {
seconds: 1574186781
nanos: 57658000
}
thanks, @nnegrey , ya the last one provides the progress percentage as 100% but it would have been really useful if there was someway to get the interim percentage
Yep, feel free to file a feature request on this page https://cloud.google.com/support/docs/issue-trackers for the API.