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')}