0

The problem was that when I click the button, it reads the text but even after it is finished, the page is still waiting for localhost, so I thought maybe I should instantiate the reader on page load only as I did in the code below, getting a NullReferenceException

protected void Page_Load(object sender, EventArgs e)
{
        if (!IsPostBack)
        {
            Label1.Text = "click button";
            reader = new SpeechSynthesizer();
        }
        else
        {}
}

protected void Button1_Click(object sender, EventArgs e)
{
          reader.SpeakAsync(TextBox1.Text);//getting the error here
            Label1.Text = "SPEAKING";
}
John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • Thank you, i get why it is not working now, but if i remove the reference from page load and put it in the button click, another problem appears: after the reading is complete, the page is always waiting for host, and the completion event is never working – user3079575 Dec 08 '13 at 10:25
  • Is that `System.Speech.Synthesis.SpeechSynthesizer`? Forget the `NullReferenceException`; you probably have a bigger conceptual problem. Unless the class is explicitly designed for use from a web server, or you are doing the heavy-lifting yourself (a non-trivial combination of audio encoding, temp files, a media streaming handler and/or JavaScript), you can't synthesize sounds on a web server and expect the sound to come out of the browser. If it seems to work for you right now, it's most likely because your web server and your browser happen to be running on the same computer. – Euro Micelli Dec 08 '13 at 16:55
  • Any alternatives for reading texts not limited by size? – user3079575 Dec 09 '13 at 19:44

0 Answers0