Skip to content

Add speech async gapic - #2663

Merged
daspecster merged 1 commit into
googleapis:masterfrom
daspecster:add-speech-async-gapic
Nov 3, 2016
Merged

Add speech async gapic#2663
daspecster merged 1 commit into
googleapis:masterfrom
daspecster:add-speech-async-gapic

Conversation

@daspecster

@daspecsterdaspecster commented Nov 2, 2016

Copy link
Copy Markdown
Contributor

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.

@daspecsterdaspecster added the api: speech Issues related to the Speech-to-Text API. label Nov 2, 2016
@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 2, 2016
@daspecster
daspecsterforce-pushed the add-speech-async-gapic branch from 0e14c9d to 5078aa4CompareNovember 2, 2016 03:07
@daspecster
daspecsterforce-pushed the add-speech-async-gapic branch 2 times, most recently from 54b981b to eb08066CompareNovember 2, 2016 04:10
@daspecsterdaspecster mentioned this pull request Nov 2, 2016
14 tasks
@daspecster
daspecsterforce-pushed the add-speech-async-gapic branch from eb08066 to 46cd146CompareNovember 2, 2016 04:17
Comment threadspeech/setup.py Outdated
REQUIREMENTS = [
'google-cloud-core >= 0.20.0',
'grpcio >= 1.0.0, < 2.0dev',
'google-gax >= 0.14.1, < 0.15dev',

This comment was marked as spam.

@daspecster
daspecsterforce-pushed the add-speech-async-gapic branch 2 times, most recently from 0ca8559 to bf805e3CompareNovember 2, 2016 04:49
Comment threadspeech/google/cloud/speech/_gax.py Outdated
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

This comment was marked as spam.

Comment threadspeech/google/cloud/speech/_gax.py Outdated
OPERATIONS_API_HOST = 'speech.googleapis.com'

register_type(AsyncRecognizeMetadata)
register_type(AsyncRecognizeResponse)

This comment was marked as spam.

Comment threadspeech/google/cloud/speech/_gax.py Outdated
words to the vocabulary of the recognizer.

:raises NotImplementedError: Always.
:rtype: :class:`~google.cloud.operation.Opeartion`

This comment was marked as spam.

Comment threadspeech/google/cloud/speech/_gax.py Outdated
api = self._gapic_api
response = api.async_recognize(config=config, audio=audio)

self._client._operations_stub = make_secure_stub(

This comment was marked as spam.

Comment threadspeech/setup.py
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',

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment threadspeech/unit_tests/test_client.py Outdated
credentials = _Credentials()
client = self._makeOne(credentials=credentials, use_gax=True)
client.connection = _Connection()
_MockGAPICSpeechAPI._results = []

This comment was marked as spam.

This comment was marked as spam.

credentials = _Credentials()
client = self._makeOne(credentials=credentials)
client.connection = _Connection()
client.connection.credentials = credentials

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

operation = client.async_recognize(sample)

self.assertFalse(operation.complete)
self.assertIsNone(operation.response)

This comment was marked as spam.

Comment threadspeech/unit_tests/test_client.py Outdated


class _MockGAPICMetadata(object):
type_url = None

This comment was marked as spam.

@daspecster
daspecsterforce-pushed the add-speech-async-gapic branch from 375feeb to 2e9f486CompareNovember 2, 2016 18:20
@daspecster

Copy link
Copy Markdown
ContributorAuthor

@dhermes I think there are just thow two open questions. Did you have anything else?

@staticmethod
def _make_result(transcript, confidence):
from google.cloud.grpc.speech.v1beta1 import cloud_speech_pb2
return cloud_speech_pb2.SpeechRecognitionResult(

This comment was marked as spam.

Comment threadspeech/unit_tests/test_client.py Outdated
alternatives=[
cloud_speech_pb2.SpeechRecognitionAlternative(
transcript=transcript,
confidence=confidence,

This comment was marked as spam.


def _make_sync_response(self, *results):
from google.cloud.grpc.speech.v1beta1 import cloud_speech_pb2
response = cloud_speech_pb2.SyncRecognizeResponse(

This comment was marked as spam.

Comment threadspeech/unit_tests/test_client.py Outdated
from google.cloud.speech import _gax as MUT

from google.cloud import speech
from google.cloud.speech import _gax as MUT

This comment was marked as spam.

This comment was marked as spam.

Comment threadspeech/unit_tests/test_client.py Outdated
client.connection = _Connection()
client.connection.credentials = credentials

_MockGAPICSpeechAPI._response = self._make_sync_response()

This comment was marked as spam.

credentials = _Credentials()
client = self._makeOne(credentials=credentials)
client.connection = _Connection()
client.connection.credentials = credentials

This comment was marked as spam.

Comment threadspeech/unit_tests/test_client.py Outdated
mock_response = self._response
mock_response.results = self._results
return mock_response
# self._response.results = self._results

This comment was marked as spam.

This comment was marked as spam.

_results = None

def async_recognize(self, config, audio):
from google.longrunning.operations_pb2 import Operation

This comment was marked as spam.

Comment threadspeech/unit_tests/test_client.py Outdated
"confidence": 0.9224355
}, {
"transcript": 'testing 4 5 6',
"confidence": 0.0123456

This comment was marked as spam.

Comment threadspeech/unit_tests/test_client.py Outdated

with self.assertRaises(ValueError):
with _Monkey(MUT, SpeechApi=_MockGAPICSpeechAPI):
with _Monkey(_gax, SpeechApi=speech_api):

This comment was marked as spam.

Comment threadspeech/unit_tests/test_client.py Outdated
self.assertEqual(results[1].transcript,
alternatives[1]['transcript'])
self.assertEqual(results[1].confidence,
alternatives[1]['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 provided you clear up my most recent comments and resolve the setup.py question for @jonparrott

@daspecster

Copy link
Copy Markdown
ContributorAuthor

Travis has gone on strike again...

@daspecster

Copy link
Copy Markdown
ContributorAuthor

Finally travis ran this job. @dhermes, I'm merging(in 15minutes) since I got your suggestions in.

@dhermes

Copy link
Copy Markdown
Contributor

Feel free to merge now

@daspecster
daspecster merged commit 3de5bc0 into googleapis:masterNov 3, 2016
@daspecsterdaspecster mentioned this pull request Nov 3, 2016
@daspecster
daspecster deleted the add-speech-async-gapic branch January 24, 2017 15:17
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 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.

5 participants

@daspecster@dhermes@theacodes@tseaver@googlebot