Skip to content

Getting metadata/progress of a long-running recognition #819

Closed

Description

@jbrew138

In 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.

Activity

  1. jpaquinocivicom commented on Nov 20, 2017

    @jpaquinocivicom

    hi jbrew , are you able to solve this issue? i tried using 0.25.0-alpha version, but still not working, any work around?

  2. lesv commented on Dec 6, 2017

    @lesv
    Contributor
  3. gguuss commented on Dec 19, 2017

    @gguuss
    Contributor

    OK, I was able to reproduce what @jbrew138 is seeing:

    • Updates come in and the metadata in the long running operations do not get updated
    • When the processing completes, metadata jumps to 100% from 0%

    According to the docs, this is actually the expected behavior, only the 100% progress indicator is guaranteed. That said, this looks like a feature that we should be implementing (intermediate updates to results in long running speech operations).

  4. bud4 commented on Oct 16, 2018

    @bud4

    it would be very useful to have an indication of the progress.
    i'm using REST to read progress . I realized that the progressPercent attribute is not present in the json if it has value 0 or if the file is small and therefore the progress goes immediately from 0 to 100 !!
    I think it would be more correct that the progressPercent attribute was always present even if it has a value of 0.

  5. bud4 commented on Oct 16, 2018

    @bud4

    @gguuss in json jumps from 0 to 100 is true for small file. try it with very large files. look at my previous comment

  6. kurtisvg commented on Jun 10, 2019

    @kurtisvg
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Sponsor
    SponsoredKunjungi sekarang
    Promo