ASR语音识别接口V1.0

2020-05-12 11:32:35 admin 606

ASR语音识别接口V1.0


客户端使用websocket与语音识别服务器进行通信

服务器地址:asr.zaofada.com  websocket端口是8002

1、语音识别相关命令:

CMD_DECODE_BEGIN_STREAM

必要参数:

可选参数:

LangMod:

语言模型名称,默认为default-001,此项功能只在拥有自定义训练语言模型时有效。

Vad:

是否进行vad音频切分,0:切分,1:不切分,默认为1

Punc:

是否预测标点符号,0:不预测,1:预测,默认为1

SegTM:

是否获取切分开始结束时间,0:不获取,1:获取,默认为1

SampleRate:

wav采样率,80008k音频,1600016k音频。默认为8000

系统仅支持16bit的采样位深。

Immediate:

是否实时立即返回最新识别结果,0:实时,1:非实时,默认为0

示例:

参数全部默认:

{“EvtID”: “CMD_DECODE_BEGIN_STREAM”}

不进行vad切分:

{“EvtID”: “CMD_DECODE_BEGIN_STREAM”, “Vad”:0}

不进行标点符号预测:

{“EvtID”: “CMD_DECODE_BEGIN_STREAM”, “Punc”:0}

 

 

CMD_DECODE_ONLINE_PUSH_FRAME

必要参数:

EndPoint:结束点标志,上传文件完毕最后一帧结束时设置为1,否则为0

Frame:经过base64加密的音频二进制数据,EndPoint参数为结尾标志,最后一次发送音频结尾的时候值为1,其余的为0

 

可选参数:

示例:

{"EvtID":"CMD_DECODE_ONLINE_PUSH_FRAME","EndPoint":0,"Frame":"feowdwefwewe341321\ga=="}

非结束帧

{"EvtID":"CMD_DECODE_ONLINE_PUSH_FRAME","EndPoint":1,"Frame":"feowdwefwewe341321\ga=="}

最后一帧

2、语音识别流程:

Websocket流式识别接口支持实时识别,在发送音频流之前需要先发送CMD_DECODE_BEGIN_STREAM命令,命令格式如下:

{"EvtID":"CMD_DECODE_BEGIN_STREAM"}

 

发送CMD_DECODE_BEGIN_STREAM之后可以立即上传音频流,上传音频流命令如下:

{"EvtID":"CMD_DECODE_ONLINE_PUSH_FRAME","EndPoint":0,"Frame":"feo|wdwefwewe341321\ga=="}

 

Frame参数是经过base64加密的音频二进制数据,EndPoint参数为结尾标志,最后一次发送音频结尾的时候值为1,其余的为0。每次分片为10ms

 

3、识别结果示例:

开始发送音频帧后,有识别内容时会立即返回,返回结果如下:

 

{"RESULT":"SUCCES","Begin":0.00,"Vad":0,"End":66.99,"LastFlag":0,"Content":"您好,三江客"}

 

BeginEnd参数为开始和结束时间,单位ms

Vad参数为VAD切分标志,为1时为代表此次返回为一个Vad切分点,在Immediate参数为1时有效。

LastFlag参数为结束标志,为1时代表最后一次返回结果。

 

Content参数为识别结果,

Immediate参数为0时,Vad开启时则返回VAD切分的单句话识别结果,VAD关闭时则等发送完整个文件一次性返回结果。

Immediate参数为1时,Vad默认开启,识别到任何内容会立即返回最新识别结果,vad切分后整句话识别内容重置。

示例:

Immediate = 0 Vad = 1

{"RESULT":"SUCCES","Begin":0.00,"Vad":1,"End"2.74,"LastFlag":0,"Content":"你好"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":1,"End":5.99,"LastFlag":0,"Content":",今天天气怎么样"}

{"RESULT":"SUCCES","Begin":6.23,"Vad":1,"End":7.89,"LastFlag":1,"Content":"?还不错。"}

 

Immediate = 0 Vad = 0

{"RESULT":"SUCCES","Begin":0.00,"Vad":1,"End":7.89,"LastFlag":1,"Content":"你好,今天天气怎么样?还不错。"}

 

Immediate = 1

{"RESULT":"SUCCES","Begin":0.00,"Vad":0,"End":1.52,"LastFlag":0,"Content":""}

{"RESULT":"SUCCES","Begin":0.00,"Vad":0,"End":1.82,"LastFlag":0,"Content":""}

{"RESULT":"SUCCES","Begin":0.00,"Vad":0,"End":2.36,"LastFlag":0,"Content":"你好"}

{"RESULT":"SUCCES","Begin":0.00,"Vad":1,"End":2.74,"LastFlag":0,"Content":"你好,"}

 

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":3,56,"LastFlag":0,"Content":""}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":3,68,"LastFlag":0,"Content":""}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":4.12,"LastFlag":0,"Content":"今天"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":3,56,"LastFlag":0,"Content":"今天"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":7.8,"LastFlag":0,"Content":"今天天"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":7.8,"LastFlag":0,"Content":"今天天"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":7.8,"LastFlag":0,"Content":"今天天气"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":7.8,"LastFlag":0,"Content":"今天天气"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":7.8,"LastFlag":0,"Content":"今天天气怎"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":7.8,"LastFlag":0,"Content":"今天天气怎"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":7.8,"LastFlag":0,"Content":"今天天气怎么"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":7.8,"LastFlag":0,"Content":"今天天气怎么"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":0,"End":7.8,"LastFlag":0,"Content":"今天天气怎么样"}

{"RESULT":"SUCCES","Begin":3.45,"Vad":1,"End":7.8,"LastFlag":1,"Content":"今天天气怎么样?"}

{"RESULT":"SUCCES","Begin":6.23,"Vad":0,"End":7.89,"LastFlag":0,"Content":""}

{"RESULT":"SUCCES","Begin":6.23,"Vad":0,"End":7.89,"LastFlag":0,"Content":""}

{"RESULT":"SUCCES","Begin":6.23,"Vad":0,"End":7.89,"LastFlag":0,"Content":"还不"}

{"RESULT":"SUCCES","Begin":6.23,"Vad":0,"End":7.89,"LastFlag":0,"Content":"还不"}

{"RESULT":"SUCCES","Begin":6.23,"Vad":0,"End":7.89,"LastFlag":0,"Content":"还不错"}

{"RESULT":"SUCCES","Begin":6.23,"Vad":1,"End":7.89,"LastFlag":1,"Content":"还不错。"}

 


免费试用
电话咨询
热门产品
免费体验
QQ客服