Skip to content

SpeechSynthesizer & SpeechRecognizer

Narendran N

Narendran N

Asked Jul 25, 2016, 3:21 AM EDT2 answers
Share
LinkedInX


Am enhancing en existing web application which makes the visually impaired people, to be used based on the Text to Speech & Speech Recognition

The same code is working fine in windows application, but not in web application.

If I put break point, it's coming to the point but the code is not getting execute.

Here is the code, please do the needful.

Code
     using System.Speech;  
using System.Speech.Synthesis;  
using System.Threading;  
using System.Speech.Recognition;  
  
  
  
 SpeechSynthesizer ss = new SpeechSynthesizer();  
    PromptBuilder pb = new PromptBuilder();  
    SpeechRecognitionEngine sre = new SpeechRecognitionEngine();   
    SpeechRecognizer sr = new SpeechRecognizer();  
  
   protected void btn_Spk_Click(object sender, EventArgs e)      
    {  
        string optiona, optionb, optionc;  
        Choices clist = new Choices();  
        foreach (GridViewRow row in gvtemperament.Rows)  
        {  
            RadioButton rblist1 = ((RadioButton)row.FindControl("rdTemp_Opt1"));  
            RadioButton rblist2 = ((RadioButton)row.FindControl("rdTemp_Opt2"));  
            RadioButton rblist3 = ((RadioButton)row.FindControl("rdTemp_Opt3"));  
            Label lbl1 = (Label)row.FindControl("lbl_desc");  
            if (row.Cells[0].Text == "1")  
            {  
                ss.SelectVoiceByHints(VoiceGender.Female);  
                ss.Volume = 100;  
                ss.Rate = -3;  
                pb.ClearContent();  
                pb.AppendText("Please answer all the Questions and you starts here!");  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                pb.ClearContent();  
                pb.AppendText(lbl1.Text);  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                ss.SelectVoiceByHints(VoiceGender.Male);  
                pb.ClearContent();  
                pb.AppendText("Options are ");  
                ss.Speak(pb);  
  
                optiona = rblist1.Text;  
                optionb = rblist2.Text;  
                optionc = "Not Sure";  
  
                  
                pb.ClearContent();  
                pb.AppendText(optiona);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionb);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionc);  
                ss.Speak(pb);  
  
                Thread.Sleep(150);  
  
                clist.Add(new string[] { "Yes", "No", "Not Sure" });  
                Grammar gr = new Grammar(new GrammarBuilder(clist));  
                try  
                {  
                    sre.RequestRecognizerUpdate();  
                    sre.LoadGrammar(gr);  
                    sre.SpeechRecognized += sre_SpeechRecognized;  
                    sre.SetInputToDefaultAudioDevice();  
                    sre.RecognizeAsync(RecognizeMode.Multiple);  
                }  
                catch (Exception ex)  
                {  
                     this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language=\"javascript\">" + "alert('Error');</script>");  
                }  
            }  
            else if (row.Cells[0].Text == "2")  
            {  
                ss.SelectVoiceByHints(VoiceGender.Female);  
                ss.Volume = 100;  
                ss.Rate = -3;  
  
                pb.ClearContent();  
                pb.AppendText(lbl1.Text);  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                ss.SelectVoiceByHints(VoiceGender.Male);  
                pb.ClearContent();  
                pb.AppendText("Options are ");  
                ss.Speak(pb);  
  
                optiona = rblist1.Text;  
                optionb = rblist2.Text;  
                optionc = "Not Sure";  
  
   
                pb.ClearContent();  
                pb.AppendText(optiona);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionb);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
   
                pb.ClearContent();  
                pb.AppendText(optionc);  
                ss.Speak(pb);  
  
                Thread.Sleep(150);  
                clist.Add(new string[] { "Yes", "No", "Not Sure" });  
                Grammar gr = new Grammar(new GrammarBuilder(clist));  
                try  
                {  
                    sre.RequestRecognizerUpdate();  
                    sre.LoadGrammar(gr);  
                    sre.SpeechRecognized += sre_SpeechRecognized;  
                    sre.SetInputToDefaultAudioDevice();  
                    sre.RecognizeAsync(RecognizeMode.Multiple);  
                }  
                catch (Exception ex)  
                {  
                     this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language=\"javascript\">" + "alert('Error');</script>");  
                }  
            }  
            else if (row.Cells[0].Text == "3")  
            {  
                ss.SelectVoiceByHints(VoiceGender.Female);  
                ss.Volume = 100;  
                ss.Rate = -3;  
  
                pb.ClearContent();  
                pb.AppendText(lbl1.Text);  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                ss.SelectVoiceByHints(VoiceGender.Male);  
                pb.ClearContent();  
                pb.AppendText("Options are ");  
                ss.Speak(pb);  
  
                optiona = rblist1.Text;  
                optionb = rblist2.Text;  
                optionc = "Not Sure";  
                                                             
                pb.ClearContent();  
                pb.AppendText(optiona);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionb);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionc);  
                ss.Speak(pb);  
                Thread.Sleep(150);  
                clist.Add(new string[] { "Yes", "No", "Not Sure" });  
                Grammar gr = new Grammar(new GrammarBuilder(clist));  
                try  
                {  
                    sre.RequestRecognizerUpdate();  
                    sre.LoadGrammar(gr);  
                    sre.SpeechRecognized += sre_SpeechRecognized;  
                    sre.SetInputToDefaultAudioDevice();  
                    sre.RecognizeAsync(RecognizeMode.Multiple);  
                }  
                catch (Exception ex)  
                {  
                      this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language=\"javascript\">" + "alert('Error');</script>");  
                }  
            }  
            else if (row.Cells[0].Text == "4")  
            {  
                ss.SelectVoiceByHints(VoiceGender.Female);  
                ss.Volume = 100;  
                ss.Rate = -3;  
  
                pb.ClearContent();  
                pb.AppendText(lbl1.Text);  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                ss.SelectVoiceByHints(VoiceGender.Male);  
                pb.ClearContent();  
                pb.AppendText("Options are ");  
                ss.Speak(pb);  
  
                optiona = rblist1.Text;  
                optionb = rblist2.Text;  
                optionc = "Not Sure";  
                                       
                pb.ClearContent();  
                pb.AppendText(optiona);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionb);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionc);  
                ss.Speak(pb);  
                Thread.Sleep(150);  
                clist.Add(new string[] { "Yes", "No", "Not Sure" });  
                Grammar gr = new Grammar(new GrammarBuilder(clist));  
                try  
                {  
                    sre.RequestRecognizerUpdate();  
                    sre.LoadGrammar(gr);  
                    sre.SpeechRecognized += sre_SpeechRecognized;  
                    sre.SetInputToDefaultAudioDevice();  
                    sre.RecognizeAsync(RecognizeMode.Multiple);  
                }  
                catch (Exception ex)  
                {  
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language=\"javascript\">" + "alert('Error');</script>");  
                }  
            }  
            else if (row.Cells[0].Text == "5")  
            {  
                ss.SelectVoiceByHints(VoiceGender.Female);  
                ss.Volume = 100;  
                ss.Rate = -3;  
                pb.ClearContent();  
                pb.AppendText(lbl1.Text);  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                ss.SelectVoiceByHints(VoiceGender.Male);  
                pb.ClearContent();  
                pb.AppendText("Options are ");  
                ss.Speak(pb);  
  
                optiona = rblist1.Text;  
                optionb = rblist2.Text;  
                optionc = "Not Sure";  
  
                pb.ClearContent();  
                pb.AppendText(optiona);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionb);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionc);  
                ss.Speak(pb);  
                Thread.Sleep(150);  
                clist.Add(new string[] { "Yes", "No", "Not Sure" });  
                Grammar gr = new Grammar(new GrammarBuilder(clist));  
                try  
                {  
                    sre.RequestRecognizerUpdate();  
                    sre.LoadGrammar(gr);  
                    sre.SpeechRecognized += sre_SpeechRecognized;  
                    sre.SetInputToDefaultAudioDevice();  
                    sre.RecognizeAsync(RecognizeMode.Multiple);  
                }  
                catch (Exception ex)  
                {  
                     this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language=\"javascript\">" + "alert('Error');</script>");  
                }  
            }  
            else if (row.Cells[0].Text == "6")  
            {  
                ss.SelectVoiceByHints(VoiceGender.Female);  
                ss.Volume = 100;  
                ss.Rate = -3;  
                pb.ClearContent();  
                pb.AppendText(lbl1.Text);  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                ss.SelectVoiceByHints(VoiceGender.Male);  
                pb.ClearContent();  
                pb.AppendText("Options are ");  
                ss.Speak(pb);  
  
                optiona = rblist1.Text;  
                optionb = rblist2.Text;  
                optionc = "Not Sure";  
  
                pb.ClearContent();  
                pb.AppendText(optiona);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionb);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionc);  
                ss.Speak(pb);  
                Thread.Sleep(150);  
                clist.Add(new string[] { "Yes", "No", "Not Sure" });  
                Grammar gr = new Grammar(new GrammarBuilder(clist));  
                try  
                {  
                    sre.RequestRecognizerUpdate();  
                    sre.LoadGrammar(gr);  
                    sre.SpeechRecognized += sre_SpeechRecognized;  
                    sre.SetInputToDefaultAudioDevice();  
                    sre.RecognizeAsync(RecognizeMode.Multiple);  
                }  
                catch (Exception ex)  
                {  
                     this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language=\"javascript\">" + "alert('Error');</script>");  
                }  
            }  
            else if (row.Cells[0].Text == "7")  
            {  
                ss.SelectVoiceByHints(VoiceGender.Female);  
                ss.Volume = 100;  
                ss.Rate = -3;  
                pb.ClearContent();  
                pb.AppendText(lbl1.Text);  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                ss.SelectVoiceByHints(VoiceGender.Male);  
                pb.ClearContent();  
                pb.AppendText("Options are ");  
                ss.Speak(pb);  
  
                optiona = rblist1.Text;  
                optionb = rblist2.Text;  
                optionc = "Not Sure";  
  
                pb.ClearContent();  
                pb.AppendText(optiona);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionb);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionc);  
                ss.Speak(pb);  
                Thread.Sleep(150);  
                clist.Add(new string[] { "Yes", "No", "Not Sure" });  
                Grammar gr = new Grammar(new GrammarBuilder(clist));  
                try  
                {  
                    sre.RequestRecognizerUpdate();  
                    sre.LoadGrammar(gr);  
                    sre.SpeechRecognized += sre_SpeechRecognized;  
                    sre.SetInputToDefaultAudioDevice();  
                    sre.RecognizeAsync(RecognizeMode.Multiple);  
                }  
                catch (Exception ex)  
                {  
                     this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language=\"javascript\">" + "alert('Error');</script>");  
                }  
            }  
            else if (row.Cells[0].Text == "8")  
            {  
                ss.SelectVoiceByHints(VoiceGender.Female);  
                ss.Volume = 100;  
                ss.Rate = -3;  
                pb.ClearContent();  
                pb.AppendText(lbl1.Text);  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                ss.SelectVoiceByHints(VoiceGender.Male);  
                pb.ClearContent();  
                pb.AppendText("Options are ");  
                ss.Speak(pb);  
  
                optiona = rblist1.Text;  
                optionb = rblist2.Text;  
                optionc = "Not Sure";  
  
                pb.ClearContent();  
                pb.AppendText(optiona);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionb);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionc);  
                ss.Speak(pb);  
                Thread.Sleep(150);  
                clist.Add(new string[] { "Yes", "No", "Not Sure" });  
                Grammar gr = new Grammar(new GrammarBuilder(clist));  
                try  
                {  
                    sre.RequestRecognizerUpdate();  
                    sre.LoadGrammar(gr);  
                    sre.SpeechRecognized += sre_SpeechRecognized;  
                    sre.SetInputToDefaultAudioDevice();  
                    sre.RecognizeAsync(RecognizeMode.Multiple);  
                }  
                catch (Exception ex)  
                {  
                      this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language=\"javascript\">" + "alert('Error');</script>");  
                }  
            }  
            else if (row.Cells[0].Text == "9")  
            {  
                ss.SelectVoiceByHints(VoiceGender.Female);  
                ss.Volume = 100;  
                ss.Rate = -3;  
                pb.ClearContent();  
                pb.AppendText(lbl1.Text);  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                ss.SelectVoiceByHints(VoiceGender.Male);  
                pb.ClearContent();  
                pb.AppendText("Options are ");  
                ss.Speak(pb);  
  
                optiona = rblist1.Text;  
                optionb = rblist2.Text;  
                optionc = "Not Sure";  
  
                pb.ClearContent();  
                pb.AppendText(optiona);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionb);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionc);  
                ss.Speak(pb);  
                Thread.Sleep(150);  
                clist.Add(new string[] { "Yes", "No", "Not Sure" });  
                Grammar gr = new Grammar(new GrammarBuilder(clist));  
                try  
                {  
                    sre.RequestRecognizerUpdate();  
                    sre.LoadGrammar(gr);  
                    sre.SpeechRecognized += sre_SpeechRecognized;  
                    sre.SetInputToDefaultAudioDevice();  
                    sre.RecognizeAsync(RecognizeMode.Multiple);  
                }  
                catch (Exception ex)  
                {  
                     this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language=\"javascript\">" + "alert('Error');</script>");  
                }  
            }  
            else if (row.Cells[0].Text == "10")  
            {  
                ss.SelectVoiceByHints(VoiceGender.Female);  
                ss.Volume = 100;  
                ss.Rate = -3;  
                pb.ClearContent();  
                pb.AppendText(lbl1.Text);  
                ss.Speak(pb);  
                Thread.Sleep(1500);  
  
                ss.SelectVoiceByHints(VoiceGender.Male);  
                pb.ClearContent();  
                pb.AppendText("Options are ");  
                ss.Speak(pb);  
  
                optiona = rblist1.Text;  
                optionb = rblist2.Text;  
                optionc = "Not Sure";  
  
                pb.ClearContent();  
                pb.AppendText(optiona);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionb);  
                ss.Speak(pb);  
                Thread.Sleep(700);  
  
                pb.ClearContent();  
                pb.AppendText(optionc);  
                ss.Speak(pb);  
                Thread.Sleep(150);  
                clist.Add(new string[] { "Yes", "No", "Not Sure" });  
                Grammar gr = new Grammar(new GrammarBuilder(clist));  
                try  
                {  
                    sre.RequestRecognizerUpdate();  
                    sre.LoadGrammar(gr);  
                    sre.SpeechRecognized += sre_SpeechRecognized;  
                    sre.SetInputToDefaultAudioDevice();  
                    sre.RecognizeAsync(RecognizeMode.Multiple);  
                }  
                catch (Exception ex)  
                {  
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language=\"javascript\">" + "alert('Error');</script>");  
                }  
            }  
        }  
    }  
  
  void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)  
  {  
        foreach (GridViewRow row in gvtemperament.Rows)  
        {  
            RadioButton rblist1 = ((RadioButton)row.FindControl("rdTemp_Opt1"));  
            RadioButton rblist2 = ((RadioButton)row.FindControl("rdTemp_Opt2"));  
            RadioButton rblist3 = ((RadioButton)row.FindControl("rdTemp_Opt3"));  
            Label lbl1 = (Label)row.FindControl("lbl_desc");  
  
            if (row.Cells[0].Text == "1")  
            {  
                if (e.Result.Text == "Yes")  
                {                       
                    rblist1.Checked = true;  
                    rblist1.Text = "Narendran";  
                }  
                else if (e.Result.Text == "No")  
                {  
                    rblist2.Checked = true;  
                        rblist1.Text = "Naren";  
                }  
                else //if (e.Result.Text == "Not Sure")  
                {  
                    rblist3.Checked = true;  
                    rblist1.Text = "Chk";  
                }  
            }  
            else if (row.Cells[0].Text == "2")  
            {  
                if (e.Result.Text == "Yes")  
                {  
                    rblist1.Checked = true;  
                    rblist1.Text = "Round2";  
                }  
                else if (e.Result.Text == "No")  
                {  
                    rblist2.Checked = true;  
                    rblist2.Text = "Round2";  
                }  
                else //if (e.Result.Text == "Not Sure")  
                {  
                    rblist3.Checked = true;   
                    rblist3.Text = "Round2";  
                }  
            }  
  
            else if (row.Cells[0].Text == "3")  
            {  
                if (e.Result.Text == "Yes")  
                {  
                    rblist1.Checked = true;  
                }  
                else if (e.Result.Text == "No")  
                {  
                    rblist2.Checked = true;  
                }  
                else //if (e.Result.Text == "Not Sure")  
                {  
                    rblist3.Checked = true;  
                }  
            }  
  
            else if (row.Cells[0].Text == "4")  
            {  
                if (e.Result.Text == "Yes")  
                {  
                    rblist1.Checked = true;  
                }  
                else if (e.Result.Text == "No")  
                {  
                    rblist2.Checked = true;  
                }  
                else //if (e.Result.Text == "Not Sure")  
                {  
                    rblist3.Checked = true;  
                }  
            }  
  
            else if (row.Cells[0].Text == "5")  
            {  
                if (e.Result.Text == "Yes")  
                {  
                    rblist1.Checked = true;  
                }  
                else if (e.Result.Text == "No")  
                {  
                    rblist2.Checked = true;  
                }  
                else //if (e.Result.Text == "Not Sure")  
                {  
                    rblist3.Checked = true;  
                }  
            }  
  
            else if (row.Cells[0].Text == "6")  
            {  
                if (e.Result.Text == "Yes")  
                {  
                    rblist1.Checked = true;  
                }  
                else if (e.Result.Text == "No")  
                {  
                    rblist2.Checked = true;  
                }  
                else //if (e.Result.Text == "Not Sure")  
                {  
                    rblist3.Checked = true;  
                }  
            }  
            else if (row.Cells[0].Text == "7")  
            {  
                if (e.Result.Text == "Yes")  
                {  
                    rblist1.Checked = true;  
                }  
                else if (e.Result.Text == "No")  
                {  
                    rblist2.Checked = true;  
                }  
                else //if (e.Result.Text == "Not Sure")  
                {  
                    rblist3.Checked = true;  
                }  
            }  
  
            else if (row.Cells[0].Text == "8")  
            {  
                if (e.Result.Text == "Yes")  
                {  
                    rblist1.Checked = true;  
                }  
                else if (e.Result.Text == "No")  
                {  
                    rblist2.Checked = true;  
                }  
                else //if (e.Result.Text == "Not Sure")  
                {  
                    rblist3.Checked = true;  
                }  
            }  
  
            else if (row.Cells[0].Text == "9")  
            {  
                if (e.Result.Text == "Yes")  
                {  
                    rblist1.Checked = true;  
                }  
                else if (e.Result.Text == "No")  
                {  
                    rblist2.Checked = true;  
                }  
                else //if (e.Result.Text == "Not Sure")  
                {  
                    rblist3.Checked = true;  
                }  
            }  
  
            else if (row.Cells[0].Text == "10")  
            {  
                if (e.Result.Text == "Yes")  
                {  
                    rblist1.Checked = true;  
                }  
                else if (e.Result.Text == "No")  
                {  
                    rblist2.Checked = true;  
                }  
                else //if (e.Result.Text == "Not Sure")  
                {  
                    rblist3.Checked = true;  
                }  
            }  
            else  
            {  
  
            }  
        }  
    }
