Python Forum

Full Version: Python audio library
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am creating a project that has a module which requires audio playback.(similar to a music player)
So I'm looking for a Python audio library that:

1- Supports mp3 and Ogg file format
2- Platform independent or supports Windows and Debian(Linux)
3- Support play, pause, and seeking.
4- Well documented and simple API.
5- Return signal on playback completion.


Few I tried:
a- PyQt4 phonon-> Not working on windows, getting errors.
b- Pydub - doesn't have pause and seeking.
c- Simpleaudio - supports only wave.

Please suggest.
pygame's mixer.music module supports mp3 and ogg, runs on most platforms, supports play/pause/seek, has a fairly simple api, AND you can set a callback event to fire when it completes.

https://www.pygame.org/docs/ref/music.html

Don't let the pygame name fool you, it's built modularly, so you can init() just the mixer, and it can work without a display attached.
Thanks for suggestion. I'll check it out.
I have used PyGame module to build a basic mp3 player. The sound quality was awesome. Cool
An other option is Pyglet.
Sound and video
Quote:
  • Load images, sound, music and video in almost any format. 
  • pyglet can optionally use AVbin to play back audio formats such as MP3, OGG/Vorbis and WMA, and video formats such as DivX, MPEG-2, H.264, WMV and Xvid.
(Aug-07-2017, 08:40 PM)snippsat Wrote: [ -> ]An other option is Pyglet

Good suggestion, thank you. I thought it would be too many dependencies.Its well documented too.