GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Added setEnableWordTimeOffsets(true) to Async Recognize for a File by dlaqab · Pull Request #781 · GoogleCloudPlatform/java-docs-samples

Conversation

@dlaqab

@dlaqab dlaqab commented Aug 1, 2017

Copy link
Copy Markdown

Added setEnableWordTimeOffsets(true) to Async Recognize for a File
Added setEnableWordTimeOffsets(false) to Sync samples and quick start

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Daryush Laqab
Added setEnableWordTimeOffsets(true) to Async Recognize for a File
1e4cf44
Added setEnableWordTimeOffsets(false) to Sync samples and quick start
@googlebot

googlebot commented Aug 1, 2017

Copy link
Copy Markdown

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

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Aug 1, 2017
@dlaqab

dlaqab commented Aug 1, 2017

Copy link
Copy Markdown
Author

I am covered by my current employer (Google)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gguuss
gguuss suggested changes Aug 1, 2017
View reviewed changes
Comment thread speech/cloud-client/src/main/java/com/example/speech/Recognize.java
.setEncoding(AudioEncoding.FLAC)
.setLanguageCode("en-US")
.setSampleRateHertz(16000)
.setEnableWordTimeOffsets(false)

@gguuss gguuss Aug 1, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Isn't false the default?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread speech/cloud-client/src/main/java/com/example/speech/Recognize.java
.setEncoding(AudioEncoding.LINEAR16)
.setLanguageCode("en-US")
.setSampleRateHertz(16000)
.setEnableWordTimeOffsets(false)

