Skip to content

Commit 83000e9

Browse files
committed
Fix googleapis#2519, py3.5 encoding issue.
1 parent 1d39cfd commit 83000e9

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

speech/google/cloud/speech/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ def _build_request_data(sample, language_code=None, max_alternatives=None,
237237
:returns: Dictionary with required data for Google Speech API.
238238
"""
239239
if sample.content is not None:
240-
audio = {'content': b64encode(_to_bytes(sample.content))}
240+
audio = {'content':
241+
b64encode(_to_bytes(sample.content)).decode('ascii')}
241242
else:
242243
audio = {'uri': sample.source_uri}
243244

speech/unit_tests/test_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ def test_sync_recognize_content_with_optional_parameters(self):
6767
from google.cloud.speech.sample import Sample
6868
from unit_tests._fixtures import SYNC_RECOGNIZE_RESPONSE
6969

70-
_B64_AUDIO_CONTENT = base64.b64encode(_to_bytes(self.AUDIO_CONTENT))
70+
_B64_AUDIO_CONTENT = (base64.b64encode(_to_bytes(self.AUDIO_CONTENT))
71+
.decode('ascii'))
7172
RETURNED = SYNC_RECOGNIZE_RESPONSE
7273
REQUEST = {
7374
'config': {

0 commit comments

Comments
 (0)