| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Mostly LGTM, though ping me once issues resolved
Sorry, something went wrong.
| from google.cloud.speech.encoding import Encoding | ||
| from google.cloud.speech.operation import Operation | ||
| from google.cloud.speech.sample import Sample | ||
| from google.cloud.speech.transcript import Transcript |
| return api_response['results'][0]['alternatives'] | ||
| return [Transcript.from_api_repr(alternative) | ||
| for alternative | ||
| in api_response['results'][0]['alternatives']] |
| def from_api_repr(cls, transcript): | ||
| """Factory: construct ``Transcript`` from JSON response. | ||
|
|
||
| :type transcript: :class:`~SpeechRecognitionAlternative` |
| :rtype: :class:`~Transcript` | ||
| :returns: Instance of ``Transcript``. | ||
| """ | ||
| return cls(transcript['transcript'], transcript['confidence']) |
| self.assertEqual(response, expected) | ||
| alternative = SYNC_RECOGNIZE_RESPONSE['results'][0]['alternatives'][0] | ||
| expected = [Transcript.from_api_repr(alternative)] | ||
| self.assertIsInstance(response[0], Transcript) |
| expected = [Transcript.from_api_repr(alternative)] | ||
| self.assertIsInstance(response[0], Transcript) | ||
| self.assertEqual(response[0].transcript, expected[0].transcript) | ||
| self.assertEqual(response[0].confidence, expected[0].confidence) |
| SYNC_RECOGNIZE_RESPONSE['results'][0]['alternatives'][0])] | ||
| self.assertIsInstance(response[0], Transcript) | ||
| self.assertEqual(response[0].transcript, expected[0].transcript) | ||
| self.assertEqual(response[0].confidence, expected[0].confidence) |
There was a problem hiding this comment.
LGTM pending my two nits and length checks. Feel free to incorporate my feedback about the results[0] bit, but don't feel required to.
Sorry, something went wrong.
| alternative = SYNC_RECOGNIZE_RESPONSE['results'][0]['alternatives'][0] | ||
| expected = [Transcript.from_api_repr(alternative)] | ||
| expected = Transcript.from_api_repr(alternative) | ||
| self.assertEqual(len(response, 1)) |
| if len(api_response['results']) == 1: | ||
| results = api_response['results'] | ||
| if len(results) == 1: | ||
| result = results[0]['alternatives'] |
| expected = [Transcript.from_api_repr( | ||
| SYNC_RECOGNIZE_RESPONSE['results'][0]['alternatives'][0])] | ||
| expected = Transcript.from_api_repr( | ||
| SYNC_RECOGNIZE_RESPONSE['results'][0]['alternatives'][0]) |
|
Ok thanks! I changed the response check via your suggestion, added the length check and fixed my bug. I also just squashed the commits. |
Sorry, something went wrong.
|
Travis is green. Merging. |
Sorry, something went wrong.
Use Transcript object in sync and async.
Use Transcript object in sync and async.
Use Transcript object in sync and async.
…les#2613) * automl: add base samples * automl: add base set of samples * Clean up tests * License year 2020, drop python2 print statement unicode * use centralized automl testing project * Fix GCS path typo * Use fake dataset for batch predict * lint: line length * fix fixture naming and use * Fix fixture changes * Catch resource exhausted error * use fake data for import test * update how to access an operation id Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>
Use Transcript object in sync and async.
| Back | FazBrowse Home | New Git URL |
In the spirit of smaller PRs. I started switching sync to GAPIC again and I realized that this is required first.