欢迎来到传世资源网!
加载中...
正在加载,请耐心等待...
本站为收藏、学习站,如有侵权,请联系管理员删除!

本人共享:语音实时转写,C#实现

介绍 评论 失效链接反馈

使用讯飞科技的语音API,实现语音实时转写from clipboard
from clipboard
from clipboard
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace 讯飞语音Windows
{
    public static class MSPDLL
    {
        [DllImport("msc.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Winapi)]
        public static extern int MSPLogin(string usr, string pwd, string param);
        [DllImport("msc.dll")]
        public static extern int MSPLogout();
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern IntPtr MSPGetVersion(string verName, ref int errorCode);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern IntPtr MSPUploadData(string dataName, IntPtr data, int dataLen, string param, ref int errorCode);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern int MSPSetParam(string paramName, string paramValue);
    }

    public partial class QTTS
    {
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern IntPtr QTTSSessionBegin(string param, ref int errorCode);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern int QTTSTextPut(string sessionID, string textString, int txtLen, string param);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern IntPtr QTTSAudioGet(string sessionID, ref int audioLen, ref int synthStatus, ref int errorCode);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern int QTTSSessionEnd(string sessionID, string hints);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern int QTTSGetParam(string sessionID, string paramName, string paramValue, ref int valueLen);
    }

    public partial class QISR
    {
        //typedef int ( *GrammarCallBack)( int, const char*, void*);
        //typedef int ( *LexiconCallBack)( int, const char*, void*);
        public delegate int GrammarCallBack(int errorCode, string info, IntPtr userData);
        public delegate int LexiconCallBack(int errorCode, string info, IntPtr userData);

        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern IntPtr QISRSessionBegin(string grammarList, string param, ref int errorCode);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern int QISRAudioWrite(string sessionID, IntPtr waveData, int waveLen, int audioStatus, ref int epStatus, ref int recogStatus);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern IntPtr QISRGetResult(string sessionID, ref int rsltStatus, int waitTime, ref int errorCode);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern int QISRSessionEnd(string sessionID, string hints);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern int QISRGetParam(string sessionID, string paramName, string paramValue, ref int valueLen);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern int QISRBuildGrammar(string grammarType, string grammarContent, int grammarLength, string param, GrammarCallBack callback, IntPtr userData);
        [DllImport("msc.dll", CharSet = CharSet.Ansi)]
        public static extern int QISRUpdateLexicon(string lexiconName, string lexiconContent, int lexiconLength, string param, LexiconCallBack callback, IntPtr userData);
    }
}

下载声明:

本站资源均有第三方用户自行上传分享推荐,非本站自制,仅供玩家做交流学习之用!切勿用于商业用途!游戏作品版权归原作者享有,如有版权问题,请附带版权证明至邮件,本平台将应您的要求删除。
相关推荐:

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复