Process process;
// Read Contetnt Mouse click event
private SpeechSynthesizer readerSpeak;
private void btnSpeakContent_Click(object sender, EventArgs e)
{
if(richTextBoxThanglish.Text.Trim() == string.Empty)
{
if (process.HasExited == false)
process.Kill();
MessageBoxWrapper.ShowWarning("Textbox is Empty.", "ABTS", "Textbox is Empty.");
process = Process.Start("narrator.exe");
}
else
{
if (process.HasExited == false)
process.Kill();
readerSpeak = new SpeechSynthesizer();
readerSpeak.SpeakAsync(richTextBoxThanglish.Text.ToString());
if (process.HasExited == true)
process = Process.Start("narrator.exe");
}
}
private void btnStopSpeak_Click(object sender, EventArgs e)
{
if (process.HasExited == true)
process = Process.Start("narrator.exe");
if (!(readerSpeak == null))
{
readerSpeak.Dispose();
}
}
假设上面的程序有两个按钮调用 speakContent 和 stop_speak。我运行 narrator.exe 进程来获取 Windows 旁白。我确实想在不重叠语音的情况下说出richtextbox 内容。我知道 Synchronos speak,但它会暂停我的应用程序,直到 speakContent 完成。我需要这个和 SpeakAsyn()。无论如何在语音旁白中添加静音?实际上我需要那个文本语音,在 3 秒之后。我曾使用“System.Threading.Thread.Sleep(3000);”。但是仍然会发生文本重叠,意味着叙述者和字符串到语音一起播放。
请帮忙。