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 — Speech transcribe async bug by ryanmats · Pull Request #688 · GoogleCloudPlatform/python-docs-samples

Conversation

@ryanmats

@ryanmats ryanmats commented Nov 29, 2016

Copy link
Copy Markdown
Contributor

Fixed bugs for Speech API GRPC sample code:

  • Issues with import statements
  • Changed default encoding choice from FLAC to LINEAR16. Added code to print error message if there was an error with the transcribe_async long running operation. (As per Jerjou's suggestion)
  • Added tests for GRPC transcribe and transcribe_async samples. Code uploads the audio.raw blob to the default CLOUD_STORAGE_BUCKET, tests sample code using this blob's URI, and deletes the blob at the end.

Sorry, something went wrong.

Uh oh!

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

All reactions
ryanmats added 3 commits November 28, 2016 18:28
@ryanmats
Fixed Speech API GRPC sample import issues, added tests
8a7355e
@ryanmats
Merge branch 'master' of https://github.com/GoogleCloudPlatform/pytho…
0a3878e
…n-docs-samples into speech-transcribe-async-bug
@ryanmats
Revised tests for speech grpc samples to upload sample audio and use it
e4c1f71
@ryanmats ryanmats assigned theacodes Nov 29, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 29, 2016
@ryanmats ryanmats assigned jerjou and puneith Nov 29, 2016
@theacodes

theacodes commented Nov 29, 2016 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

@ryanmats all of the speech test resources should be pre-uploaded, so there should be no need to upload/delete the blob every time (see scripts/prepare-testing-project.sh L47).

All reactions

Sorry, something went wrong.

Uh oh!

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

@theacodes

theacodes commented Nov 29, 2016

Copy link
Copy Markdown
Contributor

Other than the note about the tests, this LGTM. @jerjou can you take a quick look before we merge?

All reactions

Sorry, something went wrong.

Uh oh!

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

jerjou
jerjou reviewed Nov 29, 2016
View reviewed changes
Comment thread speech/grpc/transcribe_async.py Outdated
if operation.error.message:
print("")
print("Operation error:")
print(operation.error)

@jerjou jerjou Nov 29, 2016

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.

What? Jon didn't wasn't like, "Please use single quotes for strings"?? WHO ARE YOU AND WHAT HAVE YOU DONE TO @jonparrott ?!? :)

I'd just combine this into one string, for brevity:

print('\nOperation error:\n{}'.format(operation.error))

We should be paid proportional to like, the inverse of lines of code :) Except then we'd be incentivized to not write any code at all... hm...

Sorry, something went wrong.

Uh oh!

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

All reactions

@theacodes theacodes Nov 29, 2016

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 blame my lack of sleep.

Sorry, something went wrong.

Uh oh!

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

All reactions
jerjou
jerjou reviewed Nov 29, 2016
View reviewed changes
Comment thread speech/grpc/transcribe_async_test.py Outdated
assert re.search(r'how old is the Brooklyn Bridge', out, re.DOTALL | re.I)

# Delete audio file from storage bucket
blob.delete()

@jerjou jerjou Nov 29, 2016

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.

+1 just have the asset on the GCS bucket already :)

But for future reference, if you're going to do this, should probably put this in a context manager (so that eg if the assertion fails, the blob is still deleted), or in one of those fancy pytest fixtures (same idea)

Sorry, something went wrong.

Uh oh!

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

All reactions
@jerjou

jerjou commented Nov 29, 2016

Copy link
Copy Markdown
Contributor

Minor comments. Mainly just Jon's thing :) Otherwise, looks good.

All reactions

Sorry, something went wrong.

Uh oh!

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

ryanmats added 2 commits November 29, 2016 13:53
@ryanmats
Made changes based on Jon/Jerjou's code review
695cd78
@ryanmats
Merge branch 'master' of https://github.com/GoogleCloudPlatform/pytho…
d3fee87
…n-docs-samples into speech-transcribe-async-bug
@ryanmats

ryanmats commented Nov 29, 2016

Copy link
Copy Markdown
Contributor Author

@jonparrott @jerjou I pushed the changes based on your code review comments. Also updated the speech sample audio filename in scripts/prepare-testing-project.sh.

All reactions

Sorry, something went wrong.

Uh oh!

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

theacodes
theacodes reviewed Nov 29, 2016
View reviewed changes
Comment thread scripts/prepare-testing-project.sh

echo "Creating speech resources."
gsutil cp speech/api/resources/audio.flac gs://$GCLOUD_PROJECT/speech/
gsutil cp speech/api-client/resources/audio.raw gs://$GCLOUD_PROJECT/speech/

@theacodes theacodes Nov 29, 2016

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.

Are there other tests that depend on audio.flac?

Sorry, something went wrong.

