通过语音识别控制电脑 [英] control pc through speech recognition
本文介绍了通过语音识别控制电脑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个通过语音来控制你的个人计划,意味着当我说打开我的电脑,然后我的电脑打开,或者控制其他功能时,我已经尝试了很多时间但是陷入了代码之间,我的代码从用户获取语音输入但不比较
这里是代码:
I'm working on a uni project to control your PC through voice, means when i say open my computer, then my-computer open, or control other functions,i have tried a lots of time but stuck in between code, my code gets voice input from user but doesn't compare
here is code:
{
SpeechRecognizer recognizer = new SpeechRecognizer();
recognizer.Enabled = true;
Choices folderPath= new Choices();
folderPath.Add(new string[] { "My Computer", "My Documents", "my docs", "Sumeet", "gehi"});
GrammarBuilder gb = new GrammarBuilder(folderPath);
Grammar gramer = new Grammar(gb);
recognizer.LoadGrammar(gramer);
gramerSpeechRecognized+=new EventHandler<SpeechRecognizedEventArgs (gramer_SpeechRecognized);
}
void gramer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result.Text == "computer" || e.Result.Text=="my computer")
{
string myComputerPath = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
System.Diagnostics.Process.Start("explorer", myComputerPath);
//OR
//System.Diagnostics.Process.Start("explorer", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
}
else
{
// give output what user have said
textBox1.Text = e.Result.Text;
}
}
需要你的帮助开发人员...
我的代码中是否有任何错误或如何与语音进行比较
need your help developers...
is there any mistakes in my code or how to compare with speech
推荐答案
可能我的电脑
是大写的,所以输入是我的电脑
,它不等于我的电脑
!
试试这个:
Hi,
Probably,"My Computer"
is capitalized, so the input is"My Computer"
, which is NOT equal to"my computer"
!
Try this:
void gramer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
string resultText = e.Result.Text.ToLower();
if (resultText == "computer" || resultText =="my computer")
{
希望这会有所帮助。
Hope this helps.
请点击以下链接。它有很好的解释:
[ ^ ]
Follow below link. It has nice explanation :
Speech recognition, speech to text, text to speech, and speech synthesis in C#[^]
这篇关于通过语音识别控制电脑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文