how to convert wav to mp3 in live using python?

若如初见. 提交于 2019-12-05 00:46:07

try python-audiotools. I think it will help you stream the audio file that you want.

From reading the code for pydub, it appears that an AudioSegment only allows an output to a file using the out_f variable. So, you can read the WAV file and encode each chunk to a file and then read the file and send it out, decoding it on the other end. However, this is not very efficient. I'd suggest actually extending pydub to handle streams and contributing to the project. The export code is pretty straightforward and I bet it would not be too difficult to do. The author would likely be grateful.

The code for AudioSegment is here: https://github.com/jiaaro/pydub/blob/master/pydub/audio_segment.py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!