D
D
Didar Kamiljanow2022-01-26 20:04:55
Microsoft
Didar Kamiljanow, 2022-01-26 20:04:55

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:
61f17ef15aae5386475854.png

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

1 answer(s)
A
Alexander Ananiev, 2022-01-26
@DidarCoder

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 question

Ask a Question

731 491 924 answers to any question