我正在用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();
}在客户端,我使用以下代码:使用MediaElement向客户端播放创建的声音:http://elegantcode.com/2010/03/07/text-to-speech-in-silverlight-using-wcf/。
它可以工作,但我需要调整它,因为生成的流相当大-2分钟的新闻超过8MB。在过去的几天里,我一直在浏览网页,寻找两个问题的解决方案: 1.使用wcf将音频数据流式传输到Silverlight 2.在将音频发送到客户端之前对音频进行压缩
至于第一个问题,我不知道如何实现它:/我将寻求任何帮助或想法。使用No.2最困难的事情是我不能将输出声音保存为文件。我需要在飞行中编码,并发送压缩的声音到客户端。据我所知,最好的办法是编码为AAC或WMA,因为MediaElement支持这两种方式。
如果有任何帮助,我将不胜感激。谢谢。
发布于 2013-04-15 12:19:38
Windows Azure Media Services可能值得一看。http://www.windowsazure.com/en-us/home/features/media-services/
它提供“实时流媒体”,你可以在你的音频中使用。我使用它是为了点播,但不是直播,它真的很容易做到。只需将你的媒体上传到“云”,它就会对你进行编码,并为你提供一个端点。然后,您可以在Silverlight media元素中使用此终结点来获取流媒体。
https://stackoverflow.com/questions/13364731
复制相似问题