From e4e213a44641060a8a9857b5838b65eb4693c12a Mon Sep 17 00:00:00 2001 From: Thomas Schultz Date: Thu, 10 Nov 2016 12:58:42 -0500 Subject: [PATCH] Fix bug with speech streaming speech_context. --- .../google-cloud-python-speech/google/cloud/speech/_gax.py | 3 ++- packages/google-cloud-python-speech/unit_tests/test__gax.py | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/google-cloud-python-speech/google/cloud/speech/_gax.py b/packages/google-cloud-python-speech/google/cloud/speech/_gax.py index 3cad482dd53a..aa9e9aa95d58 100644 --- a/packages/google-cloud-python-speech/google/cloud/speech/_gax.py +++ b/packages/google-cloud-python-speech/google/cloud/speech/_gax.py @@ -329,7 +329,8 @@ def _stream_requests(sample, language_code=None, max_alternatives=None, """ config_request = _make_streaming_request( sample, language_code=language_code, max_alternatives=max_alternatives, - profanity_filter=profanity_filter, speech_context=speech_context, + profanity_filter=profanity_filter, + speech_context=SpeechContext(phrases=speech_context), single_utterance=single_utterance, interim_results=interim_results) # The config request MUST go first and not contain any audio data. diff --git a/packages/google-cloud-python-speech/unit_tests/test__gax.py b/packages/google-cloud-python-speech/unit_tests/test__gax.py index 31af01178613..2b208cbf553a 100644 --- a/packages/google-cloud-python-speech/unit_tests/test__gax.py +++ b/packages/google-cloud-python-speech/unit_tests/test__gax.py @@ -130,8 +130,6 @@ def test_stream_requests(self): from io import BytesIO from google.cloud import speech from google.cloud.speech.sample import Sample - from google.cloud.grpc.speech.v1beta1.cloud_speech_pb2 import ( - SpeechContext) from google.cloud.grpc.speech.v1beta1.cloud_speech_pb2 import ( StreamingRecognitionConfig) from google.cloud.grpc.speech.v1beta1.cloud_speech_pb2 import ( @@ -143,7 +141,7 @@ def test_stream_requests(self): language_code = 'US-en' max_alternatives = 2 profanity_filter = True - speech_context = SpeechContext(phrases=self.HINTS) + speech_context = self.HINTS single_utterance = True interim_results = False streaming_requests = self._callFUT(sample, language_code,