none
c# error in speech recognition RRS feed

  • Pergunta

  • The code worked fine at first but then it suddently stopped working and i dont know what it is. here is the code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Speech.Synthesis;
    using System.Speech.Recognition;
    using System.Threading;


    namespace speaker
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            SpeechSynthesizer sSynth = new SpeechSynthesizer();
            PromptBuilder pBuilder = new PromptBuilder();
            SpeechRecognitionEngine sRecognize = new SpeechRecognitionEngine();

            private void Form1_Load(object sender, EventArgs e)
            {

            }

            private void button1_Click(object sender, EventArgs e)
            {
                pBuilder.ClearContent();
                pBuilder.AppendText(textBox1.Text);
                sSynth.Speak(pBuilder);
                
            }

            private void button2_Click(object sender, EventArgs e)
            {
                button2.Enabled = false;
                button2.Enabled = true;
                Choices sList = new Choices();
                sList.Add(new string[] {"hello", "hi", "exit" });
                Grammar gr = new Grammar(new GrammarBuilder(sList));
                try
                {
                    sRecognize.RequestRecognizerUpdate();
                    sRecognize.LoadGrammar(gr);
                    sRecognize.SpeechRecognized += sRecognize_SpeechRecognized;
                    sRecognize.SetInputToDefaultAudioDevice();
                    sRecognize.RecognizeAsync(RecognizeMode.Multiple);
                }

                catch
                {
                    return;
                }
            }

            void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
            {
                MessageBox.Show("speech recognised:" + e.Result.Text.ToString());
            }
        }
    }

    quinta-feira, 17 de abril de 2014 09:53

Respostas

  • Hi Velez,

    I'm not sure if it was your intention but you posted your question at the pt-BR forum. This forum uses portuguese as the main language.

    Probably you better remake your post in portuguese or ask this at the en-US forum.

    Anyway, does it return an error? If yes, post the message for us.

    See ya,


    TP.

    • Marcado como Resposta Giovani Cr quinta-feira, 17 de abril de 2014 18:46
    quinta-feira, 17 de abril de 2014 13:31