我正在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支持这两种编码。
我将不胜感激。谢谢。
最佳答案
也许值得一看Windows Azure Media Services。 http://www.windowsazure.com/en-us/home/features/media-services/
它提供了“实时流”,您可能会在音频中使用它。我已经按需使用此功能,但没有进行直播,流式传输,而且确实很容易做到。只需将您的媒体上传到“云”中,它将进行编码并为您提供端点。然后,您可以在Silverlight Media元素中使用此终结点以获取流媒体。
关于c# - 将流转换为WMA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13364731/