我正在 Silverlight 中创建一个需要读取其内容的应用程序。我正在使用 WCF 服务将内容发送到服务器端,然后有这段代码可以将文本合成为语音。
public class SpeechService
{
[OperationContract]
public byte[] StartSpeak(string Text)
{
MemoryStream ms = new MemoryStream();
using (System.Speech.Synthesis.SpeechSynthesizer synhesizer = new System.Speech.Synthesis.SpeechSynthesizer())
{
synhesizer.SelectVoiceByHints(System.Speech.Synthesis.VoiceGender.NotSet, System.Speech.Synthesis.VoiceAge.NotSet, 0, new System.Globalization.CultureInfo("pl-PL"));
synhesizer.SetOutputToWaveStream(ms);
synhesizer.Speak(Text);
}
return ms.ToArray();
}
在客户端,我使用以下代码:http : //elegantcode.com/2010/03/07/text-to-speech-in-silverlight-using-wcf/ 使用 MediaElement 向客户端播放创建的声音。
它可以工作,但我需要调整它,因为生成的流非常大 - 2 分钟的新闻超过 8MB。最近几天我在网上浏览两个问题的解决方案: 1. 使用 wcf 将音频数据流式传输到 Silverlight 2. 在将音频发送到客户端之前对其进行压缩
至于问题号。1 我不知道如何实现它:/我将使用任何帮助或想法。最难的是没有。2是我无法将输出声音保存为文件。我需要即时进行编码并将压缩的声音发送到客户端。据我所知,最好的想法是将编码为 AAC 或 WMA,因为这两者都受 MediaElement 支持。
我将不胜感激。谢谢。