Question
Asked By – Josh Hunt
How can I play audio (it would be like a 1 second sound) from a Python script?
It would be best if it was platform independent, but firstly it needs to work on a Mac.
I know I could just execute the afplay file.mp3
command from within Python, but is it possible to do it in raw Python? I would also be better if it didn’t rely on external libraries.
Now we will see solution for issue: Play audio with Python
Answer
You can find information about Python audio here: http://wiki.python.org/moin/Audio/
It doesn’t look like it can play .mp3 files without external libraries. You could either convert your .mp3 file to a .wav or other format, or use a library like PyMedia.
This question is answered By – Paige Ruten
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0