问题描述
http://chupanhcuoi.com.vn/temp/Untitled.png
我有一个小型测试应用程序(对不起,因为源代码是从其他程序复制并由我编辑的),它可以从第一个文本框中的单词中识别单词.该程序可以用某些词完美地工作,但是用某些词却无法工作.例如,我的输入是一二三车书"(语法中包含五个词).该程序可以轻松识别1,2,3,但我永远无法使其识别汽车和书本.
任何人都可以帮助我解释为什么?还是有任何解决方案可以强制以编程方式训练语音识别器中的汽车"和书"这个词?
对不起,我的英语不是母语.
这是我的项目zip文件: http://chupanhcuoi.com.vn/temp/SpeechTest.zip [ ^ ]
抱歉,我不知道如何上传到codeproject.com
语音识别器的代码是从211行到256行.
http://chupanhcuoi.com.vn/temp/Untitled.png
I have this small test application(sorry because the source code is copied from other and edited by me), which can recognize word from the words in the first textbox. the program works perfect with some words, but with somes, it never works. For a sample, my input is "one two three car book" (there are five words contained in the grammar). And the program can recognize 1,2,3 easily, but I can never make it recognize car, and book.
Any one can help me explain why ? Or is there any solution which can force to train the speech recognizer the word "car" and "book" programmatically ?
Sorry for my English, I''m not a native speaker.
Here is my project zip file : http://chupanhcuoi.com.vn/temp/SpeechTest.zip[^]
Sorry that I dont know how to upload to codeproject.com
the code for speech recognizer is from line 211 to line 256.
private void cmdEnable_Click(object sender, System.EventArgs e)//button to start recognizer
{
if (xpmode)
{
//ignore this because these code is for window xp
}
else
{
if (!recInited)
{
//if the button is click the first time, init variables
recognizer = new SpeechRecognitionEngine();
recognizer.SetInputToDefaultAudioDevice();
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
}
else
{
if (recognizer != null)
{
//stop the old recognizer for new grammars defined in the textbox
recognizer.RecognizeAsyncStop();
}
}
changerecDict();
recognizer.RecognizeAsync(RecognizeMode.Multiple);//TurnSpeechRecognitionOn
recInited = true;
}
}
void changerecDict()
{
recogniseDict = grammartext.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (xpmode)
{
}
else
{
recognizer.UnloadAllGrammars();
recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(recogniseDict)))); //[string] contains {"one","two","three","car","book"
}
}
//event 4 xp
private void Reco_Event(int StreamNumber, object StreamPosition,SpeechRecognitionType RecognitionType,ISpeechRecoResult Result)
{
//ignore
}
//event 4 7
private void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
txtReco.Text = e.Result.Text + " " + e.Result.Confidence;
}
推荐答案
这篇关于语音识别器无法识别某些单词!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!