一个基于c#3.0的开发基于2000/XP/2003下语音识别的通用类
来源:互联网 发布:windows qt开发环境 编辑:程序博客网 时间:2024/03/29 21:25
废话少说看代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SpeechLib;
using System.Windows.Forms;
using System.Collections;
namespace yincheng01@163.com
{
public class speechxp
{
private SpeechLib.SpSharedRecoContext objRecoContext;
private SpeechLib.ISpeechRecoGrammar grammar;
private SpeechLib.ISpeechGrammarRule rule = null;
private SpeechLib.ISpeechGrammarRuleState state;
private SpeechLib.ISpeechPhraseElement PhraseElem;
public System.Windows.Forms.Control cDisplay;
public speechxp(string FileName, Control cDisplay)
{
}
private void initSAPI()
{
try
{
objRecoContext = new SpeechLib.SpSharedRecoContext();
objRecoContext.AudioLevel += new _ISpeechRecoContextEvents_AudioLevelEventHandler(RecoContext_VUMeter);//设置声音事件的响应函数
objRecoContext.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(RecoContext_Recognition);//设置成功识别事件的响应函数
objRecoContext.EventInterests = SpeechLib.SpeechRecoEvents.SRERecognition | SpeechLib.SpeechRecoEvents.SREAudioLevel;//设置响应事件
//create grammar interface with ID = 0
grammar = objRecoContext.CreateGrammar(1);//语法的实例
}
catch (Exception ex)
{
MessageBox.Show("Exception /n" + ex.ToString(), "Error - initSAPI");
}
}
private void SAPIGrammarFromFile(string FileName)
{
try
{
grammar.CmdLoadFromFile(FileName, SpeechLib.SpeechLoadOption.SLODynamic);
grammar.CmdSetRuleIdState(0, SpeechRuleState.SGDSActive);
}
catch
{
MessageBox.Show("载入语法文件失败 " + FileName + "/n", "Error - SAPIGrammarFromFile");
}
}
public void RecoContext_Recognition(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult e)
{
int i;
ArrayList reco = new ArrayList();
string phrase = e.PhraseInfo.GetText(0, -1, true);
cDisplay.Text = e.PhraseInfo.GetText(0, -1, true);
foreach (SpeechLib.ISpeechPhraseElement PhraseElem in e.PhraseInfo.Elements)
{
/// listBox1.Items.Add(PhraseElem.Pronunciation);添加语音指令
}
i = e.PhraseInfo.Elements.Count;
for (int h = 0; h < i; h++)
{
}
}
public void RecoContext_VUMeter(int StreamNumber, object StreamPosition, int e)
{
int hg = e;
}
}
}
类的调用
hhh = new SpRecognition(file); 定义好的语法XML文件
hhh.BeginRec(textBox10); 关联到显示识别结果的控件
- 一个基于c#3.0的开发基于2000/XP/2003下语音识别的通用类
- 一个基于c#3.0的开发基于vista下语音识别的通用类
- 一个基于c#3.0的开发基于vista下语音朗读的通用类
- 一个基于speech API5.1的通用语音识别类
- 一个通用的IBM viavoice语音识别语音朗读的接口,适用于基于IBM viavoice开发
- 基于C#的在线语音识别软件开发
- 一个集成微软语音识别技术与语音朗读的类,基于Microsoft SpeechAPI5.1的开发
- 基于科大讯飞的语音识别
- Android 开发基于百度语音识别技术的小程序
- 基于科大讯飞的语音识别 windows平台开发
- iOS开发 基于系统原生的语音识别助手
- C#3.0基于 Speech.Recognition的grammerbuilder 语音识别定义模糊语法范例
- C#3.0基于 Speech.Recognition的SRGS 语音识别定义模糊语法范例
- 基于TMS320VC5509A的语音识别与控制系统
- 基于matlab的语音识别系统设计
- 基于DBN的语音识别技术分析
- 基于DBN的语音识别技术分析
- 基于Qt的语音识别功能
- 惨,阑尾发炎输液了,难道还得挨一刀?
- IVR(互动式语音应答(IVR,Interactive Voice Response))
- 怎么用SQL语句取出随机的记录?
- 一个C#操作Excel类,功能比较全。
- SQL语句集锦
- 一个基于c#3.0的开发基于2000/XP/2003下语音识别的通用类
- Linq 演变的过程(delegate => Lambda => Linq)
- .NET资源站点汇总
- 判断当前为Smartphone or Pocket PC
- BAPI_TRANSACTION_COMMIT
- sql与PB程序的优化
- 【转】世行警告中國水資源危機嚴重
- Visual Studio 2008 每日提示(二十七)
- 使用 Hibernate 进行大数据量的性能测试