Skip to content

Getting TypeError: memoryview: a bytes-like object is required, not 'str' in Bing Speech Recognize #44

Description

@tbaggs

I updated the Bing Speech uri to the current supported URI for Bing Speech. However, I now get the following error when sending data to the Bing endpoint. Has anyone updated their Bing Speech API file to the current endpoint? https://docs.microsoft.com/en-us/azure/cognitive-services/speech/getstarted/getstartedrest?tabs=Powershell

New Bing URI:
url = 'https://speech.platform.bing.com/speech/recognition/interactive/cognitiveservices/v1?language=en-US'

Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/pi/source/respeaker_python_library/examples/bing_translator.py", line 23, in task
text = bing.recognize(data)
File "/home/pi/source/respeaker_python_library/examples/bing_speech_api.py", line 111, in recognize
response = self.session.post(url, params=params, headers=headers, data=data)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 535, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 443, in send
for i in request.body:
File "/home/pi/source/respeaker_python_library/examples/bing_speech_api.py", line 83, in generate
yield self.get_wav_header()
File "/home/pi/source/respeaker_python_library/examples/bing_speech_api.py", line 189, in get_wav_header
w.writeframes('')
File "/usr/lib/python3.5/wave.py", line 427, in writeframes
self.writeframesraw(data)
File "/usr/lib/python3.5/wave.py", line 415, in writeframesraw
data = memoryview(data).cast('B')
TypeError: memoryview: a bytes-like object is required, not 'str'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions