Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
Playing and Recording Sound in Python (Summary)
Congratulations! You’ve learned how to use a large number of libraries related to working with audio in Python. In this video, we’re going to recap each of them and briefly cover what they’re used for so you can quickly decide if they’ll fit your next project or not. First, we have
playsound, which is a good general purpose cross-platform audio player.
simpleaudio is where we brought in NumPy array support. It’s also cross-platform and it can play WAV files, but also NumPy arrays or byte objects. It also doesn’t require dependencies, but it will need
NumPy if you want to use NumPy arrays.
winsound was the Window’s WAV player. It only works on Windows and it only supports WAV playback, but it doesn’t require any dependencies and it allows you to beep the computer speakers in a single line of code.
PyAudio required more code than some of the other libraries. This is what allows it to have tighter control on the audio input and output, so you’ll need to decide if your project requires that.
pyaudio requires the
wavio was the WAV and array converter. It’s cross-platform, and it’s really good at converting between WAV files and NumPy arrays. To do this, it requires
wave. And finally,
soundfile, which is a cross-platform audio converter.
soundfile won’t play back any files, but it can convert any file type supported by
libsndfile. To do this, it requires
02:17 And that’s all there is to it! Hopefully by now you have a solid grasp on how to incorporate audio into your Python projects. We only scratched the surface on all of these libraries, so if any of them interested you, you should check out their documentation and see how you can customize them to do exactly what you need.
02:35 Audio can really add to an application as it can give information to the user without printing to a terminal or generating graphics onscreen. Keep this in mind and see if it’s possible to add audio to your next project.
Become a Member to join the conversation.