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

Fix bug with speech streaming speech_context. #2717

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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