Skip to main content

list available system sound files

Project description

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.

Project details


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.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

system_sounds-0.1.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: system_sounds-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for system_sounds-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bb3f2f1048c132e45f5313dac3c53b52940e68f9718c02a1376c7512dc2c78af
MD5 f8e1478254c32ad9f29d9dc65da225ef
BLAKE2b-256 cf39cc39b322cf71e5e0cfe04c04b942322daed26520d9b1e07b00e300ced89b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for system_sounds-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ea37a7d76c6b09b28dd014e37d3dc14ba833a2b112e44051d0696881de9e46fc
MD5 931a30121b3946886a2cfc23c7b2452b
BLAKE2b-256 1b0dc1e7b6e00fad83de707b59922a9e341cbd139c5ac6cbcaa9d94671160294

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page