Answer the question
In order to leave comments, you need to log in
C# WinForms, Error while working with Microsoft.Speech?
Good day friends, I only know basic knowledge of C # and I was interested in creating a simple program for speech recognition, I used the Microsoft.Speech library and downloaded all the data and the language pack, but I had a problem compiling programs, please tell me what could be problem:
Error:
Below is the code of the program:
private SpeechRecognitionEngine sre;
private CultureInfo ci;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
ci = new CultureInfo("ru-RU");
sre = new SpeechRecognitionEngine(ci);
sre.SetInputToDefaultAudioDevice();
sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(Sre_SpeechRecognized);
Choices ch = new Choices();
ch.Add(new string[]
{
"Один",
"Два",
"Три"
});
GrammarBuilder gb = new GrammarBuilder();
gb.Append(ch);
Grammar g = new Grammar(gb);
sre.LoadGrammar(g);
sre.RecognizeAsync(RecognizeMode.Multiple);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void Sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if(e.Result.Confidence > 0.12)
{
MessageBox.Show(e.Result.Text);
}
}
Answer the question
In order to leave comments, you need to log in
Well, the error is not in the code, but in the fact that Microsoft.Speech is crooked. Reinstalling might help.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question