@gguuss gguuss Aug 1, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Isn't false the default?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread speech/cloud-client/src/main/java/com/example/speech/Recognize.java
List<SpeechRecognitionAlternative> alternatives = result.getAlternativesList();
for (SpeechRecognitionAlternative alternative: alternatives) {
System.out.printf("Transcription: %s%n", alternative.getTranscript());
for (WordInfo wordInfo: alternative.getWordsList()) {

@gguuss gguuss Aug 1, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please add a test for this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@dlaqab dlaqab Aug 2, 2017

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done. I added the test. I also fixed the test failure in AsyncRecognizeGcs test, so all the tests should pass now

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread speech/cloud-client/src/main/java/com/example/speech/Recognize.java Outdated
for (WordInfo wordInfo: alternative.getWordsList()) {
System.out.println(wordInfo.getWord());
System.out.printf("\t%s ns - %s ns\n",
wordInfo.getStartTime().getNanos(), wordInfo.getEndTime().getNanos());

@gguuss gguuss Aug 1, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

You're missing seconds, this just shows the nanoseconds for portions of the response.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gguuss gguuss Aug 1, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Please update the other async sample to correctly show the seconds and nanos calculated to second fractions.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@dlaqab dlaqab Aug 2, 2017

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

your original code did not have seconds, and I did not change the "pretty print" to show seconds.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread speech/cloud-client/src/main/java/com/example/speech/QuickstartSample.java
.setEncoding(AudioEncoding.LINEAR16)
.setSampleRateHertz(16000)
.setLanguageCode("en-US")
.setEnableWordTimeOffsets(false)

@gguuss gguuss Aug 1, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Isn't this superfluous as false is the default?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gguuss gguuss Aug 2, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm pretty sure we don't want to set an optional parameter to its default value in the quickstart example. Thoughts?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Daryush Laqab
Added missing test for AsyncRecognizeFile
a893740
Fixed the tests for WordTimeOffsets
@googlebot

googlebot commented Aug 2, 2017

Copy link
Copy Markdown

CLAs look good, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Aug 2, 2017
gguuss
gguuss reviewed Aug 2, 2017
View reviewed changes
Comment thread speech/cloud-client/src/main/java/com/example/speech/Recognize.java
List<SpeechRecognitionAlternative> alternatives = result.getAlternativesList();
for (SpeechRecognitionAlternative alternative: alternatives) {
System.out.printf("Transcription: %s%n", alternative.getTranscript());
System.out.printf("Transcription: %s\n",alternative.getTranscript());

@gguuss gguuss Aug 2, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This should be:

          System.out.printf("\t%s.%s sec - %s.%s sec\n",
              wordInfo.getStartTime().getSeconds(),
              wordInfo.getStartTime().getNanos() / 100000000,
              wordInfo.getEndTime().getSeconds(),
              wordInfo.getEndTime().getNanos() / 100000000);
        }

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@dlaqab dlaqab Aug 2, 2017

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This line shows the all up transcript - lines bellow it are iterating through the words and displaying the start and end time stamps

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gguuss
gguuss reviewed Aug 2, 2017
View reviewed changes
Comment thread speech/cloud-client/src/test/java/com/example/speech/RecognizeIT.java Outdated
Recognize.asyncRecognizeGcs(gcsPath);
String got = bout.toString();
assertThat(got).contains("\t0.0 sec -");
assertThat(got).contains("\t0 ns");

@gguuss gguuss Aug 2, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Revert this change when you correct the print output in asyncRecognizeFile

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gguuss

gguuss commented Aug 2, 2017

Copy link
Copy Markdown
Contributor

@dlaqab Please update your branch to match master, change your new code to match the updated start seconds / end seconds code as:

          System.out.printf("\t%s.%s sec - %s.%s sec\n",
              wordInfo.getStartTime().getSeconds(),
              wordInfo.getStartTime().getNanos() / 100000000,
              wordInfo.getEndTime().getSeconds(),
              wordInfo.getEndTime().getNanos() / 100000000);
        }

Revert your change in RecognizeIT to test for actual seconds / fractions of a second.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Daryush Laqab added 2 commits August 2, 2017 11:17
Daryush Laqab
Merge remote-tracking branch 'upstream/master'
29f9f76
Daryush Laqab
Changed Nanoseconds to Seconds, and fixed the tests
e4a7cce
@gguuss

gguuss commented Aug 2, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

@lesv /FYI - Looks like the Circle tests are not running because this is on a personal fork of the repo. When I run the tests locally, the following is my output:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building speech-google-cloud-samples 1.0.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.9:prepare-agent (default) @ speech-google-cloud-samples ---
[INFO] argLine set to -javaagent:/Users/class/.m2/repository/org/jacoco/org.jacoco.agent/0.7.9/org.jacoco.agent-0.7.9-runtime.jar=destfile=/Users/class/temp/daryush/java-docs-samples/speech/cloud-client/target/jacoco.exec
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ speech-google-cloud-samples ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/class/temp/daryush/java-docs-samples/speech/cloud-client/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ speech-google-cloud-samples ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ speech-google-cloud-samples ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/class/temp/daryush/java-docs-samples/speech/cloud-client/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ speech-google-cloud-samples ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.20:test (default-test) @ speech-google-cloud-samples ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.9:report (report) @ speech-google-cloud-samples ---
[INFO] Loading execution data file /Users/class/temp/daryush/java-docs-samples/speech/cloud-client/target/jacoco.exec
[INFO] Analyzed bundle 'speech-google-cloud-samples' with 3 classes
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ speech-google-cloud-samples ---
[INFO]
[INFO] --- maven-failsafe-plugin:2.20:integration-test (default) @ speech-google-cloud-samples ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.speech.QuickstartSampleIT
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.831 s - in com.example.speech.QuickstartSampleIT
[INFO] Running com.example.speech.RecognizeIT
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 52.388 s - in com.example.speech.RecognizeIT
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 58.288 s
[INFO] Finished at: 2017-08-02T16:42:02-07:00
[INFO] Final Memory: 21M/376M
[INFO] ------------------------------------------------------------------------

Checkstyle shows:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building speech-google-cloud-samples 1.0.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-checkstyle-plugin:2.17:check (default-cli) @ speech-google-cloud-samples ---
[INFO] Starting audit...
[WARN] /Users/class/temp/daryush/java-docs-samples/speech/cloud-client/src/main/java/com/example/speech/QuickstartSample.java:36:3: Missing a Javadoc comment. [JavadocMethod]
[WARN] /Users/class/temp/daryush/java-docs-samples/speech/cloud-client/src/main/java/com/example/speech/Recognize.java:47:3: Missing a Javadoc comment. [JavadocMethod]
[WARN] /Users/class/temp/daryush/java-docs-samples/speech/cloud-client/src/main/java/com/example/speech/Recognize.java:157:3: Missing a Javadoc comment. [JavadocMethod]
[WARN] /Users/class/temp/daryush/java-docs-samples/speech/cloud-client/src/test/java/com/example/speech/QuickstartSampleIT.java:35: Abbreviation in name 'QuickstartSampleIT' must contain no more than '2' consecutive capital letters. [AbbreviationAsWordInName]
[WARN] /Users/class/temp/daryush/java-docs-samples/speech/cloud-client/src/test/java/com/example/speech/RecognizeIT.java:35: Abbreviation in name 'RecognizeIT' must contain no more than '2' consecutive capital letters. [AbbreviationAsWordInName]
Audit done.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.491 s
[INFO] Finished at: 2017-08-02T16:44:34-07:00
[INFO] Final Memory: 18M/308M
[INFO] ------------------------------------------------------------------------

So mostly LGTM, I'm just a little concerned about setting the optional parameter to its default value in the Quickstart still.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lesv

lesv commented Aug 3, 2017

Copy link
Copy Markdown
Contributor

@gguuss I'll try to fix that tomorrow.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gguuss
gguuss approved these changes Aug 3, 2017
View reviewed changes

@gguuss gguuss left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I feel we may want to at some point remove the .setEnableWordTimeOffsets(false) calls but reluctantly approving for today.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gguuss
Merge branch 'master' into dalaqab_enableWordTimeOffsets_examples
3384179
@googlebot

googlebot commented Aug 3, 2017

Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Aug 3, 2017
@gguuss

gguuss commented Aug 3, 2017

Copy link
Copy Markdown
Contributor

I signed it!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gguuss
gguuss suggested changes Aug 3, 2017
View reviewed changes

@gguuss gguuss left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Will make change separately to match other samples.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@beccasaurus

beccasaurus commented Aug 4, 2017

Copy link
Copy Markdown

This can be closed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dlaqab

dlaqab commented Aug 4, 2017

Copy link
Copy Markdown
Author

why? I am not sure why this needs to be closed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@beccasaurus

beccasaurus commented Aug 4, 2017

Copy link
Copy Markdown
  1. The default for EnableWordTimeOffsets is false; it is incorrect to add it explicitly.
  2. None of the other languages do this, making Java inconsistent.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@beccasaurus
beccasaurus self-requested a review August 4, 2017 04:01
@beccasaurus

beccasaurus commented Aug 4, 2017

Copy link
Copy Markdown

The setEnableWordTimeOffsets() call in these samples is extraneous to the task these samples are intended to demonstrate. Closing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@beccasaurus beccasaurus closed this Aug 4, 2017
@beccasaurus

beccasaurus commented Aug 4, 2017

Copy link
Copy Markdown

Note: samples which demonstrate Enable Word Time Offsets were added to java-docs-samples in #787

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@beccasaurus beccasaurus Awaiting requested review from beccasaurus
1 more reviewer
@gguuss gguuss gguuss requested changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: no This human has *not* signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@dlaqab @googlebot @gguuss @lesv @beccasaurus
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.