using System.Speech.Synthesis;
private void button1_Click(object sender, EventArgs e) { // if textbox1 is empty if (string.IsNullOrEmpty(textBox1.Text)) { MessageBox.Show("Please enter some text in the text box before trying to speak"); return; } else//if textbox is not empty { //call the speakAsync method to say the words inside the textbox ss.SpeakAsync(textBox1.Text); } }