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

Speech GCS #784

Merged
merged 3 commits into from
Feb 7, 2017
Merged

Speech GCS #784

merged 3 commits into from
Feb 7, 2017

Conversation

gguuss
Copy link
Contributor

@gguuss gguuss commented Feb 6, 2017

Adds examples showing transcription from a GCS URI.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 6, 2017
@@ -57,13 +55,48 @@ def main(speech_file):
# [END send_request]


def transcribe_gcs(gcs_uri):
"""Transcribes the audio file specified by the gcs_uri."""
# [START authenticating_gcs]
Copy link
Contributor

Choose a reason for hiding this comment

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

Meta: seems unnecessary to chop this sample up into so many regions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1, these aren't even referenced anywhere in the docs yet, I'd just stuck to the inherited convention.


# [START construct_request_gcs]
audio_sample = speech_client.sample(
None,
Copy link
Contributor

Choose a reason for hiding this comment

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

What is None 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.

content as in there's either content or a gcs_uri

# [END send_request_gcs]


def main(path):
Copy link
Contributor

Choose a reason for hiding this comment

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

We generally don't put main functions in our samples, just place this logic below or do separate subparsers for local path and gcs path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, moved logic to right after the args are parsed

operation.poll()

if not operation.complete:
print("Operation not complete and retry limit reached.")
Copy link
Contributor

Choose a reason for hiding this comment

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

single quotes everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, I should add a module to my pavlok for such transgressions.

while retry_count > 0 and not operation.complete:
retry_count -= 1
time.sleep(2)
operation.poll()
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought they were going to change this interface soon.... hmm. @dhermes?

Copy link
Contributor

Choose a reason for hiding this comment

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

_OperationFuture has landed in GAX/GAPIC interfaces and we are slowly working it in

/cc @lukesneeringer

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, cool, we'll catch it when @dpebot bumps our dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll skip this for now.



def test_transcribe_gcs(resource, capsys):
main('gs://cloud-samples-tests/speech/brooklyn.flac')
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer these to be in the python-docs-samples-tests bucket, provided by cloud_config.bucket.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -13,11 +13,18 @@

import re

from transcribe_async import main
from transcribe_async import transcribe_file, transcribe_gcs
Copy link
Contributor

Choose a reason for hiding this comment

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

Final nit: import modules, not names. Just do import transcribe_async and use transcribe_async.transcribe_file, etc.

@theacodes theacodes merged commit faddda1 into master Feb 7, 2017
@theacodes theacodes deleted the speech-gcs branch February 7, 2017 17:53
busunkim96 pushed a commit to busunkim96/python-speech that referenced this pull request Sep 1, 2020
busunkim96 pushed a commit to googleapis/python-speech that referenced this pull request Sep 3, 2020
telpirion pushed a commit that referenced this pull request Jan 13, 2023
dandhlee pushed a commit that referenced this pull request Feb 9, 2023
telpirion pushed a commit that referenced this pull request Mar 13, 2023
atulep pushed a commit to googleapis/google-cloud-python that referenced this pull request Apr 6, 2023
atulep pushed a commit to googleapis/google-cloud-python that referenced this pull request Apr 6, 2023
atulep pushed a commit to googleapis/google-cloud-python that referenced this pull request Apr 18, 2023
parthea pushed a commit to googleapis/google-cloud-python that referenced this pull request Oct 22, 2023
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