Conversation
speech/cloud-client/transcribe.py
Outdated
|
|
||
| def transcribe_gcs(gcs_uri): | ||
| """Transcribes the audio file specified by the gcs_uri.""" | ||
| # [START authenticating_gcs] |
There was a problem hiding this comment.
Meta: seems unnecessary to chop this sample up into so many regions.
There was a problem hiding this comment.
+1, these aren't even referenced anywhere in the docs yet, I'd just stuck to the inherited convention.
speech/cloud-client/transcribe.py
Outdated
|
|
||
| # [START construct_request_gcs] | ||
| audio_sample = speech_client.sample( | ||
| None, |
There was a problem hiding this comment.
content as in there's either content or a gcs_uri
speech/cloud-client/transcribe.py
Outdated
| # [END send_request_gcs] | ||
|
|
||
|
|
||
| def main(path): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Done, moved logic to right after the args are parsed
| operation.poll() | ||
|
|
||
| if not operation.complete: | ||
| print("Operation not complete and retry limit reached.") |
There was a problem hiding this comment.
single quotes everywhere.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
I thought they were going to change this interface soon.... hmm. @dhermes?
There was a problem hiding this comment.
_OperationFuture has landed in GAX/GAPIC interfaces and we are slowly working it in
/cc @lukesneeringer
There was a problem hiding this comment.
Alright, cool, we'll catch it when @dpebot bumps our dependencies.
There was a problem hiding this comment.
I'll skip this for now.
|
|
||
|
|
||
| def test_transcribe_gcs(resource, capsys): | ||
| main('gs://cloud-samples-tests/speech/brooklyn.flac') |
There was a problem hiding this comment.
I prefer these to be in the python-docs-samples-tests bucket, provided by cloud_config.bucket.
| import re | ||
|
|
||
| from transcribe_async import main | ||
| from transcribe_async import transcribe_file, transcribe_gcs |
There was a problem hiding this comment.
Final nit: import modules, not names. Just do import transcribe_async and use transcribe_async.transcribe_file, etc.
* chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Lingqing Gan <lingqing.gan@gmail.com>
Adds examples showing transcription from a GCS URI.