Skip to content

Using google.cloud.operation for GAPIC Speech async? #2629

Closed
@daspecster

Description

@daspecster

I've been struggling today with the right way to implement this.
I can't seem to make_secure_stub for speech.

This is the error I get...

File "/Users/daspecster/Documents/google/google-cloud-py-2/.tox/py27/lib/python2.7/site-packages/google_cloud_speech-0.20.0.dev0-py2.7.egg/google/cloud/speech/_gax.py", line 92, in async_recognize
    OPERATIONS_API_HOST)
  File "/Users/daspecster/Documents/google/google-cloud-py-2/.tox/py27/lib/python2.7/site-packages/google_cloud_core-0.20.0-py2.7.egg/google/cloud/_helpers.py", line 642, in make_secure_stub
    transport_creds = grpc.ssl_channel_credentials()
AttributeError: 'module' object has no attribute 'ssl_channel_credentials'

Example code:

        config = RecognitionConfig(
            encoding=sample.encoding, sample_rate=sample.sample_rate,
            language_code=language_code, max_alternatives=max_alternatives,
            profanity_filter=profanity_filter,
            speech_context=SpeechContext(phrases=speech_context))

        audio = RecognitionAudio(content=sample.content,
                                 uri=sample.source_uri)
        self._client._operations_stub = make_secure_stub(
            self._client.connection.credentials,
            DEFAULT_USER_AGENT,
            operations_grpc.OperationsStub,
            OPERATIONS_API_HOST)

        api = self._gapic_api
        operation = api.sync_recognize(config=config, audio=audio)
        return Operation.from_pb(operation, self._client)

Looking at the sample example it seems like the channel creation is different than it is in our _helpers.make_secure_stub

Metadata

Metadata

Assignees

Labels

api: speechIssues related to the Speech-to-Text API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions