【置顶】语音识别REST API问题及答案汇总贴
Ta的回复 :133*****864: python写的识别程序,调试通过. def recognize( filepath, ftype, frate, token, fchannel ): fh = open( filepath ,'rb') content = fh.read() f_len = os.path.getsize( filepath ) speech = base64.b64encode(content) fh.close() # 表示本机的id,使用mac地址标识 cuid = "40-8D-5C-73-00-78" url="http://vop.baidu.com/server_api" update = json.dumps({'format':ftype,'rate':frate,'channel':fchannel,'cuid':cuid,'token':token,'speech':speech,'len':f_len}) r = urllib2.urlopen( url ,update) result = json.loads( r.read() ) err_no = result['err_no'] if err_no == 0: text = result['result'][0] else: text = err_map( err_no ) print "DEBUG, Error:" ,text.encode('cp936') return err_no, text 回复133*****864:你好,我也是用python调用百度语音的api,但是一直测试通不过。可以加我QQ咨询一下吗? 851129496 谢谢