locked
Speech Recognition is not working in Web application RRS feed

  • Question

  • User1636406578 posted


     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.

    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
                {
    
                }
            }
        }  


    Please do the needful.

    Narendran Namachivayam.

    Monday, July 25, 2016 11:13 AM

All replies

  • User753101303 posted

    Hi,

    Keep in mind anyway that this code runs on the server side. So at best you would hear somethjng when being next to the *server*.

    Those users are using their own screen reading software already. And so your job is rather to annotate page elements (see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) so that those existing sofware can read your page more easily and more efficiently.

    So IMO this is whole approach that needs to be changed.

    Monday, July 25, 2016 11:39 AM
  • User1636406578 posted

    Hi PstriceSc,

     Thank you for your valuable reply, but am looking to do the stuffs through my coding not by using the third party software.

    Narendran Namachivayam.

    Tuesday, July 26, 2016 3:56 AM
  • User753101303 posted

    Then you would likely need to force the page to pause so that the speech is rendered as a wav file or whatever and then you'll have to transmit this sound file to the client side so that the user can hear it. Plus the user won't have any control about what is read (ie with those reading software, it will read for example a button label when it is hovered etc...). Oh and the speech SDK  needs of course to be installed on the web server side.

    In short it will require much more work for a worst result. Is this really what you want?

    Before proceeding further I would really suggest to give a try at a screen reader. For example Windows Narrator comes with Windows. Give it a try before deciding what to do.

    My 2nd choice would be an API such as https://www.microsoft.com/cognitive-services/en-us/speech-api/documentation/api-reference-rest/bingvoiceoutput

    And doing it on the server side would be likely my very last choice. Once again keep in mind that this code runs on the web server (and so it would speak or listen from the server devices not from the devices where the browser is actually used) and so you'll have to handle transmitted back and forth sound files to and from the client side.

    Wednesday, July 27, 2016 5:49 PM
  • User1636406578 posted

    Thanks a lot,

      My code is working well for Text to Speech and it is also recognizing my voice but it's not properly delivering.

    Trying out something under the 

    SpeechRecognitionEngine 

    class.

        sre.SetInputToDefaultAudioDevice();
    
                    sre.InitialSilenceTimeout = TimeSpan.FromSeconds(3);
                    sre.BabbleTimeout = TimeSpan.FromMilliseconds(500);
                    sre.EndSilenceTimeout = TimeSpan.FromSeconds(1);
                    sre.EndSilenceTimeoutAmbiguous = TimeSpan.FromSeconds(1.5);
    
                    var result = sre.Recognize();
    
                    //var result = sre.EmulateRecognize(ss.ToString());
    
    
                    if (result.Text == "Yes")
                    {
                        rblist1.Checked = true;
                    }
                    else if (result.Text == "No")
                    {
                        rblist2.Checked = true;
                    }
                    else if(result.Text=="Not Sure")
                    {
                        rblist3.Checked = true;
                    }
                    else
                    {
                        rblist1.Checked = false;
                        rblist2.Checked = false;
                        rblist3.Checked = false;
                    }

    Hope for the best.

    Narendran Namachivayam.

    Thursday, July 28, 2016 4:46 AM
  • User753101303 posted

    Once again it SEEMS to work because currently the web server is your own PC and also the client machine. Now when  this code will run on a REMOTE WEB SERVER it will listen in the Datacenter where this server is installed rather on the machine where the browser is.

    Thursday, July 28, 2016 3:34 PM
  • User1636406578 posted

     I think there is no point to confuse with the remote web server and the browser where we are browsing and all.

     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(TimeSpan.FromMilliseconds(1000));
    
                    pb.ClearContent();
                    pb.AppendText(lbl1.Text);
                    ss.Speak(pb);
                    Thread.Sleep(TimeSpan.FromMilliseconds(1000));
    
                    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(TimeSpan.FromMilliseconds(700));
    
                    pb.ClearContent();
                    pb.AppendText(optionb);
                    ss.Speak(pb);
                    Thread.Sleep(TimeSpan.FromMilliseconds(700));
    
                    pb.ClearContent();
                    pb.AppendText(optionc);
                    ss.Speak(pb);
    
    
                    Choices clist = new Choices(new string[] { "Yes", "No", "Not Sure" });
    
                    GrammarBuilder gb = new GrammarBuilder(); 
                    gb.Append(clist); 
    
                    // Construct a Grammar object and load it to the recognizer.
                    Grammar gr = new Grammar(gb);   
                    sre.LoadGrammarAsync(gr); 
                    sre.SetInputToDefaultAudioDevice();
                    sre.RequestRecognizerUpdate(); 
                    
                    sre.InitialSilenceTimeout = TimeSpan.FromSeconds(3);
                    sre.BabbleTimeout = TimeSpan.FromMilliseconds(500);
                    sre.EndSilenceTimeout = TimeSpan.FromSeconds(1);
                    sre.EndSilenceTimeoutAmbiguous = TimeSpan.FromSeconds(1.5);
                     
                    
                    var result = sre.Recognize();
    
                    if (result.Text == "Yes")
                    {
                        rblist1.Checked = true; 
                        break;
                    }
                    else if (result.Text == "No")
                    {
                        rblist2.Checked = true; 
                        break;
                    }
                    else if (result.Text == "Not Sure")
                    {
                        rblist3.Checked = true; 
                        break;
                    }
                    else
                    {
                        rblist1.Checked = false;
                        rblist2.Checked = false;
                        rblist3.Checked = false;
                        break;
                    }                 
                }

    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?

    Friday, July 29, 2016 4:17 AM
  • User753101303 posted

    What if you comment the var result = sre.Recognize(); line? This is just to understand if for now if your code stops here waiting for a word to be recognized.

    Else I'm just trying to avoid you much work before realizing that what you have done just doesn't work. Do the simplest speech synthesis page that works and then install that on the web server on which your web app will run and see what happens. Keep in mind that your C# code runs on the web server side.

    Now you could compare the same page with just having it being read using a screen reader (Windows Narrator which is build into Windows or maybe http://www.nvaccess.org/

    IMHO you are really going into a wrong path...

    Friday, July 29, 2016 6:52 AM
  • User379720387 posted

    The folks who have this all figured out are at: www.twilio.com

    Friday, July 29, 2016 10:55 AM
  • User1636406578 posted

    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? 

    Tuesday, August 2, 2016 10:48 AM