Hy everybody, I was trying to "implement" Speech Recognition in VS 2008 c#, but it seems to have some problems. As I know .NET 3.5 is including SDK for speech recognition and I am using .NET 3.5 I just started my sample aplication like this (it was an example on the web) using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Speech; namespace System.Speech.Recognition { public partial class Form1 : Form { SpeechRecognizer rec = new SpeechRecognizer(); public Form1() { InitializeComponent(); rec.SpeechRecognized += rec_SpeechRecognized; } void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { lblLetter.Text = e.Result.Text; } void Form1_Load(object sender, EventArgs e) { var c = new Choices(); for (var i = 0; i <= 100; i++) c.Add(i.ToString()); var gb = new GrammarBuilder(c); var g = new Grammar(gb); rec.LoadGrammar(g); rec.Enabled = true; } } Code (markup): Does anyone has a working sample for it ? Thanks Daniel Rosca
What's the problem you're having? For speech recognition to work, you have to have some sort of speech recognition installed. Vista has one built in, and Office XP and newer has one. If you're on WinXP without Office installed you probably won't have an engine and will need the Microsoft Speech SDK, available at: http://www.microsoft.com/downloads/...97-40a7-453f-b0ee-6583171b4530&displaylang=en The following is only a guess -- I don't have a compiler handy. In your constructor, this: rec.SpeechRecognized += rec_SpeechRecognized; Code (markup): Might need to be this: rec.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(rec_SpeechRecognized); Code (markup):
Ok, let me explain the problem better, maybe i didn't explained it so good. I'm trying to catch what an user is speaking, of course, not as dictation. I have the code, but I have some problems with the Speech on it. I'm getting first error when I'm writting using System.Speech; Code (markup): The statement is not as a recommended command from VS 2008, but actually i'm writting it. After this step I name the namespace as: namespace System.Speech.Recognition Code (markup): After this namespace name, the problem with the System.Speech from the beggining will not be anymore. I'm getting a new error from VS 2008 in the following code: public partial class Form1 : Form { SpeechRecognizer rec = new SpeechRecognizer(); -- on this line at SpeechRecognizer public Form1() { InitializeComponent(); rec.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(rec_SpeechRecognized); -- on this line I'm getting an error at "<SpeechRecognizedEventArgs>" } void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { lblLetter.Text = e.Result.Text; } private void Form1_Load(object sender, EventArgs e) { var c = new Choices(); -- At this line I also have problem c.Add("one"); c.Add("two"); c.Add("three"); c.Add("four"); var gb = new GrammarBuilder(c); --- For this and next line I also have problems var g = new Grammar(gb); rec.LoadGrammar(g); rec.Enabled = true; } } Code (markup): I just want to get what the user is speaking and check if that word is "one" for example. If the word is "one" something should be updated in the program. Can anyone help me?