| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| REQUIREMENTS = [ | ||
| 'google-cloud-core >= 0.20.0', | ||
| 'grpcio >= 1.0.0, < 2.0dev', | ||
| 'google-gax >= 0.14.1, < 0.15dev', |
| from google.cloud._helpers import make_secure_stub | ||
| from google.cloud.connection import DEFAULT_USER_AGENT | ||
| from google.cloud.speech.operation import Operation | ||
| from google.cloud.operation import register_type |
| OPERATIONS_API_HOST = 'speech.googleapis.com' | ||
|
|
||
| register_type(AsyncRecognizeMetadata) | ||
| register_type(AsyncRecognizeResponse) |
| words to the vocabulary of the recognizer. | ||
|
|
||
| :raises NotImplementedError: Always. | ||
| :rtype: :class:`~google.cloud.operation.Opeartion` |
| api = self._gapic_api | ||
| response = api.async_recognize(config=config, audio=audio) | ||
|
|
||
| self._client._operations_stub = make_secure_stub( |
| REQUIREMENTS = [ | ||
| 'google-cloud-core >= 0.20.0', | ||
| 'gapic-google-cloud-speech-v1beta1 >= 0.11.1, < 0.12.0', | ||
| 'grpc-google-cloud-speech-v1beta1 >= 0.11.1, < 0.12.0', |
| credentials = _Credentials() | ||
| client = self._makeOne(credentials=credentials, use_gax=True) | ||
| client.connection = _Connection() | ||
| _MockGAPICSpeechAPI._results = [] |
| credentials = _Credentials() | ||
| client = self._makeOne(credentials=credentials) | ||
| client.connection = _Connection() | ||
| client.connection.credentials = credentials |
| operation = client.async_recognize(sample) | ||
|
|
||
| self.assertFalse(operation.complete) | ||
| self.assertIsNone(operation.response) |
|
|
||
|
|
||
| class _MockGAPICMetadata(object): | ||
| type_url = None |
|
@dhermes I think there are just thow two open questions. Did you have anything else? |
Sorry, something went wrong.
| @staticmethod | ||
| def _make_result(transcript, confidence): | ||
| from google.cloud.grpc.speech.v1beta1 import cloud_speech_pb2 | ||
| return cloud_speech_pb2.SpeechRecognitionResult( |
| alternatives=[ | ||
| cloud_speech_pb2.SpeechRecognitionAlternative( | ||
| transcript=transcript, | ||
| confidence=confidence, |
|
|
||
| def _make_sync_response(self, *results): | ||
| from google.cloud.grpc.speech.v1beta1 import cloud_speech_pb2 | ||
| response = cloud_speech_pb2.SyncRecognizeResponse( |
| from google.cloud.speech import _gax as MUT | ||
|
|
||
| from google.cloud import speech | ||
| from google.cloud.speech import _gax as MUT |
| client.connection = _Connection() | ||
| client.connection.credentials = credentials | ||
|
|
||
| _MockGAPICSpeechAPI._response = self._make_sync_response() |
| credentials = _Credentials() | ||
| client = self._makeOne(credentials=credentials) | ||
| client.connection = _Connection() | ||
| client.connection.credentials = credentials |
| mock_response = self._response | ||
| mock_response.results = self._results | ||
| return mock_response | ||
| # self._response.results = self._results |
| _results = None | ||
|
|
||
| def async_recognize(self, config, audio): | ||
| from google.longrunning.operations_pb2 import Operation |
| "confidence": 0.9224355 | ||
| }, { | ||
| "transcript": 'testing 4 5 6', | ||
| "confidence": 0.0123456 |
|
|
||
| with self.assertRaises(ValueError): | ||
| with _Monkey(MUT, SpeechApi=_MockGAPICSpeechAPI): | ||
| with _Monkey(_gax, SpeechApi=speech_api): |
| self.assertEqual(results[1].transcript, | ||
| alternatives[1]['transcript']) | ||
| self.assertEqual(results[1].confidence, | ||
| alternatives[1]['confidence']) |
There was a problem hiding this comment.
LGTM provided you clear up my most recent comments and resolve the setup.py question for @jonparrott
Sorry, something went wrong.
|
Travis has gone on strike again... |
Sorry, something went wrong.
|
Finally travis ran this job. @dhermes, I'm merging(in 15minutes) since I got your suggestions in. |
Sorry, something went wrong.
|
Feel free to merge now |
Sorry, something went wrong.
…apic Add speech async gapic
| Back | FazBrowse Home | New Git URL |
This will need #2661 in order for travis-ci to pass since I don't need metadata.py and operation.py after @dhermes refactored the core operation.py@ Thanks!
@dhermes, I think we talked about this back and forth a little bit, but as you can see from the system tests, the surface is much different between sync_recognize()'s results and async_recognize()'s results.
There will be some updates for the gRPC version of sync_recognize() that will follow this as well.