Skip to main content
A Mark Parker project — see more at markparker.me Did this solve your problem? If it saved your time, you owe me a coffee

system-sounds

Table of Contents

  1. Description
  2. Installation
  3. Usage
  4. Alternatives for Playback

Description

The System Sounds library provides a straightforward interface to list and play system and user music sounds. It is cross-platform, supporting macOS, Linux, and Windows.

Installation

To install the library, use one of the following package managers:

pip

pip install system-sounds

poetry

poetry add system-sounds

Usage

Listing System Sounds:

To retrieve a list of available system sounds, use:

from system_sounds import list_system_sounds

sounds = list_system_sounds()
print(sounds)

Listing User's Music:

To retrieve a list of music from the user's default music directory, use:

from system_sounds import list_music

music = list_music()
print(music)

Listing Both System Sounds and Music:

To retrieve a combined list of system sounds and user music, use:

from system_sounds import list_all

all_sounds = list_all()
print(all_sounds)

Playing a Sound:

To play a sound, use the play_sound function:

from system_sounds import play_sound

play_sound("path_to_sound_file.wav")

Advanced Usage - Custom Directory and Extensions:

If you'd like to list files from a custom directory or look for sound files with specific extensions, utilize the list_files_from_directory function:

from system_sounds import list_files_from_directory

custom_sounds = list_files_from_directory("/path/to/directory", extensions={'.wav', '.ogg'})
print(custom_sounds)

Alternatives for Playback

The library uses system commands to play sounds, which might not be optimal or available for every scenario. For fallback or alternative methods, consider using:

sounddevice + soundfile:

This combination allows for playback and reading of sound files in various formats.

Installation:

pip install sounddevice soundfile

Example usage:

import soundfile as sf
import sounddevice as sd

data, samplerate = sf.read('path_to_sound_file.wav')
sd.play(data, samplerate)
sd.wait()

playsound:

A pure Python solution without dependencies.

Installation:

pip install playsound

Example usage:

from playsound import playsound

playsound('path_to_sound_file.mp3')

pyaudio:

Allows you to play and record audio on various platforms.

Installation:

pip install pyaudio

Example usage requires reading the sound file with a library like wave and then playing it with pyaudio.

Remember, while these alternatives provide more features or flexibility, they might also introduce additional dependencies or complexities to your application.

Metadata

Release files for system-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 system-sounds 0.1.2
File Size Uploaded Provenance
system_sounds-0.1.2.tar.gz 3.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for system-sounds 0.1.2
File Interpreter ABI Platform
system_sounds-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.1 kB

Release files / system_sounds-0.1.2.tar.gz

Download URL system_sounds-0.1.2.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b574da1caf90e25d7b2876b3b451469f708e1cd365b6d95c3c51d8f2f837beaa
BLAKE2b-256 checksum
How to use checksums
130dd3218279a1267d65ade00ddbc0bd39b975c9a12e34dda5958c56859b835e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / system_sounds-0.1.2-py3-none-any.whl

Download URL system_sounds-0.1.2-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
425561f72cd69eed9fd0d91362a3b58baafc78742790bcca47dbfb61badb979b
BLAKE2b-256 checksum
How to use checksums
c8f790356678869d0b96df1d0c12186b847905866ef4a264938de9f3627de9e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for system-sounds 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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