如何在silverlight中压缩语音流

发布于 2024-10-07 10:41:49 字数 269 浏览 2 评论 0原文

我已经使用 silverligh4 录制了音频并尝试通过服务器上的服务保存它。 问题是记录的 .WAV 文件有数十万字节的数据作为流。但是,当该流传递给服务时,其最大传输长度仅为 1526 字节。我已经在 web.config 中设置了 max 属性。我认为我们需要在客户端对流进行编码,然后传递此编码流并在服务器上对其进行解码。如何在silverlight上对音频流进行编码 应用程序并在服务器上对其进行解码?请给我建议。感谢您抽出时间。 Nspeex 或 CSpeex 不适合我。如果有人实施了相同的操作,请建议如何做?

I have recorded audio using silverligh4 and trying to save it through service on the server.
The problem is recorded .WAV file has lakhs ofbytes of data as stream. But when this stream is passed to service its getting transmitted as 1526 bytes max only. I have set max properties in web.config. I think we need to encode the stream on the client and pass this encoded stream and decode it on the server. How to encode the audio stream on sileverlight
application and decode it on the server? Please advice me. Thanks for your time. Nspeex or CSpeex do not work for me. If any one has implemented the same please suggest how to do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神爱温柔 2024-10-14 10:41:49

将 WAV 压缩到任何合理大小(无交易质量)的唯一方法是将其转换为另一种格式。

我不知道这是否适合您,但在发送到服务器之前使用 lame.exe 转换为 MP3 会非常容易。当然,您需要确保许可允许您随应用程序一起分发。

这是一个将 MP3 转换为 WAV 的开源程序:
http://www.codeproject.com/KB/audio-video/madlldlib.aspx

像这样转换为 MP3,您也许还可以使用 --decompress 选项将 MP3 转换为 WAV。

using System.Diagnostics;

public string WAV2MP3(string fileName, bool waitFlag) {

    string newFileName = fullpathDir + fileName.Replace(".wav",".mp3");
    string lameArgs = "-b 32 --resample 22.05 -m m \"" + 
        fullpathDir + fileName + "\" \"" + 
        newFileName + "\"";

    ProcessStartInfo processInfo = new ProcessStartInfo();

    Arguments = lameArgs;
    WindowStyle = ProcessWindowStyle.Hidden;
    WorkingDirectory = Application.StartupPath;

    Process startedProcess = new Process.Start(processInfo);

    if (waitFlag) {
      startedProcess.WaitForExit();
    }
    return newFileName;

};

The only way to compress WAV to any reasonable size (without trading quality) is to convert it to another format.

I don't know if this is an option for you but it would be very easy to use lame.exe to convert to MP3 before sending to the server. Of course you'd need to make sure that licensing allows you to distribute with your application.

Here is an open source program to convert MP3 to WAV:
http://www.codeproject.com/KB/audio-video/madlldlib.aspx

Something like this to convert to MP3, you might be able to convert MP3 to WAV with lame also using the --decompress option.

using System.Diagnostics;

public string WAV2MP3(string fileName, bool waitFlag) {

    string newFileName = fullpathDir + fileName.Replace(".wav",".mp3");
    string lameArgs = "-b 32 --resample 22.05 -m m \"" + 
        fullpathDir + fileName + "\" \"" + 
        newFileName + "\"";

    ProcessStartInfo processInfo = new ProcessStartInfo();

    Arguments = lameArgs;
    WindowStyle = ProcessWindowStyle.Hidden;
    WorkingDirectory = Application.StartupPath;

    Process startedProcess = new Process.Start(processInfo);

    if (waitFlag) {
      startedProcess.WaitForExit();
    }
    return newFileName;

};
念三年u 2024-10-14 10:41:49

我可能只是获取原始音频流,以低速率对其进行采样,然后通过压缩流将其发送出去。如果您想变得更奇特,您可以将压缩外包给像 LAME 这样的 MP3 编码器(在单独的线程/进程中!)。

I'd probably just take the raw audio stream, sample it at a low rate, and send it out via a compressed stream. If you wanted to get fancy, you could farm the compression out to an MP3 encoder like LAME (in a separate thread/process!).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文