用于同时创建和播放音频的 Python 音频库
我正在开发一个音频创建框架。它将生成大型音频文件,例如 3 分钟长的音频文件,大约需要 1 分钟才能生成。所以我想要的是一个类似于来自互联网的流音频的系统,我可以在生成声音时播放声音。
Pygame 的混音器允许我在播放时编辑声音。但我不知道如何更改采样率、样本大小或通道数。
Snack 允许我编辑声音及其采样率、样本大小、长度和通道数。但我不知道如何编辑正在播放的声音。
有人可以向我指出一个库,该库允许我在播放声音时编辑声音,并配置通道数量、采样率和长度(所有这些都提前知道)吗?如果没有,也许有人知道用 C++ 执行此操作的教程?
[编辑] Pymedia.audio 对我来说效果很好。但是,我无法让它在 Python 2.6 下工作。有什么想法吗?
I'm working on an audio creation framework. It'll be generating large audio files, say 3 minute long audio files that take about 1 minute to generate. So what I want is a system much like streaming audio from the internet, where I play the sound as I generate it.
Pygame's mixer allows me to edit the sound as it's playing. But I cannot figure out how to change the sample rate, sample size, or number of channels.
Snack allows me to edit sounds, as well as their sample rate, sample size, length, and number of channels. But I cannot figure out how to edit sounds as they are playing.
Could anybody point me to a library that allows me to edit a sound as it is playing, as well as configure the number of channels, sample rate, and length (all known ahead of time)? If not, perhaps somebody knows of a tutorial to do this in C++?
[EDIT] Pymedia.audio would work fine for me. However, I can't get it to work under Python 2.6. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
pymedia.audio 确实适用于 Python 2.6。看看这篇SO文章:Pymedia在Windows上使用Python 2.6安装< /a>
您可以在输出对象播放时将音频附加到它们。因此,当生成每个样本时,它也可以附加到流中。他们文档中的示例展示了如何执行此操作: http://pymedia.org/文档/pymedia.audio.sound.html
pymedia.audio does work with Python 2.6. Take a look at this SO post: Pymedia installation on Windows with Python 2.6
You can append audio to Output objects, as they are playing. So as each sample is generated, it can also be appended to the stream. The example in their documentation shows just how to do this: http://pymedia.org/docs/pymedia.audio.sound.html