Converting m4a to wav using pydub in Python – Python Tutorial

By | December 14, 2021

In this tutorial, we will introduce you how to convert m4a audio file to wav using python pydub.

Install ffmpeg.exe

In order to use pydub, you should install ffmpeg.exe first.

You can read this tutorial to know how to install.

View Audio Sample Rate, Data Format PCM or ALAW Using ffprobe – Python Tutorial

How to convert m4a to wav using pydub

Here is an example code:

m4a_file = '20211210_151013.m4a'
wav_filename = r"F:\20211210_151013.wav"
from pydub import AudioSegment
track = AudioSegment.from_file(m4a_file,  format= 'm4a')
file_handle = track.export(wav_filename, format='wav')

However, you may get this error: Couldn’t find ffmpeg or avconv

In order to fix this error, you can read:

Fix Couldn’t find ffmpeg or avconv in pydub – Python Tutorial

Then, you can find m4a is converted to wav.