How can I convert a WAV from stereo to mono in Pyt

2020-06-03 02:49发布

I don't want to use any other apps (like sox) - I want to do this in pure Python. Installing needed Python libs is fine.

标签: python audio wav
2条回答
forever°为你锁心
2楼-- · 2020-06-03 03:00

If the WAV file is PCM-encoded then you can use wave. Open the source and destination files, read samples, average the channels, and write them out.

查看更多
smile是对你的礼貌
3楼-- · 2020-06-03 03:19

I maintain an open source library, pydub, which make this pretty simple

from pydub import AudioSegment
sound = AudioSegment.from_wav("/path/to/file.wav")
sound = sound.set_channels(1)
sound.export("/output/path.wav", format="wav")

One caveat: it uses ffmpeg to handle audio format conversions, but if you only use wav it can be pure python.

查看更多
登录 后发表回答