如何在C#中为语音识别项目创建自定义语法文件 [英] how to create an custom grammer file in C# for speech Recognition project
本文介绍了如何在C#中为语音识别项目创建自定义语法文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码用于创建语法文件...但是有一些问题
代码如下
I have following code for creating an grammer file ... but have some problem
code as follows
private SpeechRecognitionEngine rec = new SpeechRecognitionEngine();
rec.SetInputToDefaultAudioDevice();
string [] s={"My Computer","My Document","C Drive"};
grammerbuilder gb=new grammerBuilder();
gb.Append(s);
rec.LoadGrammar(gb);
rec.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(rec_SpeechRecognized);
rec.RecognizeAsync(RecognizeMode.Multiple);
//RecognizedPhrase wordes = new RecognizedPhrase();
// this is an event method
void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
foreach (RecognizedWordUnit word in e.Result.Words)
{
strdata = strdata +" "+ word.Text;
}
textBox1.Text = strdata;
请通过运行它查看上面的代码并解决我的问题...
尽快给我答复...
我在等你...
please see the above code by running it and solve my problem...
give me reply as soon as possible...
i am waiting for you...
推荐答案
这是给你的好文章
创建语音识别语法 [ C#语音转文本 [ C#中的语音识别 [
here is a good article for you
Create a Speech Recognition Grammar[^]
here are some best articles for Speech Recognition
C# Speech to Text[^]
Speech recognition in C#[^]
这篇关于如何在C#中为语音识别项目创建自定义语法文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文