就像问题标题一样,我是NAudio的新手,我想和NAudio一起做一个Text to Speech演示。 NAudio可以做到这一点。 请给我一些建议。谢谢。
答案 0 :(得分:1)
不,NAudio不提供发言权。您应该使用SpeechSynthesizer作为
答案 1 :(得分:0)
从 nugget 安装 naudio 包,然后使用以下代码:
IWaveProvider provider = null;
var stream = new MemoryStream();
using (var synth = new SpeechSynthesizer())
{
synth.SetOutputToAudioStream(stream,
new SpeechAudioFormatInfo(44100, AudioBitsPerSample.Sixteen, AudioChannel.Mono));
synth.Speak(textToSpeak);
stream.Seek(0, SeekOrigin.Begin);
provider = new RawSourceWaveStream(stream, new WaveFormat(44100, 16, 1));
}
waveOut.Init(provider);
waveOut.Play();
while (waveOut.PlaybackState == PlaybackState.Playing)
{
Thread.Sleep(5000);
}