Uh oh!
There was an error while loading. Please reload this page.
Use Transcript object in sync and async. - #2613
Conversation
dhermes
left a comment
There was a problem hiding this comment.
Mostly LGTM, though ping me once issues resolved
| 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 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| return api_response['results'][0]['alternatives'] | ||
| return [Transcript.from_api_repr(alternative) | ||
| for alternative | ||
| in api_response['results'][0]['alternatives']] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def from_api_repr(cls, transcript): | ||
| """Factory: construct ``Transcript`` from JSON response. | ||
| :type transcript: :class:`~SpeechRecognitionAlternative` |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| :rtype: :class:`~Transcript` | ||
| :returns: Instance of ``Transcript``. | ||
| """ | ||
| return cls(transcript['transcript'], transcript['confidence']) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| self.assertEqual(response, expected) | ||
| alternative = SYNC_RECOGNIZE_RESPONSE['results'][0]['alternatives'][0] | ||
| expected = [Transcript.from_api_repr(alternative)] | ||
| self.assertIsInstance(response[0], Transcript) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| 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) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
dhermes
left a comment
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.
| 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)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| if len(api_response['results']) == 1: | ||
| results = api_response['results'] | ||
| if len(results) == 1: | ||
| result = results[0]['alternatives'] |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| expected = [Transcript.from_api_repr( | ||
| SYNC_RECOGNIZE_RESPONSE['results'][0]['alternatives'][0])] | ||
| expected = Transcript.from_api_repr( | ||
| SYNC_RECOGNIZE_RESPONSE['results'][0]['alternatives'][0]) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
c90f33a to
325cbe7Comparedaspecster
commented
Oct 25, 2016
Ok thanks! I changed the response check via your suggestion, added the length check and fixed my bug. I also just squashed the commits. |
daspecster
commented
Oct 25, 2016
Travis is green. Merging. |
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.
In the spirit of smaller PRs. I started switching sync to GAPIC again and I realized that this is required first.