Skip to content

speech api with sample content bytes is not encoded to ASCII string before being sent over the wire #2519

@INRIX-Avilay-Parekh

Description

@INRIX-Avilay-Parekh

When using the package as under with python3.5 -

with open('linear.wav', 'rb') as f:
    data = f.read()

s = client.sample(data, None, encoding=Encoding.LINEAR16, sample_rate=16000)
texts = client.sync_recognize(s)

Throws an error that it is not possible to convert the byte stream to JSON.

In speech/google/cloud/speech/client.py#240 the following line encodes the bytes in base64 but the return type of b64encode is still bytes.

audio = {'content': b64encode(_to_bytes(sample.content))}

If this is changed to the following, the API behaves as expected -

audio = {'content': b64encode(_to_bytes(sample.content)).decode('ascii')}

Metadata

Metadata

Assignees

Labels

api: speechIssues related to the Speech-to-Text API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions