Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create InfiniteStreamRecognizeSoftHandover.java #8251

Closed
wants to merge 4 commits into from

Conversation

bburli
Copy link

@bburli bburli commented Jun 12, 2023

Adding a sample for Soft Handover in stream switching.

Please refer #8250 for issue background.

Description

  • This class demonstrates how to perform infinite streaming speech recognition using theStreamingRecognize functionality of the Speech API. This class is almost identical to the InfiniteStreamRecognize.java class, except that it demonstrates how to perform "soft handover" between two streams.
  • A "soft handover" is making a new stream before breaking the old stream. As against a "hard handover" where you break the old stream before making the new stream. This is useful in situations where you want to perform speech recognition on a continuous audio input, but need to periodically restart the stream to avoid exceeding the maximum allowed continuous streaming duration. For demonstration purposes only, this sample uses a reset duration of 30 seconds whereas the actual allowed duration is 5 minutes per Google documentation for Streaming API.
  • This class uses two streams, STREAM1 and STREAM2, and alternates between them. When one stream is active, the other stream is used to buffer audio input. When the active stream is stopped, the buffered audio input is used to create a new stream.
  • This class also demonstrates how to align the transcript of the previous stream with the transcript of the current stream using a very simplistic algorithm.

Fixes #8250

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed Sample Format Guide
  • pom.xml parent set to latest shared-configuration
  • Appropriate changes to README are included in PR
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • Tests pass: mvn clean verify required
  • Lint passes: mvn -P lint checkstyle:check required
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

- Adding a sample for Soft Handover in stream switching.

Please refer GoogleCloudPlatform#8250 for issue background.
@bburli bburli requested review from a team and yoshi-approver as code owners June 12, 2023 05:31
@google-cla
Copy link

google-cla bot commented Jun 12, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@snippet-bot
Copy link

snippet-bot bot commented Jun 12, 2023

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: speech Issues related to the Speech-to-Text API. labels Jun 12, 2023
Ran formatting with google-java-formatter.
Copy link
Member

@anguillanneuf anguillanneuf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please

  1. add a test
  2. move the region tag start tag to line 18 (to include imports in the displayed/published sample)
  3. can you link to where in the docs this sample will get published? have you checked with the tech writer?

@bburli
Copy link
Author

bburli commented Jun 13, 2023

Hello @anguillanneuf!

  1. This example is a variation of InfiniteStreamingRecognize.java. As I see, that file also doesn't have a test. I am not sure how to write a test for infinite streaming use case. Can you provide any pointers?
  2. Done.
  3. I am not sure who decides to publish this. I brought in a PR because I thought it is an important example to share on Google streaming, especially where application control of failover is desirable. Issue InfiniteStreaming with soft handover. #8250 has more background as I mentioned in description. The infinite streaming class I referred above links from https://cloud.google.com/speech-to-text/docs/endless-streaming-tutorial page. I haven't checked with the tech writer. I am not sure how to do that as this is my first PR. I would appreciate any guidance in this regard.

@anguillanneuf
Copy link
Member

anguillanneuf commented Jun 13, 2023

Thanks @bburli for providing the great context for your PR! I apologize that I only had a chance to read carefully through the links you provided today. I'm sorry what i'm about to tell you may disappoint you. I have provided some options for you to consider.

This repo [language]-docs-samples is reserved for docs samples. If a sample you want to contribute is not going to be published on g.co/cloud, we cannot include it here. We've established sample guidelines over the years and we now require all samples to have tests (so they can be trusted by developers). You correctly pointed out that speech/src/main/java/com/example/speech/InfiniteStreamRecognize.java doesn't have a test. It looks like we missed it. I have gone ahead and opened the following issues to address our lack of tests for the published samples at https://cloud.google.com/speech-to-text/docs/endless-streaming-tutorial:

I also saw your communication with @minherz. He and I are on the same team and I will follow up with him offline. A helpful sample is different from a sample that we are committed to maintain thus a sample we will publish on g.co/cloud. I would recommend that you publish it in a different venue.

In order to publish your sample here, you need to engage with the product team and the TW to plan it. If they approve and are committed to add a docs page or a section in the docs describing what this sample is and why, we will allow it, and we will at that point require this sample to have a test.

@bburli
Copy link
Author

bburli commented Jun 14, 2023

@anguillanneuf Thank you so much for your guidance on this. I have a few questions:
1.

Thanks @bburli for providing the great context for your PR! I apologize that I only had a chance to read carefully through the links you provided today. I'm sorry what i'm about to tell you may disappoint you. I have provided some options for you to consider.

This repo [language]-docs-samples is reserved for docs samples. If a sample you want to contribute is not going to be published on g.co/cloud, we cannot include it here. We've established sample guidelines over the years and we now require all samples to have tests (so they can be trusted by developers). You correctly pointed out that speech/src/main/java/com/example/speech/InfiniteStreamRecognize.java doesn't have a test. It looks like we missed it. I have gone ahead and opened the following issues to address our lack of tests for the published samples at https://cloud.google.com/speech-to-text/docs/endless-streaming-tutorial:

I also saw your communication with @minherz. He and I are on the same team and I will follow up with him offline. A helpful sample is different from a sample that we are committed to maintain thus a sample we will publish on g.co/cloud. I would recommend that you publish it in a different venue.

In order to publish your sample here, you need to engage with the product team and the TW to plan it. If they approve and are committed to add a docs page or a section in the docs describing what this sample is and why, we will allow it, and we will at that point require this sample to have a test.

Hi @anguillanneuf - Thank you for your guidance here. This helps.

@anguillanneuf
Copy link
Member

anguillanneuf commented Jun 14, 2023

@bburli I mistook you for a Googler who would have contact with the product team and their tech writer, ofc you would not know how to reach out, I'm sorry about that. Please ignore the last paragraph in my previous response. I saw your post in Google Cloud Community. Thanks a lot. I'm going to go ahead and close this PR and the related issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: speech Issues related to the Speech-to-Text API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InfiniteStreaming with soft handover.
2 participants