Skip to main content

Play sounds in your Python scripts

This project provides a simple cross-platform API to play sounds in your Python scripts, and allows you to play sounds while a function or code block executes, or afterwards.

It's a simple wrapper over playsound and boombox.

I use this project in onhold and ding.

Rationale

boombox is great and 90% of the way there, however the default options for playing sounds on Windows are limited to WAV files. If the platform is Windows, play_sounds will default to the playsound backend.

Installation

python3 -m pip install play_sounds

Usage

This library uses pathlib.Path objects when pointing to filenames and paths.

Playing a file

from play_sounds import play_file, DEFAULT_SONG

play_file(DEFAULT_SONG)  # blocks by default

# play without blocking
play_file(DEFAULT_SONG, block=False) 

Playing while work completes

from time import sleep
from play_sounds import play_while_running, DEFAULT_SONG

with play_while_running(DEFAULT_SONG):
  sleep(60)

Play sound after work completes

from time import sleep
from play_sounds import play_after, DEFAULT_SOUND

with play_after(DEFAULT_SOUND):  # blocks by default
  sleep(60)

# play without blocking
with play_after(DEFAULT_SOUND, block=False):
  sleep(60)

Copyright

See CREDIT.md.

License

See LICENSE.

Release files for play-sounds 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for play-sounds 0.1.2
File Size Uploaded
play_sounds-0.1.2.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for play-sounds 0.1.2
File Interpreter ABI Platform
play_sounds-0.1.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 7.6 MB

Release files / play_sounds-0.1.2.tar.gz

Download URL play_sounds-0.1.2.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
16a6192a675f10f225789d0e4076997cb2c04d10583eaba6d3e0c6bdec270386
BLAKE2b-256 checksum
How to use checksums
65015ea2eb8197401dac1632bc0b6093307e4ab6ca88b7a8b6b36991ffa08822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.6

Release files / play_sounds-0.1.2-py2.py3-none-any.whl

Download URL play_sounds-0.1.2-py2.py3-none-any.whl
Size 7.5 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
92ab00e28678c3b01a574efe068e34d5bf468ac210bd48a6b14b5ac92f7a48d5
BLAKE2b-256 checksum
How to use checksums
d9f00e4d2dbbad97ebb42430744c2b2ff14f36c2f8980d2f709ac9d873fd4e09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.6

Release history Release notifications | RSS feed

0.6.0

2 release files

0.5.0

3 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.1.3

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.5

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page