官方文档说明:https://cloud.tencent.com/document/product/1093/35726
接入准备
SDK 获取
实时语音识别 Python SDK 以及 Demo 的下载地址:Python3 SDK、Python2 SDK。
下载下来并且解压
其实我是推荐使用python3的,因为python2停止维护了。
我的路径在:F:codeASR
接入须知
开发者在调用前请先查看实时语音识别的 接口说明,了解接口的使用要求和使用步骤。
开发环境
- 环境依赖 该接口支持 Python3 和 Python2.7 版本,请用户根据需要选择。
- 安装 requests 方法1:pip install requests 。 方法2:先下载 requests,然后进入下载目录执行:python setup.py install 。
返回的结果
代码语言:txt复制D:ProgramDataAnaconda3python.exe E:/code/ASR/python_realtime_asr_sdk_v3/python_realtime_asr_sdk/src/com_tencent_asr_sdk/RasrClient.py
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":0,"text":"","result_number":1,"result_list":[{"slice_type":0,"index":1,"start_time":0,"end_time":256,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":1,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":512,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":2,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":768,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":3,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":1024,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":4,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":1280,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":5,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":1536,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":6,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":1792,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":7,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":2048,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":8,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":2304,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":9,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":2560,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":10,"text":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe3x80x82","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":2816,"voice_text_str":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe3x80x82","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":11,"text":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":3072,"voice_text_str":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":12,"text":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":3328,"voice_text_str":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":13,"text":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":3584,"voice_text_str":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":14,"text":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":3840,"voice_text_str":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":15,"text":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","result_number":1,"result_list":[{"slice_type":2,"index":1,"start_time":0,"end_time":4062,"voice_text_str":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","word_size":0,"word_list":[]}],"final":1}'
Final result: b'{"code":0,"message":"success","voice_id":"fzQsMai10dyqy4JY","seq":15,"text":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","result_number":1,"result_list":[{"slice_type":2,"index":1,"start_time":0,"end_time":4062,"voice_text_str":"xe5x8cx97xe4xbaxacxe7xa7x91xe6x8ax80xe9xa6x86xe3x80x82","word_size":0,"word_list":[]}],"final":1}'
b'{"code":0,"message":"success","voice_id":"GTDUCUtTKpSq0gjq","seq":0,"text":"","result_number":1,"result_list":[{"slice_type":0,"index":1,"start_time":0,"end_time":512,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"GTDUCUtTKpSq0gjq","seq":1,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":1024,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"GTDUCUtTKpSq0gjq","seq":2,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":1536,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"GTDUCUtTKpSq0gjq","seq":3,"text":"","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":2048,"voice_text_str":"","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"GTDUCUtTKpSq0gjq","seq":4,"text":"xe5x90x83xe9xa5xadxe4xbax86xe5x90x97xefxbcx9f","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":2560,"voice_text_str":"xe5x90x83xe9xa5xadxe4xbax86xe5x90x97xefxbcx9f","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"GTDUCUtTKpSq0gjq","seq":5,"text":"xe5x90x83xe9xa5xadxe4xbax86xe5x90x97xefxbcx9f","result_number":1,"result_list":[{"slice_type":1,"index":1,"start_time":0,"end_time":3072,"voice_text_str":"xe5x90x83xe9xa5xadxe4xbax86xe5x90x97xefxbcx9f","word_size":0,"word_list":[]}],"final":0}'
b'{"code":0,"message":"success","voice_id":"GTDUCUtTKpSq0gjq","seq":6,"text":"xe5x90x83xe9xa5xadxe4xbax86xe5x90x97xefxbcx9f","result_number":1,"result_list":[{"slice_type":2,"index":1,"start_time":0,"end_time":3093,"voice_text_str":"xe5x90x83xe9xa5xadxe4xbax86xe5x90x97xefxbcx9f","word_size":0,"word_list":[]}],"final":1}'
Process finished with exit code 0
常见问题
1. python3 SDK密钥的输入