Code

Please do the needful.

Narendran Namachivayam.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Narendran N
    0
    Code
    Code
    Code
    ss.SelectVoiceByHints(VoiceGender.Female);
    Code
                    ss.Volume = 100;
    Code
                    ss.Rate = -3;
    Code
                    pb.ClearContent();
    Code
                    pb.AppendText("Please answer all the Questions and you starts here!");
    Code
                    ss.Speak(pb);
    Code
                    Thread.Sleep(TimeSpan.FromMilliseconds(1000));
    Code
    Code
                    pb.ClearContent();
    Code
                    pb.AppendText(lbl1.Text);
    Code
                    ss.Speak(pb);
    Code
                    Thread.Sleep(TimeSpan.FromMilliseconds(1000));
    Code
    Code
                    ss.SelectVoiceByHints(VoiceGender.Male);
    Code
                    pb.ClearContent();
    Code
                    pb.AppendText("Options are ");
    Code
                    ss.Speak(pb);
    Code
    Code
                    optiona = rblist1.Text;
    Code
                    optionb = rblist2.Text;
    Code
                    optionc = "Not Sure";
    Code
    Code
                    pb.ClearContent();
    Code
                    pb.AppendText(optiona);
    Code
                    ss.Speak(pb);
    Code
                    Thread.Sleep(TimeSpan.FromMilliseconds(700));
    Code
    Code
                    pb.ClearContent();
    Code
                    pb.AppendText(optionb);
    Code
                    ss.Speak(pb);
    Code
                    Thread.Sleep(TimeSpan.FromMilliseconds(700));
    Code
    Code
                    pb.ClearContent();
    Code
                    pb.AppendText(optionc);
    Code
                    ss.Speak(pb);
    Code
    Code
    C#
                    Choices clist = new Choices(new string[] { "Yes", "No", "Not Sure" });
    Code
    Code
                    GrammarBuilder gb = new GrammarBuilder();
    Code
                    gb.Append(clist);
    Code
    Code
                    // Construct a Grammar object and load it to the recognizer.
    Code
                    Grammar gr = new Grammar(gb);
    Code
                    sre.LoadGrammarAsync(gr);
    Code
                    sre.SetInputToDefaultAudioDevice();
    Code
                    sre.RequestRecognizerUpdate();
    Code
    Code
                    sre.InitialSilenceTimeout = TimeSpan.FromSeconds(3);
    Code
                    sre.BabbleTimeout = TimeSpan.FromMilliseconds(500);
    Code
                    sre.EndSilenceTimeout = TimeSpan.FromSeconds(1);
    Code
                    sre.EndSilenceTimeoutAmbiguous = TimeSpan.FromSeconds(1.5);
    Code
    Code
    Code
                    var result = sre.Recognize();
    Code
    Code
                    if (result.Text == "Yes")
    Code
                    {
    Code
                        rblist1.Checked = true;
    Code
                        break;
    Code
                    }
    Code
                    else if (result.Text == "No")
    Code
                    {
    Code
                        rblist2.Checked = true;
    Code
                        break;
    Code
                    }
    Code
                    else if (result.Text == "Not Sure")
    Code
                    {
    Code
                        rblist3.Checked = true;
    Code
                        break;
    Code
                    }
    Code
                    else
    Code
                    {
    Code
                        rblist1.Checked = false;
    Code
                        rblist2.Checked = false;
    Code
                        rblist3.Checked = false;
    Code
                        break;
    Code
                    }
    Code
                }

    Code
    Code
    VB.NET
    This is the code working as of now, but at the end the page is keep on loading and nothing happened, hope once the page loaded ended the option button will be selected.
    Help me on this, why the page is keep on loading?
    0
  • Narendran N
    0

    Thank U.


    My code is working fine, now the thing is I need the same to be implemented for Tamil & Hindi Languages, am already having the texts in DB and bound in Gridview too, but couldn't read through SpeechSynthesizer.

    Do I need to have the voice for those languages?

    0