Open alatriste-lee opened 8 years ago
也碰到这个问题。 不过我改了代码。百度的post data规格改了。 data = { "format": "pcm",
"token": self.token,
"len": len(audio_data.data),
# "rate": audio_data.rate,
"rate": 8000,
"channel" : 1,
"speech": base64.b64encode(audio_data.data),
"cuid": '93489083242',
}
不过出现另外一个问题 with sr.WavFile(WAV_FILE) as source: audio = r.record(source) # read the entire WAV file 读不出数据!!! audio为空!!
self.request = Request(url, data = json.dumps(data), headers = {"Content-Type": "application/json"})
json.dumps(data)