1 min read

Python Playsound Module

The playsound module contains a single function for playing a sound file. It is a pure Python, cross-platform, single function module with no dependencies for playing sounds.

Installation

pip install playsound

Basic Usage

from playsound import playsound

playsound('audio.mp3')

Blocking Behavior

By default, the function blocks execution until the sound finishes playing. You can change this behavior using the block argument.

# Play sound in background (non-blocking)
playsound('audio.mp3', block=False)

Note: Support for the block argument may vary depending on the operating system and version.

programming/python/python