There are a selection of Python libraries that you can use to play audio files. A few of these libraries let you play a range of audio formats, including MP3 and NumPy arrays. All of these libraries let you play WAV files, some with a few more lines of code than others:
playsound is the most straightforward package to use if you simply want to play a WAV or MP3 file. It offers no functionality other than simple playback.
simpleaudio lets you play WAV files and NumPy arrays, and gives you options to check whether a file is still playing.
winsound allows you to play WAV files or beep your speakers, but it works only on Windows.
python-sounddevice and pyaudio provide bindings for the PortAudio library for cross-platform playback of WAV files.
pydub requires pyaudio for audio playback, but with ffmpeg installed, it lets you play a large range of audio formats with only a few lines of code.
Let’s have a look at these libraries for audio playback one by one.
On this page of the site you can watch the video online Reading Audio Files in Python with a duration of hours minute second in good quality, which was uploaded by the user HERNAN ALAR 07 June 2020, share the link with friends and acquaintances, this video has already been watched 2,990 times on youtube and it was liked by 38 viewers. Enjoy your viewing!