Skip to content

Commit cb284a8

Browse files
Jon Wayne Parrottchemelnucfin
authored andcommitted
Fix speech helpers to properly pass retry and timeout args (googleapis#4828)
1 parent b2e7953 commit cb284a8

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

speech/google/cloud/speech_v1/helpers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
from __future__ import absolute_import
1616

17+
import google.api_core.gapic_v1.method
18+
1719

1820
class SpeechHelpers(object):
1921
"""A set of convenience methods to make the Speech client easier to use.
@@ -22,7 +24,10 @@ class SpeechHelpers(object):
2224
in a multiple-inheritance construction alongside the applicable GAPIC.
2325
See the :class:`~google.cloud.speech_v1.SpeechClient`.
2426
"""
25-
def streaming_recognize(self, config, requests, options=None):
27+
def streaming_recognize(
28+
self, config, requests,
29+
retry=google.api_core.gapic_v1.method.DEFAULT,
30+
timeout=google.api_core.gapic_v1.method.DEFAULT):
2631
"""Perform bi-directional speech recognition.
2732
2833
This method allows you to receive results while sending audio;
@@ -66,7 +71,7 @@ def streaming_recognize(self, config, requests, options=None):
6671
"""
6772
return self._streaming_recognize(
6873
self._streaming_request_iterable(config, requests),
69-
options,
74+
retry=retry, timeout=timeout
7075
)
7176

7277
def _streaming_request_iterable(self, config, requests):

speech/tests/unit/gapic/v1/test_helpers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def test_inherited_method(self):
3636

3737
config = types.RecognitionConfig(encoding='FLAC')
3838
audio = types.RecognitionAudio(uri='http://foo.com/bar.wav')
39-
with mock.patch.object(client, '_recognize') as recognize:
39+
patch = mock.patch.object(client, '_recognize', autospec=True)
40+
with patch as recognize:
4041
client.recognize(config, audio)
4142

4243
# Assert that the underlying GAPIC method was called as expected.
@@ -54,7 +55,9 @@ def test_streaming_recognize(self):
5455

5556
config = types.StreamingRecognitionConfig()
5657
requests = [types.StreamingRecognizeRequest(audio_content=b'...')]
57-
with mock.patch.object(client, '_streaming_recognize') as sr:
58+
patch = mock.patch.object(
59+
client, '_streaming_recognize', autospec=True)
60+
with patch as sr:
5861
client.streaming_recognize(config, requests)
5962

6063
# Assert that we called streaming recognize with an iterable

0 commit comments

Comments
 (0)