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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

system_sounds-0.1.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

system_sounds-0.1.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file system_sounds-0.1.2.tar.gz.

File metadata

  • Download URL: system_sounds-0.1.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for system_sounds-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b574da1caf90e25d7b2876b3b451469f708e1cd365b6d95c3c51d8f2f837beaa
MD5 c40f5eded5f6839b267e44a37162e2a9
BLAKE2b-256 130dd3218279a1267d65ade00ddbc0bd39b975c9a12e34dda5958c56859b835e

See more details on using hashes here.

File details

Details for the file system_sounds-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: system_sounds-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for system_sounds-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 425561f72cd69eed9fd0d91362a3b58baafc78742790bcca47dbfb61badb979b
MD5 a650079ca0ebbf6b3abd2ca602adc071
BLAKE2b-256 c8f790356678869d0b96df1d0c12186b847905866ef4a264938de9f3627de9e9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 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