-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Added setEnableWordTimeOffsets(true) to Async Recognize for a File #781
Added setEnableWordTimeOffsets(true) to Async Recognize for a File #781
Conversation
Added setEnableWordTimeOffsets(false) to Sync samples and quick start
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 am covered by my current employer (Google) |
@@ -127,6 +128,7 @@ public static void syncRecognizeGcs(String gcsUri) throws Exception, IOException | |||
.setEncoding(AudioEncoding.FLAC) | |||
.setLanguageCode("en-US") | |||
.setSampleRateHertz(16000) | |||
.setEnableWordTimeOffsets(false) |
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?
@@ -95,6 +95,7 @@ public static void syncRecognizeFile(String fileName) throws Exception, IOExcept | |||
.setEncoding(AudioEncoding.LINEAR16) | |||
.setLanguageCode("en-US") | |||
.setSampleRateHertz(16000) | |||
.setEnableWordTimeOffsets(false) |
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?
@@ -186,6 +189,11 @@ public static void asyncRecognizeFile(String fileName) throws Exception, IOExcep | |||
List<SpeechRecognitionAlternative> alternatives = result.getAlternativesList(); | |||
for (SpeechRecognitionAlternative alternative: alternatives) { | |||
System.out.printf("Transcription: %s%n", alternative.getTranscript()); | |||
for (WordInfo wordInfo: alternative.getWordsList()) { |
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.
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
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()); |
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.
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.
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.
@@ -50,6 +50,7 @@ public static void main(String... args) throws Exception { | |||
.setEncoding(AudioEncoding.LINEAR16) | |||
.setSampleRateHertz(16000) | |||
.setLanguageCode("en-US") | |||
.setEnableWordTimeOffsets(false) |
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?
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?
Fixed the tests for WordTimeOffsets
CLAs look good, thanks! |
@@ -185,7 +188,12 @@ public static void asyncRecognizeFile(String fileName) throws Exception, IOExcep | |||
for (SpeechRecognitionResult result: results) { | |||
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()); |
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);
}
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
Recognize.asyncRecognizeGcs(gcsPath); | ||
String got = bout.toString(); | ||
assertThat(got).contains("\t0.0 sec -"); | ||
assertThat(got).contains("\t0 ns"); |
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
@dlaqab Please update your branch to match master, change your new code to match the updated start seconds / end seconds code as:
Revert your change in RecognizeIT to test for actual seconds / fractions of a second. |
@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:
Checkstyle shows:
So mostly LGTM, I'm just a little concerned about setting the optional parameter to its default value in the Quickstart still. |
@gguuss I'll try to fix that tomorrow. |
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.
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 |
I signed it! |
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.
This can be closed. |
why? I am not sure why this needs to be closed |
|
The setEnableWordTimeOffsets() call in these samples is extraneous to the task these samples are intended to demonstrate. Closing. |
Note: samples which demonstrate Enable Word Time Offsets were added to java-docs-samples in #787 |
Added setEnableWordTimeOffsets(true) to Async Recognize for a File
Added setEnableWordTimeOffsets(false) to Sync samples and quick start