Skip to content

Commit

Permalink
Merge pull request #2717 from daspecster/fix-speech-streaming-speech-…
Browse files Browse the repository at this point in the history
…context-bug

Fix bug with speech streaming speech_context.
  • Loading branch information
daspecster authored Nov 10, 2016
2 parents cd9ac33 + 5fbbc1b commit 9403751
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion speech/google/cloud/speech/_gax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions speech/unit_tests/test__gax.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion system_tests/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def _make_streaming_request(self, file_obj, single_utterance=True,
sample_rate=16000)
return client.streaming_recognize(sample,
single_utterance=single_utterance,
interim_results=interim_results)
interim_results=interim_results,
speech_context=['hello', 'google'])

def _check_results(self, results, num_results=1):
self.assertEqual(len(results), num_results)
Expand Down

0 comments on commit 9403751

Please sign in to comment.