| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| import monitoring | ||
| import pubsub | ||
| import storage | ||
| import speech |
| import io | ||
| from google.cloud import speech | ||
| client = speech.Client() | ||
| file_name = 'system_tests/data/hello.wav' |
| client = speech.Client() | ||
| file_name = 'system_tests/data/hello.wav' | ||
|
|
||
| with io.open(file_name, 'rb') as file_obj: |
| def test_sync_recognize_gcs_file(self): | ||
| from google.cloud import speech | ||
| client = speech.Client() | ||
| source_uri = 'gs://ferrous-arena-my-test-bucket/hello.wav' |
|
|
||
| def test_sync_recognize_gcs_file(self): | ||
| from google.cloud import speech | ||
| client = speech.Client() |
| speech_context=['Google', 'cloud']) | ||
| self.assertEqual(res[0].transcript, | ||
| 'hello thank you for using Google Cloud platform') | ||
| self.assertEqual(len(res), 1) |
| sample = client.sample(content=file_obj.read(), | ||
| encoding=speech.Encoding.LINEAR16, | ||
| sample_rate=16000) | ||
| res = client.sync_recognize(sample, |
| max_alternatives=2, | ||
| profanity_filter=True, | ||
| speech_context=['Google', 'cloud']) | ||
| self.assertEqual(res[0].transcript, |
| speech_context=['Google', 'cloud']) | ||
| self.assertEqual(res[0].transcript, | ||
| 'hello thank you for using Google Cloud platform') | ||
| self.assertEqual(len(res), 2) |
|
@dhermes, I had to change how the transcript and confidence values are accessed. I think I was running this before with a different version installed so I had them as properties. The result for sync _recognize is currently a dictionary. |
Sorry, something went wrong.
It's tough to review a moving target. Are the tested methods done and checked in? If yes, then why the out-of-sync issue? |
Sorry, something went wrong.
| max_alternatives=1) | ||
| self.assertEqual(result[0]['transcript'], | ||
| 'hello thank you for using Google Cloud platform') | ||
| self.assertGreater(result[0]['confidence'], .90) |
| result = self._make_sync_request(content=file_obj.read(), | ||
| max_alternatives=2) | ||
|
|
||
| self.assertEqual(result[0]['transcript'], |
| def test_sync_recognize_gcs_file(self): | ||
| import os | ||
|
|
||
| source_uri = os.getenv('SPEECH_GCS_URI') |
| return result | ||
|
|
||
| def test_sync_recognize_local_file(self): | ||
| file_name = 'system_tests/data/hello.wav' |
|
|
||
| self.assertEqual(result[0]['transcript'], | ||
| 'hello thank you for using Google Cloud platform') | ||
| self.assertGreater(result[0]['confidence'], .90) |
|
|
||
| def _make_sync_request(self, content=None, source_uri=None, | ||
| max_alternatives=None): | ||
| from google.cloud.speech.encoding import Encoding |
|
|
||
| class Config(object): | ||
| """Run-time configuration to be modified at set-up. | ||
| This is a mutable stand-in to allow test set-up to modify |
| max_alternatives=max_alternatives, | ||
| profanity_filter=True, | ||
| speech_context=['Google', | ||
| 'cloud']) |
| return result | ||
|
|
||
| def _check_best_results(self, results): | ||
| from google.cloud.speech.transcript import Transcript |
|
|
||
| def test_sync_recognize_local_file(self): | ||
| import os | ||
| from google.cloud.speech.transcript import Transcript |
| import os | ||
| from google.cloud.speech.transcript import Transcript | ||
|
|
||
| file_name = os.path.join('system_tests', 'data', 'hello.wav') |
| self.assertIsInstance(second_alternative, Transcript) | ||
| self.assertEqual(second_alternative.transcript, | ||
| 'thank you for using Google Cloud platform') | ||
| self.assertEqual(second_alternative.confidence, 0.0) |
| self._check_best_results(results) | ||
| self.assertIsInstance(second_alternative, Transcript) | ||
| self.assertEqual(second_alternative.transcript, | ||
| 'thank you for using Google Cloud platform') |
| with open(file_name, 'rb') as file_obj: | ||
| blob.upload_from_file(file_obj) | ||
|
|
||
| # source_uri = os.getenv('SPEECH_GCS_URI') |
| def test_sync_recognize_gcs_file(self): | ||
| import os | ||
|
|
||
| file_name = os.path.join('system_tests', 'data', 'hello.wav') |
|
|
||
| file_name = os.path.join('system_tests', 'data', 'hello.wav') | ||
| bucket_name = Config.TEST_BUCKET.name | ||
| blob_name = 'document.txt' |
| CLIENT = None | ||
| TEST_BUCKET = None | ||
| AUDIO_FILE = os.path.join(os.path.dirname(__file__), 'data', 'hello.wav') | ||
| ASSERT_TEXT = 'thank you for using Google Cloud platform' |
| """ | ||
| CLIENT = None | ||
| TEST_BUCKET = None | ||
| AUDIO_FILE = os.path.join(os.path.dirname(__file__), 'data', 'hello.wav') |
| self._check_best_results(results) | ||
| self.assertIsInstance(second_alternative, Transcript) | ||
| self.assertEqual(second_alternative.transcript, Config.ASSERT_TEXT) | ||
| self.assertEqual(second_alternative.confidence, 0.0) |
…stem-tests Add Speech sync recognize system test.
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:160860d189ff1c2f7515638478823712fa5b243e27ccc33a2728669fa1e2ed0c <details><summary>bigframes: 2.39.0</summary> ## [2.39.0](google/bigframes@v2.38.0...v2.39.0) (2026-03-31) ### Features * add `df.bigquery.ai.forecast` method to pandas dataframe accessor (#2518) ([1126cec9](google/bigframes@1126cec9)) * support full round-trip persistence for multimodal reference cols (#2511) ([494a0a11](google/bigframes@494a0a11)) * expose DataFrame.bigquery in both pandas and bigframes DataFrames (#2533) ([69fe3176](google/bigframes@69fe3176)) ### Bug Fixes * to_gbq may swap data columns when replace table (#2532) ([17ecc65e](google/bigframes@17ecc65e)) * handle aggregate operations on empty selections (#2510) ([34fb5daa](google/bigframes@34fb5daa)) * Localize BigQuery log suppression for gbq.py (#2541) ([af49ca29](google/bigframes@af49ca29)) * Respect remote function config changes even if logic unchanged (#2512) ([b9524284](google/bigframes@b9524284)) * support melting empty DataFrames without crashing (#2509) ([e8c4603](google/bigframes@e8c46032)) ### Performance Improvements * Make executor data uploads async internally (#2529) ([96597f0b](google/bigframes@96597f0b)) ### Documentation * gemini retouch of the index page for seo (#2514) ([2e5311e2](google/bigframes@2e5311e2)) * Rename Blob column references to ObjectRef column (#2535) ([44e0ffd9](google/bigframes@44e0ffd9)) </details>
This reverts commit abf6047.
This reverts commit 416c678.
| Back | FazBrowse Home | New Git URL |
First swing at system tests for sync_recognize().
The GCS test is using a file(hello.wav) on my bucket so we'll probably want to upload that to the testing account.