def do_request(self):
"""Establishes a connection and starts sending audio to the cloud
endpoint. Responses are handled by the subclass until one returns a
result.
Returns:
namedtuple with the following fields:
transcript: string with transcript of user query
response_audio: optionally, an audio response from the server
Raises speech.Error on error.
"""
try:
service = self._make_service(self._channel_factory.make_channel())
response_stream = self._create_response_stream(
service, self._request_stream(), self.DEADLINE_SECS)
if self._audio_logging_enabled:
self._start_logging_request()
return self._handle_response_stream(response_stream)
except (
google.auth.exceptions.GoogleAuthError,
grpc.RpcError,
) as exc:
raise Error('Exception in speech request') from exc
评论列表
文章目录