I'm trying to find a Python library that would take an audio file (e.g. .ogg, .wav) and convert it into mp3 for playback on a webpage.
Also, any thoughts on setting its quality for playback would be great.
Thank you.
Play Mp3 Files With Python Using the playsound Package One simple way to play an mp3 file using Python is with the help of playsound library. It can be used to play both . mp3 and . wav files.
I wrote a library designed to do that =D
from pydub import AudioSegment
AudioSegment.from_file("/input/file").export("/output/file", format="mp3")
Easy!
to specify a bitrate, just use the bitrate
kwarg…
from pydub import AudioSegment
sound = AudioSegment.from_file("/input/file")
sound.export("/output/file", format="mp3", bitrate="128k")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With