赞
踩
Python调用科大讯飞C语言接口实现语音识别,源代码:
- from ctypes import *
- import time
-
- # 调用动态链接库
- dll = cdll.LoadLibrary("libmsc.so")
- #登录参数,apppid一定要和你的下载SDK对应
- login_params = b"appid = 57738ed9, work_dir = ."
-
- FRAME_LEN = 640 # Byte
-
- MSP_SUCCESS = 0
- # 返回结果状态
- MSP_AUDIO_SAMPLE_FIRST = 1
- MSP_AUDIO_SAMPLE_CONTINUE = 2
- MSP_AUDIO_SAMPLE_LAST = 4
- MSP_REC_STATUS_COMPLETE = 5
- # 你的语音文件路径
- filename = "testAudio.wav"
-
- class Msp:
- def __init__(self):
- pass
-
- def login(self):
- ret = dll.MSPLogin(None, None, login_params)
- # print('MSPLogin =>', ret)
-
- def logout(self):
- ret = dll.MSPLogout()
- # print('MSPLogout =>', ret)
-
- def isr(self, audiofile, session_begin_params):
- ret =
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。