Python Forum
Python audio library - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python audio library (/thread-4311.html)



Python audio library - hbknjr - Aug-07-2017

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.


RE: Python audio library - nilamo - Aug-07-2017

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.


RE: Python audio library - hbknjr - Aug-07-2017

Thanks for suggestion. I'll check it out.


RE: Python audio library - wavic - Aug-07-2017

I have used PyGame module to build a basic mp3 player. The sound quality was awesome. Cool


RE: Python audio library - snippsat - Aug-07-2017

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.



RE: Python audio library - hbknjr - Aug-08-2017

(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.