Skip to content

Result returned from google.cloud.speech.sample.Sample.streaming_recognize #3166

Closed

Description

@cgratie

The streaming_recognize method of Sample computes its output as follows:

        for response in responses:
            for result in response.results:
                if result.is_final or interim_results:
                    yield StreamingSpeechResult.from_pb(result)

Thus, it returns a generator where results are no longer grouped by response. I feel that this makes it more difficult for the end user to use the results, since results from the same response should be concatenated in order to obtain the complete transcript of the fragment transcribed so far.

Activity

  1. daspecster commented on Mar 20, 2017

    @daspecster
    Contributor

    @cgratie if you set interin_results to True, it will pass the live results as they are received.

    I which case you could concatenate them. Does that answer your question?

  2. cgratie commented on Mar 20, 2017

    @cgratie
    Author

    @daspecster I am indeed using interim_results=True and want to use live results as they come in. As far as I could figure out from the content of the responses, results from the same response are to be concatenated to get the current transcription of the video, whereas new responses overwrite older ones. Thus, if I don't know when a new response starts (because I only see a flow of results), I don't know when to concatenate and when to overwrite.

    The example provided at python-docs-samples/speech/grpc/transcribe_streaming.py uses only the first result in order to show real time transcription results:

            result = resp.results[0]
            transcript = result.alternatives[0].transcript
    

    Even in that case, one still needs to know which is the first result from each response.

  3. daspecster commented on Mar 21, 2017

    @daspecster
    Contributor

    @cgratie ok, cool.

    I think I'm starting to grasp the issue. I think what you need access to is the result_index?

    That way you can update in place the results.

  4. cgratie commented on Mar 21, 2017

    @cgratie
    Author

    @daspecster Yeah, result_index would be enough for my current project.

    It would also be useful if endpointer_type can be exposed somehow: for example it could help identify segments containing speech inside a larger audio file. Assuming of course that the value of endpointer_type is reliable in the current version of the API. I am making the implicit assumption that all values inside a response are reliable enough to be sent over, which is why I was a bit confused that some of them are hidden from the end user.

  5. lukesneeringer commented on Aug 8, 2017

    @lukesneeringer
    Contributor

    Since this ticket was filed, we have released a new Speech library which entails effectively a complete rewrite. Since it is very likely to solve this issue, I am closing this. However, please feel free to reopen if my closure is premature.

    Note: Make sure you are using google.cloud.speech.SpeechClient, as the old Client still exists as a deprecated artifact for a little longer.

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

Metadata

Metadata

Assignees

Labels

api: speechIssues related to the Speech-to-Text API.priority: p2Moderately-important priority. Fix may not be included in next release.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions