我想在我的应用程序中将进度条连接到我的语音合成器(以显示它阅读文本的程度)。
我的 SpeechSynthesizer 代码的主要组件如下:
private void button1_Click(object sender, EventArgs e)//Start button
{
reader.Dispose();
if (Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.Text != "")
{
reader = new SpeechSynthesizer();
reader.SpeakAsync(Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.Text);
button2.Enabled = true;
button4.Enabled = true;
reader.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(reader_SpeakCompleted);
}
else
{
MessageBox.Show("Please insert text before launching Text to Speech.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private void button2_Click(object sender, EventArgs e)//Pause button
{
if (reader != null)
{
if (reader.State == SynthesizerState.Speaking)
{
reader.Pause();
button3.Enabled = true;
}
}
private void button3_Click(object sender, EventArgs e)//Resume button
{
if (reader != null)
{
if (reader.State == SynthesizerState.Paused)
{
reader.Resume();
}
button3.Enabled = false;
}
}
private void button4_Click(object sender, EventArgs e)//Stop button
{
if (reader != null)
{
reader.Dispose();
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
}
}
我想将此代码连接到进度条,以便它显示语音合成器的当前状态(并在用户暂停/停止进度条时暂停/停止。这可能吗?我从未使用过进度条正确,所以我想要一些关于如何做到这一点的帮助。
谢谢。