我想在我的表单上有一个组合框,允许用户选择他们想要使用的声音。我怎样才能实现这样的功能?
目前,我的表单由四个按钮和一个组合框组成。按钮和合成器背后的代码如下:
private void button1_Click(object sender, EventArgs e)
{
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);
}
}
void reader_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
{
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
if (reader != null)
{
if (reader.State == SynthesizerState.Speaking)
{
reader.Pause();
button3.Enabled = true;
}
private void button3_Click(object sender, EventArgs e)
{
if (reader != null)
{
if (reader.State == SynthesizerState.Paused)
{
reader.Resume();
}
button3.Enabled = false;
}
}
private void button4_Click(object sender, EventArgs e)
{
if (reader != null)
{
reader.Dispose();
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
}
我想用当前安装的声音列表填充一个组合框,当用户单击一个时,它会从所选声音中的richTextBoxPrintCtrl1 中读取文本。目前,合成器可以工作,但我想将此功能添加到我的文本到语音功能中。
谢谢。