playsound aims to be a “pure Python, cross-platform, single function module with no dependencies for playing sounds.” In other words, if all you need to do is play a sound file, this will get it done. In fact, you can play a sound with a single line of code.
The content of these files isn’t important, but I’m going to use them to show the compatibilities between different file types with the libraries that we talk about. From the terminal, let’s go ahead and install
All right. That’s all installed. Inside your text editor, you can then just go ahead and say
from playsound import playsound. And to play that sound, just call
playsound() and pass in the filename.
What this will do is form a bridge between Python and Objective-C on your Mac. All right! So you’ve got
playsound working. In the next video, you’re going to see how to use
simpleaudio for playing WAV files.
Become a Member to join the conversation.