资源简介
c#实现科大讯飞语音听写功能,如果有需要的话,你得在科大讯飞官网上创建语音听写应用服务,并在程序中使用自己的APPID
代码片段和文件信息
using audio;
using System;
using System.IO;
using System.Media;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace asr
{
public static class asr_demo
{
public static string ASR_RES_PATH = “fo|res/asr/common.jet“; //离线语法识别资源路径
public static string GRM_BUILD_PATH = “res/asr/GrmBuilld“; //构建离线语法识别网络生成数据保存路径
public static string GRM_FILE = “call.bnf“; //构建离线识别语法网络所用的语法文件
public static string LEX_NAME = “contact“; //更新离线识别语法的contact槽(语法文件为此示例中使用的call.bnf)
public static string get_audio_file()
{
char key = ‘\0‘;
while (key != 27) //按Esc则退出
{
Console.Write(“请选择音频文件:\n“);
Console.Write(“1.打电话给丁伟\n“);
Console.Write(“2.打电话给黄辣椒\n“);
key = Console.ReadKey(true).KeyChar;
switch (key)
{
case ‘1‘:
Console.Write(“\n1.打电话给丁伟\n“);
return “wav/ddhgdw.pcm“;
case ‘2‘:
Console.Write(“\n2.打电话给黄辣椒\n“);
return “wav/ddhghlj.pcm“;
default:
continue;
}
}
//exit(0);
return null;
}
public static int build_grammar(IntPtr udata)
{
FileStream fs = new FileStream(GRM_FILE FileMode.Open FileAccess.Read);
StreamReader sr = new StreamReader(fs Encoding.Default);
sr.baseStream.Seek(0 SeekOrigin.Begin);
string s = sr.ReadToEnd();
sr.Close();
fs.Close();
byte[] data = Encoding.Default.GetBytes(s);
uint grm_cnt_len = (uint)data.Length;
IntPtr grm_content = Marshal.AllocHGlobal(data.Length);
Marshal.Copy(data 0 grm_content data.Length);
string grm_build_params = string.Format(“engine_type = local asr_res_path = {0} sample_rate = {1} grm_build_path = {2} “ ASR_RES_PATH DefineConstantsAsr_demo.SAMPLE_RATE_16K GRM_BUILD_PATH);
int ret = qisr.QISRBuildGrammar(Marshal.StringToHGlobalAnsi(“bnf“) grm_content grm_cnt_len Marshal.StringToHGlobalAnsi(grm_build_params) build_grm_cb udata);
Marshal.FreeHGlobal(grm_content);
return ret;
}
public static int update_lexicon(IntPtr udata)
{
string lex_content = “丁伟\n黄辣椒“;
uint lex_cnt_len = (uint)Encoding.Default.GetByteCount(lex_content);
string update_lex_params = string.Format(“engine_type = local text_encoding = GB2312 asr_res_path = {0} sample_rate = {1} grm_build_path = {2} grammar_list = {3} “ ASR_RES_PATH DefineConstantsAsr_demo.SAMPLE_RATE_16K GRM_BUILD_PATH grammarId);
int ret = qisr.QISRUpdateLexicon(LEX_NAME lex_content
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 138 2019-01-26 13:59 asr_demo\.vs\asr\DesignTimeBuild\.dtbcache
..A..H. 50176 2019-01-28 10:43 asr_demo\.vs\asr\v15\.suo
文件 0 2019-01-26 11:52 asr_demo\.vs\asr\v15\Server\sqlite3\db.lock
文件 630784 2019-01-26 14:07 asr_demo\.vs\asr\v15\Server\sqlite3\storage.ide
文件 32768 2019-01-28 10:42 asr_demo\.vs\asr\v15\Server\sqlite3\storage.ide-shm
文件 4231272 2019-01-28 10:43 asr_demo\.vs\asr\v15\Server\sqlite3\storage.ide-wal
....... 189 2016-07-05 09:44 asr_demo\asr\App.config
文件 2894 2019-01-26 12:02 asr_demo\asr\asr.csproj
....... 228 2016-07-05 09:44 asr_demo\asr\asr.csproj.user
文件 17668 2019-01-28 10:43 asr_demo\asr\asr_demo.cs
文件 41472 2019-01-26 14:07 asr_demo\asr\bin\Debug\asr.exe
文件 189 2016-07-05 09:44 asr_demo\asr\bin\Debug\asr.exe.config
文件 19968 2019-01-26 14:07 asr_demo\asr\bin\Debug\asr.pdb
....... 22696 2016-07-05 09:44 asr_demo\asr\bin\Debug\asr.vshost.exe
....... 189 2016-07-05 09:44 asr_demo\asr\bin\Debug\asr.vshost.exe.config
....... 490 2016-07-05 09:44 asr_demo\asr\bin\Debug\asr.vshost.exe.manifest
文件 244796 2017-02-26 15:57 asr_demo\asr\bin\Debug\audio_source\cn_syll.wav
文件 286396 2017-02-26 15:57 asr_demo\asr\bin\Debug\audio_source\cn_word.wav
文件 339244 2017-02-26 15:57 asr_demo\asr\bin\Debug\audio_source\en_word.wav
文件 122156 2017-02-26 15:57 asr_demo\asr\bin\Debug\audio_source\test.wav
文件 323672 2017-02-26 15:57 asr_demo\asr\bin\Debug\audio_source\test1.wav
文件 139442 2017-02-26 15:57 asr_demo\asr\bin\Debug\audio_source\test2.wav
文件 56640 2018-12-07 11:40 asr_demo\asr\bin\Debug\audio_source\关机1.pcm
....... 777 2016-07-05 09:44 asr_demo\asr\bin\Debug\call.bnf
....... 21 2016-07-05 09:44 asr_demo\asr\bin\Debug\msc\84e346e9fb724d989e55e5485b117c4c\cfg.ldata
....... 141 2016-07-05 09:44 asr_demo\asr\bin\Debug\msc\84e346e9fb724d989e55e5485b117c4c\k.dat
....... 10 2016-07-05 09:44 asr_demo\asr\bin\Debug\msc\84e346e9fb724d989e55e5485b117c4c\u.data
文件 12 2019-01-26 14:07 asr_demo\asr\bin\Debug\msc\90e18c6b7391011e342b0b332650e544\u.data
....... 178797 2016-07-05 09:44 asr_demo\asr\bin\Debug\msc\auth.log
文件 30762 2019-01-26 13:44 asr_demo\asr\bin\Debug\msc\auth_local_check.log
............此处省略209个文件信息
相关资源
- 科大讯飞 语音唤醒及语音听写服务
- C#接讯飞实现语音听写功能demowindows
- c# webapi 实现科大讯飞语音听写功能
- C#调用百度语音识别
- C# 语音识别
- c#(vs2017)阿里云语音识别接口demo
- 科大讯飞C#语音识别代码
- 语音录音、合成、识别 C#科大讯飞源
- C#接科大讯飞在线语音合成Windows
- 基于科大讯飞语音识别
- C# 语音识别 语音合成 .rar
- Unity Windows Speech
- c# 用SAPI实现语音识别及文本转换的详
- 语音识别系统(asp.net+c#)
- 基于讯飞的离线语音识别C#
- c# 语音识别 智能机器人 语音问答
- C#(VS2017)百度语音识别demo
- 语音识别+文字语音合成C#
- 用C#实现文本朗读和语音识别功能
- c#语音识别及朗读系统_基于speechSDK开
- C#版本语音识别
- 科大讯飞语音识别最新流式接口C# d
- c#实现讯飞语音识别
- speechstt c#写的语音识别程序
- Speech 语音识别功能
- c#实现百度语音识别.rar
- C#科大讯飞源文件
- 讯飞语音播放
- 语音识别 -科大讯飞语音库SDK开发接口
- C# 语音识别+ 文字朗读 开发
评论
共有 条评论