Uh oh!

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

All reactions

@ryanmats ryanmats Nov 29, 2016

Copy link
Copy Markdown
Contributor 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.

Just searched through the repo and it doesn't look like there are. Also, the audio.flac file doesn't exist in that directory anymore.

Sorry, something went wrong.

Uh oh!

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

All reactions

@jerjou jerjou Nov 29, 2016

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.

Might want to set -e on the top of this file, so that the build will fail in the future when this happens..

Sorry, something went wrong.

Uh oh!

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

All reactions

@jerjou jerjou Nov 29, 2016

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.

(doesn't have to be in this CL - just saying it'd probably be a good idea..)

Sorry, something went wrong.

Uh oh!

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

All reactions

@ryanmats ryanmats Nov 30, 2016

Copy link
Copy Markdown
Contributor 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.

changed in this PR

Sorry, something went wrong.

Uh oh!

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

All reactions
theacodes
theacodes reviewed Nov 29, 2016
View reviewed changes
Comment thread speech/grpc/transcribe_async_test.py Outdated
def test_main(resource, capsys):

# Run the transcribe_async sample on audio.raw, verify correct results
speech_storage_uri = 'gs://' + os.environ.get('CLOUD_STORAGE_BUCKET')

@theacodes theacodes Nov 29, 2016

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.

Use the cloud_config or remote_resource fixture.

Sorry, something went wrong.

Uh oh!

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

All reactions
ryanmats added 2 commits November 29, 2016 15:44
@ryanmats
Changed tests to use cloud_config for speech_storage_uri
111eb09
@ryanmats
Added set -e to prepare-testing-project.sh script as per Jerjou's com…
6f6134b
…ments
theacodes
theacodes reviewed Nov 30, 2016
View reviewed changes
Comment thread conftest.py Outdated
@pytest.fixture(scope='session')
def cloud_config():
"""Provides a configuration object as a proxy to environment variables."""
speech_storage_uri = 'gs://' + os.environ.get('CLOUD_STORAGE_BUCKET')

@theacodes theacodes Nov 30, 2016

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.

@ryanmats there's already the storage_bucket thing here, there isn't any need to add another one.

Sorry, something went wrong.

Uh oh!

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

All reactions

@ryanmats ryanmats Nov 30, 2016

Copy link
Copy Markdown
Contributor 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.

fixed

Sorry, something went wrong.

Uh oh!

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

All reactions
ryanmats added 3 commits November 30, 2016 12:31
@ryanmats
Merge branch 'master' of https://github.com/GoogleCloudPlatform/pytho…
fb9d2b6
…n-docs-samples into speech-transcribe-async-bug
@ryanmats
Modified cloud_config for speech grpc tests
bcbe0ab
@ryanmats
Merge branch 'master' of https://github.com/GoogleCloudPlatform/pytho…
2322792
…n-docs-samples into speech-transcribe-async-bug
theacodes
theacodes reviewed Nov 30, 2016
View reviewed changes
Comment thread speech/grpc/transcribe_async_test.py Outdated
def test_main(resource, capsys, cloud_config):

# Run the transcribe sample on audio.raw, verify correct results
speech_storage_uri = 'gs://' + cloud_config.storage_bucket

@theacodes theacodes Nov 30, 2016

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.

Lol okay, I promise I'm not doing this just to annoy you:

Prefer:

storage_uri = 'gs://{}/speech/audio.raw'.format(cloud_config.storage_bucket)

(Here and in the other test file).

Sorry, something went wrong.

Uh oh!

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

All reactions

@ryanmats ryanmats Nov 30, 2016

Copy link
Copy Markdown
Contributor 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.

fixed

Sorry, something went wrong.

Uh oh!

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

All reactions
@ryanmats
Fixed formatting issues with storage_uri string
01a1603
@theacodes
theacodes merged commit ff54b24 into master Nov 30, 2016
@theacodes
theacodes deleted the speech-transcribe-async-bug branch November 30, 2016 21:18
Linchin pushed a commit that referenced this pull request Aug 18, 2025
@gcf-owl-bot
chore: [autoapprove] Update black and isort to latest versions (#688
2dc8510
)

Source-Link: googleapis/synthtool@0c7b033
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:08e34975760f002746b1d8c86fdc90660be45945ee6d9db914d1508acdf9a547

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
@Linchin Linchin mentioned this pull request Aug 18, 2025
chore: migrate handwritten samples from googleapis/python-bigquery-storage #13543
Merged
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers
@theacodes theacodes theacodes left review comments
@jerjou jerjou jerjou left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

@theacodes theacodes

@jerjou jerjou

@puneith puneith

Labels

cla: yes This human has 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

@ryanmats @theacodes @jerjou @googlebot @puneith
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.