问题描述
我正在尝试识别用户使用麦克风讲话的内容,并将其与预定义文本进行比较并验证。我使用过System.Speech dll。
我对此有疑问。
1.目前我正在使用语法生成器它中的编码值并将其与用户所说的相匹配。我的代码如下。
以下代码的问题是,有时它会匹配听起来相似的单词
例如听到和年。如果我有话说开发者,如果用户说开发,那么它将从语法中选择开发者。那么有没有办法避免它或提高它的准确性?
2.有没有办法记录用户说的所有内容然后进行比较?如果是,那怎么样?
我尝试过:
static void Main(字符串 [] args)
{
SpeechRecognizer识别器= 新 SpeechRecognizer();
选择颜色= 新选择();
colors.Add( new string [] { red, green , blue});
GrammarBuilder gb = new GrammarBuilder();
gb.Append(colors);
语法g = new 语法(gb);
gb.Culture = Thread.CurrentThread.CurrentCulture;
recognizer.LoadGrammar(g);
recognizer.SpeechRecognized + =
new EventHandler< SpeechRecognizedEventArgs>(sre_SpeechRecognized);
}
void sre_SpeechRecognized( object sender,SpeechRecognizedEventArgs e)
{
if (e.Result.Text == red)
{
Console.WriteLine( 识别为红色色跨度>);
}
}
Hi,
I'm trying to recognize what user is speaking using microphone and compare it with the predefined text and validate. I have used the System.Speech dll.
I have doubts regarding the same.
1.Currently I am using grammar builder with hard-coded values in it and matching it with what user is saying.My Code below.
Problem with below code is that sometimes it matches words which sound similar
for example "hear" and "year". Also if I have word say "developer" and if user says "development" then it will pick "developer" from grammar. So is there way to avoid it or increase the accuracy of it?
2. Is there a way where I can record everything what user has said and then compare it? If yes, then how?
What I have tried:
static void Main(string[] args) { SpeechRecognizer recognizer = new SpeechRecognizer(); Choices colors = new Choices(); colors.Add(new string[] { "red", "green", "blue" }); GrammarBuilder gb = new GrammarBuilder(); gb.Append(colors); Grammar g = new Grammar(gb); gb.Culture = Thread.CurrentThread.CurrentCulture; recognizer.LoadGrammar(g); recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized); } void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { if (e.Result.Text == "red") { Console.WriteLine("Recognized red color"); } }
这篇关于语音识别准确度C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!