【发布时间】:2012-11-02 02:48:56
【问题描述】:
我正在 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 支持。
我将不胜感激。谢谢。
【问题讨论】:
-
真的没有人可以帮忙吗? :(
标签: c# .net silverlight audio stream