Skip to content

Convert wav to mp3 format in Python

Learn how to convert an audio file from wav format to mp3 format in Python. Pydub is a Python module that can be used in Audio manipulation.

pydub can be used to play with audio files. In this example, we convert an audio file which is in wav format to mp3 format.

from os import path
from pydub import AudioSegment

#files

src = "input.wav"
dst = "output.mp3"

#convert wav to mp3
sound = AudioSegment.from_mp3(src)
sound.export(dst, format="wav")
See also  Check if variable exists in Python

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.