找传奇、传世资源到传世资源站!

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

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

使用讯飞科技的语音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

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