DEV Community

MrRobot
MrRobot

Posted on

playsound – Simple Audio Playback in Python

playsound is a lightweight Python library used to play sound files with just one line of code. It supports both Windows and macOS (and partially Linux) and works with most common audio formats like .mp3 and .wav. Since it has no dependencies and requires minimal setup, it’s perfect for adding sound effects, notifications, or background music to simple Python projects.


Installation:

pip install playsound
Enter fullscreen mode Exit fullscreen mode

Example usage:

from playsound import playsound

# Play an audio file
playsound("example.mp3")
Enter fullscreen mode Exit fullscreen mode

PyPI page: https://pypi.org/project/playsound/
GitHub page: https://github.com/TaylorSMarks/playsound


3 Project Ideas:

  1. Create a notification system that plays alerts for specific events.
  2. Build a simple music player with a GUI using Tkinter or PySimpleGUI.
  3. Add sound effects to a text-based or console game.

Top comments (0)