Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
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.
To install the library, use one of the following package managers:
pip install system-sounds
poetry add system-sounds
To retrieve a list of available system sounds, use:
from system_sounds import list_system_sounds
sounds = list_system_sounds()
print(sounds)
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)
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)
To play a sound, use the play_sound
function:
from system_sounds import play_sound
play_sound("path_to_sound_file.wav")
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)
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:
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()
A pure Python solution without dependencies.
Installation:
pip install playsound
Example usage:
from playsound import playsound
playsound('path_to_sound_file.mp3')
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.
FAQs
list available system sound files
We found that system-sounds demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.