Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion system_tests/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,32 @@ def _check_best_results(self, results):
self.assertGreater(top_result.confidence, 0.90)

def test_sync_recognize_local_file(self):
with open(AUDIO_FILE, 'rb') as file_obj:
content = file_obj.read()
results = self._make_sync_request(content=content,
max_alternatives=2)

self.assertEqual(len(results), 2)
second_alternative = results[1]
self._check_best_results(results)
self.assertIsInstance(second_alternative, Transcript)
self.assertEqual(second_alternative.transcript, self.ASSERT_TEXT)
self.assertEqual(second_alternative.confidence, 0.0)

def test_sync_recognize_gcs_file(self):
bucket_name = Config.TEST_BUCKET.name
blob_name = 'hello.wav'
blob = Config.TEST_BUCKET.blob(blob_name)
self.to_delete_by_case.append(blob) # Clean-up.
with open(AUDIO_FILE, 'rb') as file_obj:
blob.upload_from_file(file_obj)

source_uri = 'gs://%s/%s' % (bucket_name, blob_name)
result = self._make_sync_request(source_uri=source_uri,
max_alternatives=1)
self._check_best_results(result)

def test_sync_recognize_local_file_rest(self):
with open(AUDIO_FILE, 'rb') as file_obj:
results = self._make_sync_request(content=file_obj.read(),
max_alternatives=2)
Expand All @@ -134,7 +160,7 @@ def test_sync_recognize_local_file(self):
self.assertEqual(second_alternative.transcript, self.ASSERT_TEXT)
self.assertEqual(second_alternative.confidence, 0.0)

def test_sync_recognize_gcs_file(self):
def test_sync_recognize_gcs_file_rest(self):
bucket_name = Config.TEST_BUCKET.name
blob_name = 'hello.wav'
blob = Config.TEST_BUCKET.blob(blob_name)
Expand Down