Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing audio file with Python

Tags:

python

audio

mp3

I've seen most of the questions on this topic but almost all of them are outdated. (This is not a dupe)

My requirement is a preferably light weight library for simply playing audio files such as mp3,etc from Python (2.7)

These are the libraries that I've so far looked into and I'm listing what are the things that are stopping me from using each of them:

  • PyMedia: it was last updated in Feb, 2006
  • Mp3Play: supports only XP and was last updated in 2008.

I've also tried Pyglet but even this doesn't look good. Also heard that wx has support for mp3 and I'm trying it. Any comments about the same?

Which reliable lightweight library do others use these days?

PS: please post one library only per answer

like image 721
Atul Goyal Avatar asked Feb 02 '23 13:02

Atul Goyal


1 Answers

I'm not sure what your issue is with pyglet. Playing an mp3 using that couldn't be simpler:

import pyglet
sound = pyglet.media.load('mysound.mp3', streaming=False)
sound.play()
pyglet.app.run()

pyglet is well-maintained, cross-platform, and very small for a multimedia library.

like image 122
Rafe Kettler Avatar answered Feb 05 '23 04:02

Rafe Kettler