| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Thank you very much for the patch -- it is very well done!
Sorry, something went wrong.
| bucket = client.get_bucket('<your-bucket-name>') | ||
| blob = bucket.blob('my-test-file.txt') | ||
| blob.upload_from_string('this is test content!') | ||
|
|
|
|
||
| At this moment we only support one method of the Speech API: | ||
|
|
||
| - `syncrecognize`_ |
|
|
||
| - `syncrecognize`_ | ||
|
|
||
| Synchronous Recognize |
| --------------------- | ||
|
|
||
| The :meth:`~google.cloud.speech.Client.syncrecognize` method | ||
| does speech to text on a file and returns the text |
|
|
||
| The :meth:`~google.cloud.speech.Client.syncrecognize` method | ||
| does speech to text on a file and returns the text | ||
| as a :class:`list` of tuples dicts (each containing a transcript an a confidence value). |
| for param_name, param in required_params: | ||
| if param is None: | ||
| message = '%r cannot be None' % (param_name) | ||
| raise ValueError(message) |
| if param is None: | ||
| message = '%r cannot be None' % (param_name) | ||
| raise ValueError(message) | ||
| config = dict(required_params) |
| ('maxAlternatives', max_alternatives), | ||
| ('profanityFilter', profanity_filter)]: | ||
| if param is not None: | ||
| config[param_name] = param |
| sample_rate, | ||
| max_alternatives=2, | ||
| speech_context=hints) | ||
| self.assertEqual(speechrecognition_result[0]["transcript"], 'hello') |
| with self.assertRaises(ValueError): | ||
| client.syncrecognize(None, None, None, None) | ||
| with self.assertRaises(ValueError): | ||
| client.syncrecognize(None, "uri", None, None) |
|
Thank you for your feedback! I have implemented your suggestions, except for the additional examples with extra arguments in the docs. I will try to finish this tomorrow. |
Sorry, something went wrong.
| supported, which must be specified in the following | ||
| format: gs://bucket_name/object_name | ||
| :type content: bytes | ||
| :param content: Byte stream of audio. |
There was a problem hiding this comment.
Awesome! Thank you!
Sorry, something went wrong.
| """Client to bundle configuration needed for API requests. | ||
|
|
||
| :type project: str | ||
| :param project: the project which the client acts on behalf of. Will be |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Basic client for Google Cloud Speech API.""" |
| bucket = client.get_bucket('<your-bucket-name>') | ||
| blob = bucket.blob('my-test-file.txt') | ||
| blob.upload_from_string('this is test content!') | ||
| blob.upload_from_string('this is test content!') No newline at end of file |
| .. code-block:: python | ||
|
|
||
| >>> alternatives = client.sync_recognize(None,"gs://my-bucket/recording.flac", | ||
| ... "FLAC", 16000, max_alternatives=2): |
| >>> for alternative in alternatives: | ||
| ... print('=' * 20) | ||
| ... print(' transcript: %s' % (alternative["transcript"],)) | ||
| ... print(' confidence: %s' % (alternative["confidence"],)) |
| ... print(' confidence: %s' % (alternative["confidence"],)) | ||
| ==================== | ||
| transcript: Hello, this is a test | ||
| confidence: 0.81 |
|
|
||
| """Google Cloud Speech API wrapper.""" | ||
|
|
||
| from google.cloud.speech.client import Client, Encoding |
| response = client.sync_recognize(_AUDIO_CONTENT, | ||
| encoding, | ||
| self.SAMPLE_RATE, | ||
| language_code="EN", |
|
|
||
| self.assertEqual(REQUEST, | ||
| client.connection._requested[0]['data']) | ||
| self.assertEqual(response[0]["transcript"], 'hello') |
| }, | ||
| "audio": { | ||
| "content": _B64_AUDIO_CONTENT | ||
| } |
|
|
||
| self.assertEqual(REQUEST, | ||
| client.connection._requested[0]['data']) | ||
| self.assertEqual(response[0]["transcript"], 'hello') |
|
|
||
| class _Credentials(object): | ||
|
|
||
| _scopes = ('https://www.googleapis.com/auth/cloud-platform') |
|
@Fematich Really great work! Especially impressed that you have Travis 100% green on your first try! |
Sorry, something went wrong.
|
I have updated the code (included source_uri again and updated formatting/unit_tests). |
Sorry, something went wrong.
|
|
||
| :type source_uri: str | ||
| :param source_uri: URI that points to a file that contains audio | ||
| data bytes as specified in RecognitionConfig. |
| between 0 and 1. | ||
| """ | ||
|
|
||
| if (content is None) and (source_uri is None): |
| raise ValueError('content and source_uri cannot be both equal to\ | ||
| None') | ||
|
|
||
| if (content is not None) and (source_uri is not None): |
| """ | ||
|
|
||
| if (content is None) and (source_uri is None): | ||
| raise ValueError('content and source_uri cannot be both equal to\ |
| None') | ||
|
|
||
| if (content is not None) and (source_uri is not None): | ||
| raise ValueError('content and source_uri cannot be both different from\ |
| if sample_rate is None: | ||
| raise ValueError('sample_rate cannot be None') | ||
|
|
||
| if content is not None: |
| } | ||
|
|
||
| SYNC_RECOGNIZE_EMPTY_RESPONSE = { | ||
| 'results': [] |
|
|
||
| import unittest | ||
|
|
||
| _AUDIO_SOURCE_URI = 'gs://sample-bucket/sample-recording.flac' |
|
I'm going to merge as-is. I'll send a PR addressing most of my concerns. Remaining issues outside of that PR will be: |
Sorry, something went wrong.
|
@Fematich Thanks for your great work! We decided to go ahead and merge to speed up the process. We'd like to get this library feature-complete ASAP so we didn't want the review cycle to slow us down on getting the first chunks in. From here, a person working on this library full-time will take it to the finish line. You were great! |
Sorry, something went wrong.
|
Thank you it was a pleasure :-)! |
Sorry, something went wrong.
Updates from #2344 for speech API.
Updates from googleapis#2344 for speech API.
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:c8612d3fffb3f6a32353b2d1abd16b61e87811866f7ec9d65b59b02eb452a620 <details><summary>google-cloud-bigquery: 3.39.0</summary> ## [3.39.0](googleapis/python-bigquery@v3.38.0...v3.39.0) (2025-12-12) ### Features * adds support for Python runtime 3.14 (#2322) ([6065e14c](googleapis/python-bigquery@6065e14c)) * Add ExternalRuntimeOptions to BigQuery routine (#2311) ([fa76e310](googleapis/python-bigquery@fa76e310)) ### Bug Fixes * remove ambiguous error codes from query retries (#2308) ([8bbd3d01](googleapis/python-bigquery@8bbd3d01)) * include `io.Base` in the `PathType` (#2323) ([b11e09cb](googleapis/python-bigquery@b11e09cb)) * honor custom `retry` in `job.result()` (#2302) ([e118b029](googleapis/python-bigquery@e118b029)) ### Documentation * remove experimental annotations from GA features (#2303) ([1f1f9d41](googleapis/python-bigquery@1f1f9d41)) </details> Co-authored-by: Daniel Sanche <d.sanche14@gmail.com>
| Back | FazBrowse Home | New Git URL |
I have made a basic implementation of Speech API.
This currently only supports syncrecognize from the REST-API.
I think I followed all the contribution guidelines:
However, this is my first contribution, so in case I missed something, please let me know and I will see how to fix it!