Skip to content

Conversation

@daspecster
Copy link
Contributor

In the spirit of smaller PRs. I started switching sync to GAPIC again and I realized that this is required first.

@daspecster daspecster added the api: speech Issues related to the Speech-to-Text API. label Oct 25, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 25, 2016
@daspecster daspecster mentioned this pull request Oct 25, 2016
14 tasks
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.

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.

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.

This comment was marked as spam.

This comment was marked as spam.

def from_api_repr(cls, transcript):
"""Factory: construct ``Transcript`` from JSON response.
:type transcript: :class:`~SpeechRecognitionAlternative`

This comment was marked as spam.

: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.

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.

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.

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.

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 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.

if len(api_response['results']) == 1:
results = api_response['results']
if len(results) == 1:
result = results[0]['alternatives']

This comment was marked as spam.

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.

@daspecster daspecster force-pushed the add-speech-transcript branch from c90f33a to 325cbe7 Compare October 25, 2016 21:32
@daspecster
Copy link
Contributor Author

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
Copy link
Contributor Author

Travis is green. Merging.

@daspecster daspecster merged commit 0f8fdb6 into googleapis:master Oct 25, 2016
@daspecster daspecster deleted the add-speech-transcript branch October 25, 2016 21:37
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
atulep pushed a commit that referenced this pull request Apr 3, 2023
Use Transcript object in sync and async.
atulep pushed a commit that referenced this pull request Apr 18, 2023
Use Transcript object in sync and async.
parthea pushed a commit that referenced this pull request Oct 21, 2023
…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 <[email protected]>
parthea pushed a commit that referenced this pull request Oct 22, 2023
Use Transcript object in sync and async.
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants