D
D
Didar Kamiljanow2022-02-23 19:49:13
Speech recognition
Didar Kamiljanow, 2022-02-23 19:49:13

Speech recognition in C#?

Created a simple WinForm program that recognizes speech using the Microsoft.Speech library. Everything works fine, but there is one drawback and this is the creation of grammar. That is, he understands only certain words. Tell me how to do without creating a grammar, or advise another offline speech recognizer without a grammar.

SpeechRecognitionEngine sre;
        CultureInfo ci;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ci = new CultureInfo("ru-RU");
            sre = new SpeechRecognitionEngine(ci);
            sre.SetInputToDefaultAudioDevice();

            sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(Sre_SpeechRecognized);

            Choices ch = new Choices();
            ch.Add("Привет");

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

            Grammar grammar = new Grammar(gb);

            sre.LoadGrammar(grammar);
            sre.RecognizeAsync(RecognizeMode.Multiple);
        }

        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)
M
MaxKozlov, 2022-02-24
@DidarCoder

Vosk
Tried only on python, but c# interface seems to be present
https://github.com/alphacep/vosk-api

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question