识别出来的相差甚远
qiyuhb 发布于2017-10 浏览:1452 回复:4
0
收藏

我使用的服务是:语音识别

调用的接口是:rest api

参数设置情况:

开发平台和机型:树莓派pi

SDK版本号:

代码或日志截图(上传截图能帮助您更快解决问题):

wav_fp = wave.open(filename,'rb')

nf = wav_fp.getnframes()

f_len = nf * 2

print f_len

audio_data = wav_fp.readframes(nf)

#print audio_data

http_header = [

        'Content-Type: audio/wav; rate=8000',

        'Content-Length: %d' % f_len

]

c=pycurl.Curl()

c.setopt(pycurl.URL,str(srv_url))

c.setopt(c.HTTPHEADER,http_header)

c.setopt(c.POST,1)

c.setopt(c.CONNECTTIMEOUT,30)

c.setopt(c.TIMEOUT,30)

c.setopt(c.WRITEFUNCTION,dump_res)

c.setopt(c.POSTFIELDS,audio_data)

c.setopt(c.POSTFIELDSIZE, f_len)

c.perform()

复现步骤、现象及其他描述:

{"corpus_no":"6474897815491553526","err_msg":"success.","err_no":0,"result":["哈哈,"],"sn":"71181167701507554625"}

文件格式:c.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 8 bit, mono 8000 Hz

收藏
点赞
0
个赞
共4条回复 最后由用户已被禁言回复于2022-04
#4chenxiaoyu3回复于2017-10

qiyuhb:

已经解决了,是我音频的rate和type有问题

回复qiyuhb:

0
#3qiyuhb回复于2017-10

已经解决了,是我音频的rate和type有问题

0
#2qiyuhb回复于2017-10

又试了一下SDK,结果是一样的,是我的语音文件格式有问题吗?

from aip import AipSpeech

import json

import sys

filename=sys.argv[1]

cuid="xxxx"

api="xxx"

key="xxx"

aip=AipSpeech(cuid,api,key)

f=open(filename,'rb')


a=aip.asr(f.read(),'wav',8000,{'lan':'zh',})

print a

tex=a['result']

print tex[0].encode('utf-8')



{u'err_no': 0, u'corpus_no': u'6474908218597675149', u'err_msg': u'success.', u'result': [u'\u4e0d\u8fd8\uff0c'], u'sn': u'256617698821507557048'}

不还,



0
TOP
切换版块