Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add speech async JSON/REST system tests. #2648

Merged

Conversation

daspecster
Copy link
Contributor

This adds JSON/REST system tests for speech's async_recognize() method.

@daspecster daspecster added testing api: speech Issues related to the Speech-to-Text API. labels Oct 31, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 31, 2016
@daspecster daspecster mentioned this pull request Oct 31, 2016
14 tasks
@@ -79,6 +79,21 @@ def _make_sync_request(self, content=None, source_uri=None,
speech_context=['Google', 'cloud'])
return result

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.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

profanity_filter=True,
speech_context=['Google', 'cloud'])

return result

This comment was marked as spam.

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.

@@ -109,3 +124,54 @@ def test_sync_recognize_gcs_file(self):
result = self._make_sync_request(source_uri=source_uri,
max_alternatives=1)
self._check_best_results(result)

def test_async_recognize_local_file(self):
import time

This comment was marked as spam.

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.

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.

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.

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.

"""

def _operation_complete(result):
return result

This comment was marked as spam.

This comment was marked as spam.

@@ -126,29 +147,27 @@ def test_sync_recognize_gcs_file(self):
self._check_best_results(result)

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.

@dhermes
Copy link
Contributor

dhermes commented Oct 31, 2016

LGTM (assuming you are tracking those skipTest usages)

:rtype: bool
:returns: Boolean indicating if the operation is complete.
"""

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Copy link
Contributor

@dhermes dhermes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM provided you are tracking skipTest

@daspecster
Copy link
Contributor Author

Ok I'm squashing now. Thanks!

@daspecster daspecster force-pushed the add-speech-async-rest-system-tests branch from b79b1ee to 80e4143 Compare October 31, 2016 17:05
@daspecster daspecster merged commit 56fb77c into googleapis:master Oct 31, 2016
@daspecster daspecster deleted the add-speech-async-rest-system-tests branch October 31, 2016 17:15
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
…est-system-tests

Add speech async JSON/REST system tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: speech Issues related to the Speech-to-Text API. cla: yes This human has signed the Contributor License Agreement. testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants