Add speech async JSON/REST system tests.#2648
Conversation
system_tests/speech.py
Outdated
|
|
||
| def _make_async_request(self, content=None, source_uri=None, | ||
| max_alternatives=None): | ||
| client = speech.Client(use_gax=False) |
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.
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.
system_tests/speech.py
Outdated
| profanity_filter=True, | ||
| speech_context=['Google', 'cloud']) | ||
|
|
||
| return result |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
system_tests/speech.py
Outdated
| import time | ||
| with open(AUDIO_FILE, 'rb') as file_obj: | ||
| operation = self._make_async_request(content=file_obj.read(), | ||
| max_alternatives=2) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
system_tests/speech.py
Outdated
| self._check_best_results(result) | ||
|
|
||
| def test_async_recognize_local_file(self): | ||
| import time |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
system_tests/speech.py
Outdated
| while retry_count > 0 and not operation.complete: | ||
| retry_count -= 1 | ||
| time.sleep(10) | ||
| operation.poll() |
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.
system_tests/speech.py
Outdated
| source_uri = 'gs://%s/%s' % (bucket_name, blob_name) | ||
| operation = self._make_async_request(source_uri=source_uri, | ||
| max_alternatives=2) | ||
| retry_count = 100 |
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.
system_tests/speech.py
Outdated
| retry_count = 100 | ||
| while retry_count > 0 and not operation.complete: | ||
| retry_count -= 1 | ||
| time.sleep(10) |
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.
system_tests/speech.py
Outdated
| results = operation.results | ||
| self.assertIsInstance(results[0], Transcript) | ||
| self.assertEqual(results[0].transcript, 'hello ' + self.ASSERT_TEXT) | ||
| self.assertGreater(results[0].confidence, 0.90) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
system_tests/speech.py
Outdated
| """ | ||
|
|
||
| def _operation_complete(result): | ||
| return result |
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.
| def test_async_recognize_local_file(self): | ||
| import time | ||
| if Config.USE_GAX: | ||
| self.skipTest('async_recognize gRPC not yet implemented.') |
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.
|
LGTM (assuming you are tracking those |
system_tests/speech.py
Outdated
| :rtype: bool | ||
| :returns: Boolean indicating if the operation is 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.
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.
LGTM provided you are tracking skipTest
|
Ok I'm squashing now. Thanks! |
b79b1ee to
80e4143
Compare
…est-system-tests Add speech async JSON/REST system tests.
This adds JSON/REST system tests for speech's
async_recognize()method.