Getting metadata/progress of a long-running recognition
See original GitHub issueIn which file did you encounter the issue?
java-docs-samples/speech/cloud-client/src/main/java/com/example/speech/Recognize.java
Did you change the file? If so, how?
I modified the while loop to attempt getting the progress of the operation in asyncRecognizeGcs(String gcsUri)
OperationFuture<LongRunningRecognizeResponse, LongRunningRecognizeMetadata,
Operation> response =
speech.longRunningRecognizeAsync(config, audio);
while (!response.isDone()) {
ApiFuture<LongRunningRecognizeMetadata> future = response.peekMetadata();
if (future != null) {
LongRunningRecognizeMetadata meta = future.get();
if (meta != null) {
int percent = meta.getProgressPercent();
System.out.println(String.format("Percent complete: %s%%", percent));
}
}
Thread.sleep(500);
}
The while loop used to be:
while (!response.isDone()) {
System.out.println("Waiting for response...");
Thread.sleep(10000);
}
Describe the issue
API version in Gradle: ‘com.google.cloud:google-cloud-speech:0.21.1-alpha’
Using some test audio about 14 seconds long, getting the metadata of the response doesn’t return anything until the response is complete. Using response.peekMetadata()
leads to returning 0% until the response is done. Using response.getMetadata()
of course makes the later future.get()
blocking, but the only time it returns is at the end with 100%.
From the documentation on the metadata in REST it does show that progress can be returned, but Java uses gRPC.
Perhaps I’m using the code incorrectly, but otherwise would hope for some documentation or the feature to be available in the Java client library. Having progress output for very long audio (now up to 3 hours after the recent update) is almost necessary.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
hi jbrew , are you able to solve this issue? i tried using 0.25.0-alpha version, but still not working, any work around?
Notice: this issue has been closed because it has been inactive for 192 days. You may reopen this issue if it has been closed in error.