Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add speech asynchronous recognize support. #2426

Merged
merged 4 commits into from
Sep 28, 2016

Conversation

daspecster
Copy link
Contributor

Add support for Speech API long running operations.

@daspecster daspecster added the api: speech Issues related to the Speech-to-Text API. label Sep 26, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 26, 2016
config['profanityFilter'] = profanity_filter
if speech_context is not None:
config['speechContext'] = {'phrases': speech_context}
def _build_request_data(content, source_uri, encoding, sample_rate,

This comment was marked as spam.

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.

I'm not 100% but I think there is a utility in google.protobuf for parsing a JSON version of a protobuf message type (here it is Operation)

>>> operation.complete
True
>>> operation.results[0]['alternatives'][0]['transcript']
"how old is the Brooklyn Bridge"

This comment was marked as spam.

This comment was marked as spam.

... operation.poll() # API call
>>> operation.complete
True
>>> operation.results[0]['alternatives'][0]['transcript']

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

AMR_WB = 'AMR_WB'
"""AMR_WB encoding type."""
from google.cloud.speech.encoding import Encoding
from google.cloud.speech.operation import Operation

This comment was marked as spam.

This comment was marked as spam.

config['profanityFilter'] = profanity_filter
if speech_context is not None:
config['speechContext'] = {'phrases': speech_context}
def _build_request_data(content, source_uri, encoding, sample_rate,

This comment was marked as spam.

from google.cloud._helpers import _rfc3339_to_datetime


class Operation(object):

This comment was marked as spam.

This comment was marked as spam.

}
]
}
]

This comment was marked as spam.

]
}
]
}

This comment was marked as spam.

'startTime': '2016-09-22T17:52:25.536964Z',
'lastUpdateTime': '2016-09-22T17:52:27.802902Z'
},
'done': False

This comment was marked as spam.

'google.cloud.speech.v1beta1.AsyncRecognizeMetadata'),
'progressPercent': 27,
'startTime': '2016-09-22T17:52:25.536964Z',
'lastUpdateTime': '2016-09-22T17:52:27.802902Z'

This comment was marked as spam.

@@ -26,7 +26,7 @@ class Connection(base_connection.JSONConnection):
API_VERSION = 'v1beta1'
"""The version of the API, used in building the API call's URL."""

API_URL_TEMPLATE = '{api_base_url}/{api_version}/speech:{path}'
API_URL_TEMPLATE = '{api_base_url}/{api_version}/{path}'

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@daspecster
Copy link
Contributor Author

@dhermes was there supposed to be a link in here?

I'm not 100% but I think there is a utility in google.protobuf for parsing a JSON version of a protobuf message type (here it is Operation)

encoding,
self.SAMPLE_RATE)
self.assertIsInstance(operation, Operation)
self.assertFalse(operation.complete)

This comment was marked as spam.

This comment was marked as spam.

... operation.poll() # API call
>>> operation.complete
True
>>> operation.results[0]['alternatives'][0]['transcript']

This comment was marked as spam.

@@ -26,7 +26,7 @@ class Connection(base_connection.JSONConnection):
API_VERSION = 'v1beta1'
"""The version of the API, used in building the API call's URL."""

API_URL_TEMPLATE = '{api_base_url}/{api_version}/speech:{path}'
API_URL_TEMPLATE = '{api_base_url}/{api_version}/{path}'

This comment was marked as spam.

@daspecster
Copy link
Contributor Author

@tseaver I think I got all the things you mentioned. LMKWYT


def api_request(self, method, path):
self._requested.append({'method': method, 'path': path})

This comment was marked as spam.

This comment was marked as spam.

@tseaver
Copy link
Contributor

tseaver commented Sep 28, 2016

@daspecster Should be OK to merge if you can tweak the assertions for the operations tests (see above).

@daspecster daspecster merged commit 5a0e492 into googleapis:master Sep 28, 2016
@daspecster daspecster deleted the add-speech-async branch September 28, 2016 15:43
atulep pushed a commit that referenced this pull request Apr 3, 2023
Add speech asynchronous recognize support.
atulep pushed a commit that referenced this pull request Apr 18, 2023
Add speech asynchronous recognize support.
parthea pushed a commit that referenced this pull request Oct 22, 2023
Add speech asynchronous recognize support.
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