How to convert MP3 to WAV in Python How to convert MP3 to WAV in Python python python

How to convert MP3 to WAV in Python


I maintain an open source library, pydub, which can help you out with that.

from pydub import AudioSegmentsound = AudioSegment.from_mp3("/path/to/file.mp3")sound.export("/output/path/file.wav", format="wav")

One caveat: it uses ffmpeg to handle audio format conversions (except for wav files, which python handles natively).

note: you probably shouldn't do this conversion on GAE :/ even if it did support ffmpeg. EC2 would be a good match for the job though


This is working for me:

import subprocesssubprocess.call(['ffmpeg', '-i', 'audio.mp3',                   'audio.wav'])


Install the module pydub. This is an audio manipulation module for Python. This module can open many multimedia audio and video formats. You can install this module with pip.

pip install pydub

If you have not installed ffmpeg yet, install it. You can use your package manager to do that.

For Ubuntu / Debian Linux:

apt-get install ffmpeg

When ready, execute the below code:

from os import pathfrom pydub import AudioSegment# files                                                                         src = "transcript.mp3"dst = "test.wav"# convert wav to mp3                                                            sound = AudioSegment.from_mp3(src)sound.export(dst, format="wav")

Check this link for details.