c# 讯飞语音评测

192 阅读1分钟

1. 到官网注册账号,下载对应到sdk

www.xfyun.cn/services/is…

2. 拷贝sdk中,bin文件的msc.dll到项目路径下

3. 封装msc.dll,实现C# 接口调用:

```c#

public class Speech

{

[DllImport("msc.dll", CallingConvention = CallingConvention.StdCall)]

public static extern int MSPLogin(string usr, string pwd, string parameters);


[DllImport("msc.dll", CallingConvention = CallingConvention.StdCall)]

public static extern int MSPLogout();


//开始一次语音评测

[DllImport("msc.dll", CallingConvention = CallingConvention.StdCall)]

public static extern IntPtr QISESessionBegin(string paramList, string userModelId, ref int errorCode);


//写入待评测的文本

[DllImport("msc.dll", CallingConvention = CallingConvention.StdCall)]

public static extern int QISETextPut(IntPtr sessionID, string textString, uint textLen, string paramList);


//写入本次评测的音频

[DllImport("msc.dll", CallingConvention = CallingConvention.StdCall)]

public static extern int QISEAudioWrite(IntPtr sessionID, byte[] waveData, uint waveLen, int audioStatus,ref EpStatus epStatus,ref RecoStatus Status);


//获取评测结果

[DllImport("msc.dll", CallingConvention = CallingConvention.StdCall)]

public static extern IntPtr QISEGetResult(IntPtr sessionID, ref uint rsltLen,ref RecoStatus rsltStatus,ref int errorCode);


//结束本次语音评测

[DllImport("msc.dll", CallingConvention = CallingConvention.StdCall)]

public static extern int QISESessionEnd(string sessionID, string hints);

}

```


4. 按照官网的流程图,完成口语评测

img