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

Multi Channel #1561

Merged
merged 5 commits into from
Jul 13, 2018
Merged

Multi Channel #1561

merged 5 commits into from
Jul 13, 2018

Conversation

happyhuman
Copy link
Contributor

Implemented the multi channel sample

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 12, 2018
@happyhuman
Copy link
Contributor Author

@nnegrey , @dizcology , @tswast can you please review this PR?

@@ -157,6 +158,35 @@ def transcribe_file_with_diarization(path):
# [END speech_transcribe_diarization]


# [START speech_transcribe_multichannel]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: per our snippet rubric snippets should show concrete values for variables whenever possible. I recommend moving this region tag into the function rather than outside of it. The snippet should also show the necessary imports.

Example:

https://github.com/GoogleCloudPlatform/google-cloud-python/blob/b022ca9d2176411c1d0a528da9ba820d24f0630e/docs/bigquery/snippets.py#L180-L181

Note: we comment out the import and client creation in BigQuery because we have ~100 snippets and repeating auth every time slows down the tests substantially, but this is not necessary if there are only a few snippets as there are here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good observation @tswast. However all other samples in the speech directory seem to have the region tags outside the functions. So, if we move the region tags inside the function for this sample, it will look inconsistent with the rest of the samples for speech. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Better to follow the new standard than to follow the old one. Eventually we will convert all samples to the new standard (starting with translate).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point @tswast, I moved the region tags in beta_snippets.py inside the functions

@@ -157,6 +158,35 @@ def transcribe_file_with_diarization(path):
# [END speech_transcribe_diarization]


# [START speech_transcribe_multichannel]
def transcribe_file_with_multichannel(speech_file):
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend showing an example value for speech_file within the snippet.

# [START speech_transcribe_multichannel]
from google.cloud import speech
client = speech.SpeechClient()

# TODO(developer): Uncomment and set to a path to your audio file.
# speech_file = 'path/to/file.wav'
...

Example:

https://github.com/GoogleCloudPlatform/google-cloud-python/blob/b022ca9d2176411c1d0a528da9ba820d24f0630e/docs/bigquery/snippets.py#L183

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I added it (and also for Diarization sample which was merged in yesterday).

Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

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

A couple nits. LGTM after they are addressed (either by renaming the argument or updating the comment)

client = speech.SpeechClient()

# TODO(developer): Uncomment and set to a path to your audio file.
# speech_file = 'path/to/file.wav'
Copy link
Contributor

Choose a reason for hiding this comment

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

In this sample the variable appears to be called "path".

client = speech.SpeechClient()

# TODO(developer): Uncomment and set to a path to your audio file.
# speech_file = 'path/to/file.wav'
Copy link
Contributor

Choose a reason for hiding this comment

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

In this sample the variable appears to be called "path".

client = speech.SpeechClient()

# TODO(developer): Uncomment and set to a path to your audio file.
# speech_file = 'path/to/file.wav'
Copy link
Contributor

Choose a reason for hiding this comment

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

In this sample the variable appears to be called "path".

client = speech.SpeechClient()

# TODO(developer): Uncomment and set to a path to your audio file.
# speech_file = 'path/to/file.wav'
Copy link
Contributor

Choose a reason for hiding this comment

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

In this sample the variable appears to be called "path".

@happyhuman happyhuman merged commit 1fe1ca8 into master Jul 13, 2018
@happyhuman happyhuman deleted the multichannel branch July 13, 2018 23:17
"""Transcribe the given audio file using an enhanced model."""
# [START speech_transcribe_file_with_enhanced_model]
Copy link
Member

Choose a reason for hiding this comment

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

I see this is a different way to use the region tags than commonly done in Python so far. Is this the convention going forward?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is a result of our most recent samples rubric working group. I'll be presenting on this in a team meeting post-Next.

print('-' * 20)
print('First alternative of result {}'.format(i))
print(u'Transcript: {}'.format(alternative.transcript))
print(u'Channel Tag: {}'.format(result.channel_tag))
Copy link
Member

Choose a reason for hiding this comment

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

what happens where there are multiple channels? do we get the output from all channels into the same alternative? or does the output from the second channel go to the second alternative, and so on?

os.path.join(RESOURCES, 'Google_Gnome.wav'))
out, err = capsys.readouterr()

assert 'OK Google stream stranger things from Netflix to my TV' in out
Copy link
Member

Choose a reason for hiding this comment

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

this is a single channel audio file, use an actual multichannel test file.

busunkim96 pushed a commit to busunkim96/python-speech that referenced this pull request Sep 1, 2020
* Implemented the multi channel sample

* Added parameter comment

* Moved region tags inside the functions

* Deleted the extra line

* Fixing typos
busunkim96 pushed a commit to googleapis/python-speech that referenced this pull request Sep 3, 2020
* Implemented the multi channel sample

* Added parameter comment

* Moved region tags inside the functions

* Deleted the extra line

* Fixing typos
telpirion pushed a commit that referenced this pull request Jan 13, 2023
* Implemented the multi channel sample

* Added parameter comment

* Moved region tags inside the functions

* Deleted the extra line

* Fixing typos
dandhlee pushed a commit that referenced this pull request Feb 9, 2023
* Implemented the multi channel sample

* Added parameter comment

* Moved region tags inside the functions

* Deleted the extra line

* Fixing typos
telpirion pushed a commit that referenced this pull request Mar 13, 2023
* Implemented the multi channel sample

* Added parameter comment

* Moved region tags inside the functions

* Deleted the extra line

* Fixing typos
atulep pushed a commit to googleapis/google-cloud-python that referenced this pull request Apr 6, 2023
* Implemented the multi channel sample

* Added parameter comment

* Moved region tags inside the functions

* Deleted the extra line

* Fixing typos
atulep pushed a commit to googleapis/google-cloud-python that referenced this pull request Apr 6, 2023
* Implemented the multi channel sample

* Added parameter comment

* Moved region tags inside the functions

* Deleted the extra line

* Fixing typos
atulep pushed a commit to googleapis/google-cloud-python that referenced this pull request Apr 18, 2023
* Implemented the multi channel sample

* Added parameter comment

* Moved region tags inside the functions

* Deleted the extra line

* Fixing typos
parthea pushed a commit to googleapis/google-cloud-python that referenced this pull request Oct 22, 2023
* Implemented the multi channel sample

* Added parameter comment

* Moved region tags inside the functions

* Deleted the extra line

* Fixing typos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants