我有问题。我有一个RichTextBox
,我希望将文本转换为语音音频,那么是否有一些库或程序可以执行此操作?我想在C#,WinForms中执行此操作。
更新
private void aiutoVocaleToolStripMenuItem_Click(object sender, EventArgs e)
{
string contenuto_valore = TextBox_stampa_contenuto.Text.Trim();
var s = new System.Speech.Synthesis.SpeechSynthesizer();
s.Speak(contenuto_valore);
}
程序说没有参考汇编
答案 0 :(得分:1)
您可以使用MS TTS:
http://msdn.microsoft.com/de-de/library/system.speech.synthesis.speechsynthesizer%28v=vs.110%29.aspx
使用TTS:
private static SpeechSynthesizer speaker;
public static void Main(String[] args){
speaker = new SpeechSynthesizer();
speaker.SetOutputToDefaultAudioDevice();
speaker.Rate = 1;
speaker.Volume = 100;
speaker.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
speaker.SpeakAsync("Hello World");
}
private static List<VoiceInfo> GetInstalledVoices() {
var listOfVoiceInfo = from voice
in speaker.GetInstalledVoices()
select voice.VoiceInfo;
return listOfVoiceInfo.ToList<VoiceInfo>();
}
只需阅读RichTextBox's
Text
属性即可获取文字
答案 1 :(得分:0)
阅读RichTextBox
值(如果文本非常大,请将其拆分)并将请求发送至translate.google.com:
http://translate.google.com/translate_tts?tl=en&q=Your%20Text%20Here
如果必须,您可以获取使用HTTP GET
生成的声音文件。记住,您的客户需要访问互联网
您需要引用System.Speech.dll
才能使用SpeechSynthesizer()
。按照步骤:
System.Speech.dll
现在您可以运行以下代码;
private void aiutoVocaleToolStripMenuItem_Click(object sender, EventArgs e)
{
using (SpeechSynthesizer synth = new SpeechSynthesizer())
{
synth.SetOutputToDefaultAudioDevice();
synth.Speak(TextBox_stampa_contenuto.Text.Trim());
}
}
答案 2 :(得分:0)
内置于.NET
var s = new System.Speech.Synthesis.SpeechSynthesizer();
s.Speak("hello");
http://msdn.microsoft.com/en-us/library/ms586901(v=vs.110).aspx