下载官网推荐的wav格式的文件样例-“16k 采样率wav文件样例下载”
使用下面代码识别语音,一直提示{u'err_no': 3301, u'err_msg': u'speech quality error.', u'sn': u'310507927971550640468'},请教大神指点原因何处??谢谢
class voice2word(BaiduVoiceFather):
def getText(self):
wav_filename = '16k.wav' #读取录制的音频
d = open(wav_filename,'rb').read()
size = os.path.getsize(wav_filename)
texturl = "http://vop.baidu.com/server_api?lan=zh&cuid=%s&token=%s" % (self.cuid, self.gettoken())
data_update={
"dev_pid":1536,
"format": "wav",
"rate": 16000,
"channel": 1,
"len": size,
"speech": base64.b64encode(d).decode('utf-8')
}
request = requests.post(texturl, data=json.dumps(data_update).encode('utf-8'),
headers={'Content-Type': 'audio/wav;rate=16000'})
result = json.loads(request.content)
print (result)
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
感谢使用百度语音。
谢谢
3301错误是指音频质量过差不清晰,但提供的样式文件是没有问题的。有可能是集成时参数不正确,先用官方demo试下。另外试下pcm格式。https://github.com/Baidu-AIP/speech-demo