Skip to content

jabbalaci/keysound

Repository files navigation

keysound

Play an audio file (a click sound) when a keyboard button is pressed.

Audio Samples

Soundpacks are located in the sounds/ folder. Currently available soundpacks:

Installation

We need the external command play, which is part of the package sox. Install it:

# Ubuntu:
$ sudo apt install sox
# Arch / Manjaro:
$ sudo pacman -S sox

play is used as a fallback solution. First we try to play the audio files without external calls.

Then:

  • Download the source code
  • Create a virtual environment
  • Install the requirements (see pyproject.toml)

Usage

  • activate the virtual environment
  • launch main.py

Read the help:

$ ./main.py -h
usage: main.py [-h] [-v] [-l] [-p] [-s SOUND] [-m MOUSE] [-u]

Play a sound effect when a keyboard button is pressed

options:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -l, --list            list available soundpacks and exit
  -p, --play-all        play all sound files and exit
  -s SOUND, --sound SOUND
                        which soundpack to use
  -m MOUSE, --mouse MOUSE
                        number of mouse clicks (0, 1 or 2)
  -u, --keyup           make sound when a button is released

You can specify the soundpack to be used after -s:

$ ./main.py
$ ./main.py -s fallout
$ ./main.py -s banana

Supported OS

It was tested under Linux only (Manjaro Linux). It may (or may not) work under Windows and MacOS.

Troubleshoot

Under Ubuntu Linux, you will also need these packages:

$ sudo apt install libasound2-dev libportaudio2 sox

Credits

The sound files were borrowed from the following projects:

Related Work

About

Play an audio file (a click sound) when a keyboard button is pressed

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published