简体   繁体   中英

C# Speech Recognition

Where can I find references and full documentation for the C# speech recognition namespace. MSDN only provides a very brief description of the members and nothing more from what I can find. Is there an absolute resource for theses kinds of things. Mostly everything I'm learning is from other tutorials or snippets in forums.

Intro: Speech Recognition

Code examples covering most of the basics:

Getting Started with Speech Recognition

The basic operations that speech recognition applications perform: - Starting the speech recognizer.

  • Creating a recognition grammar.

  • Loading the grammar into a speech recognizer.

  • Registering for speech recognition event notification.

  • Creating a handler for the speech recognition event.

I found that the latest MSDN pages on System.Speech.Recognition for .NET 4 are skimpy on the details, but the older pages for .NET 3.5 have more details. For a quick comparison I just grabbed these two pages:

vs.

The .NET 3.5 docs have detailed remarks and examples. The .NET 4.0 versions just have definitions.

I found the helpfile that comes with the Server Speech Platform SDK has details that the .NET 4.0 MSDN pages leave off - http://www.microsoft.com/downloads/en/details.aspx?FamilyID=1b1604d3-4f66-4241-9a21-90a294a5c9a4 .

To get started with .NET speech, there is a very good article that was published a few years ago at http://msdn.microsoft.com/en-us/magazine/cc163663.aspx . It is probably the best introductory article I've found so far. It is a little out of date, but very helfpul. (The AppendResultKeyValue method was dropped after the beta and likely other breaking changes.)

Firstly, you add the library for Speech Recognition.

using System.Speech.Recognition

If you cannot load the library, you can add it by using add reference. Go

Project>Add Reference>Browse

Generally, System.Speech.dll is in C:\\Program Files\\Reference Assemblies\\Microsoft\\Framework\\v3.0

Here, the example code that recognizes "Yes","No","In","Out" is below:

namespace SpeechRecognition
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            SpeechRecognizer sr = new SpeechRecognizer();
            Choices ch = new Choices();
            ch.Add(new string[] { "yes", "no","in","out" });

            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(ch);

            Grammar gr = new Grammar(gb);

            sr.LoadGrammar(gr);

            sr.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sr_SpeechRecognition);

        }

        private void sr_SpeechRecognition(object sender, SpeechRecognizedEventArgs e)
        {
            MessageBox.Show(e.Result.Text);

        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM