Hello friends,
I am in a big trouble .I m building an application which use speech Recoginiztion. I m getting "A first chance exception of type 'System.InvalidOperationException' occurred in System.Speech.dll" Exception and noting is recognized pls help me My Code is
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.Recognition;
using System.Speech.Synthesis;
using System.Threading;
namespace Text_To_Speech
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SpeechSynthesizer sSynth = new SpeechSynthesizer();
SpeechRecognitionEngine sRecoEng = new SpeechRecognitionEngine();
PromptBuilder pBuild = new PromptBuilder();
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
pBuild.ClearContent();
pBuild.AppendText(textBox1.Text.ToString());
sSynth.Speak(pBuild);
}
private void button2_Click(object sender, EventArgs e)
{
button2.Enabled = false;
Choices GoodOne = new Choices();
GoodOne.Add(new String[] { "Hello", "Up", "Down", "Good Morning", "Computer" });
try
{
Grammar Gra = new Grammar(new GrammarBuilder(GoodOne));
sRecoEng.RequestRecognizerUpdate();
sRecoEng.LoadGrammar(Gra);
sRecoEng.SpeechRecognized += sRecoEng_SpeechRecognized;
sRecoEng.SetInputToDefaultAudioDevice();
sRecoEng.RecognizeAsync(RecognizeMode.Multiple);
sRecoEng.Dispose();
}
catch
{
return;
}
}
void sRecoEng_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show(e.Result.Text.ToString());
}
}
}