的WinForms SpeechRecognitionEngine [英] winforms SpeechRecognitionEngine

查看:115
本文介绍了的WinForms SpeechRecognitionEngine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经开始播放有关与speechRecognitionEngine,并建立了一个非常基本的应用程序基于一个,我们发现栈溢出。低于code: -

we have started to play about with the speechRecognitionEngine, and built a very basic app based on one that we found on stack overflow. Code below:-

public partial class Form1 : Form
{
    SpeechRecognitionEngine sr = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US")); 

    public Form1()
    {
        InitializeComponent();
        // Create an in-process speech recognizer for the en-US locale.

    }

    private void BeginSpeach()
    {
        //Create grammar
        Choices words = new Choices();
        words.Add("Hi");
        words.Add("No");
        words.Add("Yes");

        Grammar wordsList = new Grammar(new GrammarBuilder(words));

        wordsList.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(rec_SpeechRecognized);
        sr.LoadGrammar(wordsList);

        sr.SetInputToDefaultAudioDevice();
        sr.RecognizeAsync();
    }


    void rec_SpeechRecognized(object sender, RecognitionEventArgs e)
    {
        MessageBox.Show(e.Result.Text);
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        BeginSpeach();
    }
}

这似乎工作太棒了。唯一的问题是,一旦检测到的字喜,那就是,它不会背叛了。 有没有办法让这个总是听呢?所以我可以说你好,然后选择否,然后选择是。

This seems to work great. The only issue is that once it has detected the word "hi", thats is, it won't defect any more. Is there a way to get this to always listen? so i can say "hi", then "no", then "yes".

我们希望建立在此创建命令的列表

We hope to build on this to create a list of commands

感谢您的任何意见

推荐答案

西门,看看这个MSDN网页,其中有关于如何使用的例子监听模式

Simon, check this MSDN page which has an example on how to use Listen Mode

<一个href="http://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognizer.statechanged%28v=vs.110%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognizer.statechanged%28v=vs.110%29.aspx

这篇关于的WinForms SpeechRecognitionEngine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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