GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Speech transcribe async bug by ryanmats · Pull Request #688 · GoogleCloudPlatform/python-docs-samples Conversation
Contributor
Fixed bugs for Speech API GRPC sample code:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
@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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Other than the note about the tests, this LGTM. @jerjou can you take a quick look before we merge? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if operation.error.message: | ||
| print("") | ||
| print("Operation error:") | ||
| print(operation.error) |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
| assert re.search(r'how old is the Brooklyn Bridge', out, re.DOTALL | re.I) | ||
|
|
||
| # Delete audio file from storage bucket | ||
| blob.delete() |
There was a problem 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.
There was an error while loading. Please reload this page.
|
Minor comments. Mainly just Jon's thing :) Otherwise, looks good. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…n-docs-samples into speech-transcribe-async-bug
|
@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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| 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/ |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
changed in this PR
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| 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') |
There was a problem 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.
There was an error while loading. Please reload this page.
| @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') |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
fixed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…n-docs-samples into speech-transcribe-async-bug
…n-docs-samples into speech-transcribe-async-bug
| 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 |
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
fixed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
) 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>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.