I have a large mp3 file(about 1.8GB), which I have to transcribe using wit.ai. Since I am working with wav files a lot, i converted it to wav file.
But since wit.ai's speech api can't take more than 10s long audio, I am planning to stream the file in chunks. But some how I am only getting reponse 400(bad request). I am not able to find out, what I am sending wrong. Following are the details:
headers = {'authorization': 'Bearer ' + wit_access_token,
'Content-Type': 'audio/wav','Transfer-encoding': 'chunked'}
with open('meeting-record.wav', 'rb') as f:
audio = f.read(2048) # taken it any number
resp = requests.post(API_ENDPOINT, headers = headers,
data = audio)
print(resp)
data = json.loads(resp.content)
text = data['_text']
print(text)
f.close()
I am getting the following output
<Response [400]>
Traceback (most recent call last):
File ".\sound-record.py", line 61, in <module>
text = data['_text']
KeyError: '_text'
Can someone show some pointers, where its going wrong?