Skip to content

Use Transcript object in sync and async. - #2613

Merged
daspecster merged 1 commit into
googleapis:masterfrom
daspecster:add-speech-transcript
Oct 25, 2016
Merged

Use Transcript object in sync and async.#2613
daspecster merged 1 commit into
googleapis:masterfrom
daspecster:add-speech-transcript

Conversation

@daspecster

Copy link
Copy Markdown
Contributor

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

@daspecsterdaspecster added the api: speech Issues related to the Speech-to-Text API. label Oct 25, 2016
@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 25, 2016
@daspecsterdaspecster mentioned this pull request Oct 25, 2016
14 tasks

@dhermesdhermes left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadspeech/google/cloud/speech/client.py Outdated
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.

Comment threadspeech/unit_tests/test_client.py Outdated
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.

Comment threadspeech/unit_tests/test_client.py Outdated
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.

@dhermesdhermes left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadspeech/unit_tests/test_client.py Outdated
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.

Comment threadspeech/google/cloud/speech/client.py Outdated
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

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

Travis is green. Merging.

@daspecster
daspecster merged commit 0f8fdb6 into googleapis:masterOct 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
atulep pushed a commit that referenced this pull request Apr 18, 2023
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 <6719667+leahecole@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Oct 22, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: speechIssues related to the Speech-to-Text API.cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@daspecster@dhermes@tseaver@googlebot