Uh oh!
There was an error while loading. Please reload this page.
Add Speech sync recognize system test. - #2547
Conversation
| import monitoring | ||
| import pubsub | ||
| import storage | ||
| import speech |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| import io | ||
| from google.cloud import speech | ||
| client = speech.Client() | ||
| file_name = 'system_tests/data/hello.wav' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| client = speech.Client() | ||
| file_name = 'system_tests/data/hello.wav' | ||
| with io.open(file_name, 'rb') as file_obj: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def test_sync_recognize_gcs_file(self): | ||
| from google.cloud import speech | ||
| client = speech.Client() |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| speech_context=['Google', 'cloud']) | ||
| self.assertEqual(res[0].transcript, | ||
| 'hello thank you for using Google Cloud platform') | ||
| self.assertEqual(len(res), 1) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| sample = client.sample(content=file_obj.read(), | ||
| encoding=speech.Encoding.LINEAR16, | ||
| sample_rate=16000) | ||
| res = client.sync_recognize(sample, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| max_alternatives=2, | ||
| profanity_filter=True, | ||
| speech_context=['Google', 'cloud']) | ||
| self.assertEqual(res[0].transcript, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| speech_context=['Google', 'cloud']) | ||
| self.assertEqual(res[0].transcript, | ||
| 'hello thank you for using Google Cloud platform') | ||
| self.assertEqual(len(res), 2) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
daspecster
commented
Oct 18, 2016
@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 |
dhermes
commented
Oct 20, 2016
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? |
| max_alternatives=1) | ||
| self.assertEqual(result[0]['transcript'], | ||
| 'hello thank you for using Google Cloud platform') | ||
| self.assertGreater(result[0]['confidence'], .90) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| result = self._make_sync_request(content=file_obj.read(), | ||
| max_alternatives=2) | ||
| self.assertEqual(result[0]['transcript'], |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def test_sync_recognize_gcs_file(self): | ||
| import os | ||
| source_uri = os.getenv('SPEECH_GCS_URI') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| return result | ||
| def test_sync_recognize_local_file(self): | ||
| file_name = 'system_tests/data/hello.wav' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| self.assertEqual(result[0]['transcript'], | ||
| 'hello thank you for using Google Cloud platform') | ||
| self.assertGreater(result[0]['confidence'], .90) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def _make_sync_request(self, content=None, source_uri=None, | ||
| max_alternatives=None): | ||
| from google.cloud.speech.encoding import Encoding |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
da3d0c9 to
c30ea2fCompare| 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 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| max_alternatives=max_alternatives, | ||
| profanity_filter=True, | ||
| speech_context=['Google', | ||
| 'cloud']) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| return result | ||
| def _check_best_results(self, results): | ||
| from google.cloud.speech.transcript import Transcript |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def test_sync_recognize_local_file(self): | ||
| import os | ||
| from google.cloud.speech.transcript import Transcript |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| import os | ||
| from google.cloud.speech.transcript import Transcript | ||
| file_name = os.path.join('system_tests', 'data', 'hello.wav') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| self.assertIsInstance(second_alternative, Transcript) | ||
| self.assertEqual(second_alternative.transcript, | ||
| 'thank you for using Google Cloud platform') | ||
| self.assertEqual(second_alternative.confidence, 0.0) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| self._check_best_results(results) | ||
| self.assertIsInstance(second_alternative, Transcript) | ||
| self.assertEqual(second_alternative.transcript, | ||
| 'thank you for using Google Cloud platform') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| with open(file_name, 'rb') as file_obj: | ||
| blob.upload_from_file(file_obj) | ||
| # source_uri = os.getenv('SPEECH_GCS_URI') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def test_sync_recognize_gcs_file(self): | ||
| import os | ||
| file_name = os.path.join('system_tests', 'data', 'hello.wav') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| file_name = os.path.join('system_tests', 'data', 'hello.wav') | ||
| bucket_name = Config.TEST_BUCKET.name | ||
| blob_name = 'document.txt' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| """ | ||
| CLIENT = None | ||
| TEST_BUCKET = None | ||
| AUDIO_FILE = os.path.join(os.path.dirname(__file__), 'data', 'hello.wav') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…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.
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.