.NET 3.0 文本转语音 WAV 输出太大且过程缓慢

发布于 2024-08-15 03:20:53 字数 545 浏览 2 评论 0原文

我编写了一个小应用程序,它接收一些文本并将其转换为音频 wav。 现在,除了生成的 wav 文件太大之外,它工作正常。

我正在寻找使 wav 输出更小并使整个过程花费更少时间的方法。

示例代码:

 public byte[] ConvertText2Wav(string text)
    {
        MemoryStream wavAudioStream = new MemoryStream();            
        SpeechSynthesizer speechEngine = new SpeechSynthesizer();
        speechEngine.SetOutputToWaveStream(wavAudioStream);
        speechEngine.Speak(text);
        wavAudioStream.Flush();
        Byte[] wavBytes = wavAudioStream.GetBuffer();
        return wavBytes;  
    }

I wrote a little application that takes in some text and converts it to an audio wav.
now, it works fine except that the wav file produced is too big.

I'm looking on ways to make the wav output smaller and make the whole process take less time.

Sample Code :

 public byte[] ConvertText2Wav(string text)
    {
        MemoryStream wavAudioStream = new MemoryStream();            
        SpeechSynthesizer speechEngine = new SpeechSynthesizer();
        speechEngine.SetOutputToWaveStream(wavAudioStream);
        speechEngine.Speak(text);
        wavAudioStream.Flush();
        Byte[] wavBytes = wavAudioStream.GetBuffer();
        return wavBytes;  
    }

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

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

发布评论

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

评论(4

一身仙ぐ女味 2024-08-22 03:20:54

.wav 输出未压缩。

如果您想要“更小的”输出,请使用适当的编解码器并对其进行压缩。

.wav output is uncompressed.

If you want "smaller" output, use an appropriate codec and compress it.

君勿笑 2024-08-22 03:20:54

您可以使用 LAME MP3 编码器将 WAV 输出转换为 MP3。正如 Anon 所说,这将导致输出文件更小。

http://lame.sourceforge.net/

You can use the LAME MP3 encoder to convert the WAV output to MP3. This will result in a smaller output file like Anon says.

http://lame.sourceforge.net/

谢绝鈎搭 2024-08-22 03:20:54

您应该使用专门为语音构建的压缩编解码器,以获得最大可能的好处。 Speex 是免费且优秀的。您可以像这样在 C# 中使用它: http://www.codeproject.com/KB /cs/speexincsharp.aspx

这将产生比通用或音乐编解码器更好的结果。

You should use a compression codec that is built specifically for speech to get the greatest possible benefit. Speex is free and excellent. You can use it from c# like this: http://www.codeproject.com/KB/cs/speexincsharp.aspx.

That will yield better results than a general purpose or music codec would.

把梦留给海 2024-08-22 03:20:54

波形文件本身很长。例如,您应该将其通过编解码器传递为电影的 XVID 或音频的 MP3 或 OGG。

查看本教程,了解如何使用 DirectShow

Wave files are long per se. You should pass it through a codec as XVID for movies or MP3 or OGG for audio for example.

Take a look at this tutorial on how to use DirectShow

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