使用c#进行语音识别 [英] Speech Recognition with c#

查看:128
本文介绍了使用c#进行语音识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目在这里遇到问题,我想在计算机询问其姓名时保存该人的姓名!到中的文本文件:\。

你可以指导我吗,如果我需要为名字创建一个单独的语法。

谢谢

Hi, I am having a problem in my project here, i want to save the name of the person when the computer ask for its name! to text file in c:\.
can you please guide me on this, if i need to create a separate grammar for the names.
Thanks

namespace mypro
{
    public partial class MainWindow : Window
    {
        SpeechRecognitionEngine en = new SpeechRecognitionEngine();

        public MainWindow()
        {
            InitializeComponent();

            en.SetInputToDefaultAudioDevice();

            Choices ch = new Choices("Hello","hey");
            Grammar h = new Grammar(ch.ToGrammarBuilder());
            h.Name = "ha";

   en.LoadGrammarAsync(h);

   en.RecognizeAsync(RecognizeMode.Multiple);

  en.SpeechRecognized += new EventHandler<Speech Recognized EventArgs>(en_SpeechRecognized)
            
        }


public void en_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            if (e.Result.Grammar.Name == "ha")
            {
                switch (e.Result.Text)
                {
                         
                    case "Hello":
                        Say("hi, may i know your name?");
                         break;
                    case "hey":
                         Say("hi, may i know your name?");
                        break;
                }
            }
        }

    public void Say(string input)
        {
            var s = new SpeechSynthesizer();
            var sa = new Prompt(input);
            s.Speak(sa);
            
        }

       
    }
}

推荐答案

如果您按照此主题找到答案:

http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/97c58d33-d9d5-4a2c-867f-90019cdfff77/ [ ^ ]



它还取决于您使用的语言。
If you follow this thread youll find your answer:
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/97c58d33-d9d5-4a2c-867f-90019cdfff77/[^]

It also depends on what language you are thinking of using though.


recongition系统只会识别那些是已经在语法文件中

意味着你不能直接为语法文件添加名称
recongition system will only recognize those words which are already in the grammar file
means you can not directly add names to the grammar files


不,以上解决方案都没有帮助我!别人有什么要补充的。请帮我找一个解决方案。
Nope , none of above solutions helped me! Anybody else has anything to add. please help me find a solution.


这篇关于使用c#进行语音识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