Can you fix and tell me what is wrong here? Its throwing errors. using System.Speech.Synthesis; namespace dropbox03 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private string fileContent; private void Form1_Load(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { string filePath = openFileDialog1.FileName; using StreamReader sr = new StreamReader(filePath); fileContent = sr.ReadToEnd(); } } private void exitButton_Click(object sender, EventArgs e) { this.Close(); } private void playButton_Click(object sender, EventArgs e) { string sentences = fileContent.Split("."); SpeechSynthesizer synthesizer = new SpeechSynthesizer(); synthesizer.SetOutputToDefaultAudioDevice(); foreach(string sentence in sentences) { sentenceLabel.Text = sentence; synthesizer.Speak(sentenceLabel.Text); } } } }
Can you fix and tell me what is wrong here? Its throwing errors.
using System.Speech.Synthesis;
namespace dropbox03
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string fileContent;
private void Form1_Load(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string filePath = openFileDialog1.FileName;
using StreamReader sr = new StreamReader(filePath);
fileContent = sr.ReadToEnd();
}
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void playButton_Click(object sender, EventArgs e)
{
string sentences = fileContent.Split(".");
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
synthesizer.SetOutputToDefaultAudioDevice();
foreach(string sentence in sentences)
{
sentenceLabel.Text = sentence;
synthesizer.Speak(sentenceLabel.Text);
}
}
}
}
Step by step
Solved in 3 steps