Add speech asynchronous recognize support.#2426
Add speech asynchronous recognize support.#2426daspecster merged 4 commits intogoogleapis:masterfrom
Conversation
| config['profanityFilter'] = profanity_filter | ||
| if speech_context is not None: | ||
| config['speechContext'] = {'phrases': speech_context} | ||
| def _build_request_data(content, source_uri, encoding, sample_rate, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
dhermes
left a comment
There was a problem hiding this comment.
I'm not 100% but I think there is a utility in google.protobuf for parsing a JSON version of a protobuf message type (here it is Operation)
docs/speech-usage.rst
Outdated
| >>> operation.complete | ||
| True | ||
| >>> operation.results[0]['alternatives'][0]['transcript'] | ||
| "how old is the Brooklyn Bridge" |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
docs/speech-usage.rst
Outdated
| ... operation.poll() # API call | ||
| >>> operation.complete | ||
| True | ||
| >>> operation.results[0]['alternatives'][0]['transcript'] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| AMR_WB = 'AMR_WB' | ||
| """AMR_WB encoding type.""" | ||
| from google.cloud.speech.encoding import Encoding | ||
| from google.cloud.speech.operation import Operation |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| config['profanityFilter'] = profanity_filter | ||
| if speech_context is not None: | ||
| config['speechContext'] = {'phrases': speech_context} | ||
| def _build_request_data(content, source_uri, encoding, sample_rate, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google/cloud/speech/operation.py
Outdated
| from google.cloud._helpers import _rfc3339_to_datetime | ||
|
|
||
|
|
||
| class Operation(object): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
unit_tests/speech/_fixtures.py
Outdated
| } | ||
| ] | ||
| } | ||
| ] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
unit_tests/speech/_fixtures.py
Outdated
| ] | ||
| } | ||
| ] | ||
| } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
unit_tests/speech/_fixtures.py
Outdated
| 'startTime': '2016-09-22T17:52:25.536964Z', | ||
| 'lastUpdateTime': '2016-09-22T17:52:27.802902Z' | ||
| }, | ||
| 'done': False |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
unit_tests/speech/_fixtures.py
Outdated
| 'google.cloud.speech.v1beta1.AsyncRecognizeMetadata'), | ||
| 'progressPercent': 27, | ||
| 'startTime': '2016-09-22T17:52:25.536964Z', | ||
| 'lastUpdateTime': '2016-09-22T17:52:27.802902Z' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| """The version of the API, used in building the API call's URL.""" | ||
|
|
||
| API_URL_TEMPLATE = '{api_base_url}/{api_version}/speech:{path}' | ||
| API_URL_TEMPLATE = '{api_base_url}/{api_version}/{path}' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@dhermes was there supposed to be a link in here?
|
| encoding, | ||
| self.SAMPLE_RATE) | ||
| self.assertIsInstance(operation, Operation) | ||
| self.assertFalse(operation.complete) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
docs/speech-usage.rst
Outdated
| ... operation.poll() # API call | ||
| >>> operation.complete | ||
| True | ||
| >>> operation.results[0]['alternatives'][0]['transcript'] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| """The version of the API, used in building the API call's URL.""" | ||
|
|
||
| API_URL_TEMPLATE = '{api_base_url}/{api_version}/speech:{path}' | ||
| API_URL_TEMPLATE = '{api_base_url}/{api_version}/{path}' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
7942a39 to
92b2b89
Compare
|
@tseaver I think I got all the things you mentioned. LMKWYT |
unit_tests/speech/test_operation.py
Outdated
| self._requested = [] | ||
|
|
||
| def api_request(self, method, path): | ||
| self._requested.append({'method': method, 'path': path}) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@daspecster Should be OK to merge if you can tweak the assertions for the operations tests (see above). |
Add speech asynchronous recognize support.
Add speech asynchronous recognize support.
Add speech asynchronous recognize support.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery-dataframes/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v0.7.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:e7cc6823efb073a8a26e7cefdd869f12ec228abfbd2a44aa9a7eacc284023677 <details><summary>bigframes: 2.35.0</summary> ## [2.35.0](googleapis/python-bigquery-dataframes@v2.34.0...v2.35.0) (2026-02-07) ### Features * Add bigframes.pandas.col with basic operators (#2405) ([12741677](googleapis/python-bigquery-dataframes@12741677)) * remove redundant "started." messages from progress output (#2440) ([2017cc2f](googleapis/python-bigquery-dataframes@2017cc2f)) * add bigframe.bigquery.load_data function (#2426) ([4b0f13b2](googleapis/python-bigquery-dataframes@4b0f13b2)) * Disable progress bars in Anywidget mode (#2444) ([4e2689a1](googleapis/python-bigquery-dataframes@4e2689a1)) * add bigquery.ai.generate_text function (#2433) ([5bd0029a](googleapis/python-bigquery-dataframes@5bd0029a)) * Disable progress bars in Anywidget mode to reduce notebook clutter (#2437) ([853240da](googleapis/python-bigquery-dataframes@853240da)) * Add a bigframes cell magic for ipython (#2395) ([e6de52de](googleapis/python-bigquery-dataframes@e6de52de)) * add `bigframes.bigquery.ai.generate_embedding` (#2343) ([e91536c8](googleapis/python-bigquery-dataframes@e91536c8)) ### Bug Fixes * always display the results in the `%%bqsql` cell magics output (#2439) ([2d973b54](googleapis/python-bigquery-dataframes@2d973b54)) * exlcude gcsfs 2026.2.0 (#2445) ([311de31e](googleapis/python-bigquery-dataframes@311de31e)) * suppress JSONDtypeWarning in Anywidget mode and clean up progress output (#2441) ([e0d185ad](googleapis/python-bigquery-dataframes@e0d185ad)) ### Documentation * fix cast method shown on public docs (#2436) ([ad0f33c6](googleapis/python-bigquery-dataframes@ad0f33c6)) </details>
Add support for Speech API long running operations.