A Python-based application that plays custom sounds when keys are pressed. The app is designed to run in the background, allowing you to hear sound effects while performing other tasks on your computer.
- Custom Key-to-Sound Mapping: Map specific keys to custom sound files.
- Default Sound Playback: Play a default sound for keys not explicitly mapped.
- Daemon Mode: Run the application in the background as a daemon process.
- Interactive Key Mapping: Easily modify key-to-sound mappings using a configuration file.
- Support for Multiple Sound Formats: Works with
.wavfiles.
-
Key Mapping:
- The app uses a
sounds_config.jsonfile to map keys to specific.wavsound files. - For example:
{ "a": "click_a.wav", "b": "click_b.wav", "default": "default_click.wav" }
- The app uses a
-
Sound Playback:
- When a key is pressed, the app checks the mapping in
sounds_config.jsonand plays the corresponding sound usingpygame. - If the key is not mapped, the app plays the
default_click.wavsound.
- When a key is pressed, the app checks the mapping in
-
Daemon Mode:
- The app can run as a background process using the
keyboard_sound_daemon.pyscript, allowing it to run without blocking your terminal.
- The app can run as a background process using the
-
Keyboard Listener:
- The app uses the
keyboardlibrary to listen for keypress events.
- The app uses the
- Python 3.8 or newer: Ensure Python is installed on your system.
- Dependencies:
- Install the required Python libraries:
pip install pygame keyboard python-daemon
- Install the required Python libraries:
-
Clone the project in your GitHub Codespace or local machine:
git clone https://github.com/Failure10/Plague7.git cd Plague7 -
Ensure the
soundsdirectory contains your.wavsound files:Plague7/ ├── sounds/ │ ├── click_a.wav │ ├── click_b.wav │ ├── default_click.wav ├── keyboard_sound_app.py ├── keyboard_sound_daemon.py ├── sounds_config.json └── README.md
To run the app and listen for keypresses:
python keyboard_sound_app.pyThe app will remain active in the terminal, playing sounds when keys are pressed. Press ESC to exit.
To run the app as a background process:
python keyboard_sound_daemon.py-
Verify the Process:
- Run
ps aux | grep pythonto check if the script is running. - You should see
keyboard_sound_daemon.pyin the process list.
- Run
-
Stop the Process:
- Find the Process ID (PID) using:
ps aux | grep keyboard_sound_daemon.py - Kill the process using:
kill <PID>
- Find the Process ID (PID) using:
- Open
sounds_config.jsonin a text editor. - Add, remove, or change key mappings. For example:
{ "a": "click_a.wav", "space": "space_sound.wav", "enter": "enter_sound.wav", "default": "default_click.wav" } - Save the file and restart the app to apply changes.
To adjust the volume, modify the set_volume value in the script. For example:
sound.set_volume(0.5) # Set volume to 50%-
Sound File Not Found:
- Ensure the
.wavfile exists in thesoundsdirectory. - Check that the file name in
sounds_config.jsonmatches exactly.
- Ensure the
-
No Sound Playback:
- Verify that you have installed
pygamecorrectly. - Ensure your audio system is properly configured (e.g.,
SDL_AUDIODRIVERin Codespaces).
- Verify that you have installed
-
Daemon Not Starting:
- Check for errors in the
daemon_stdout.logordaemon_stderr.logfiles.
- Check for errors in the
Contributions are welcome! If you’d like to add features or fix bugs, feel free to submit a pull request.
This project is licensed under the MIT License.
Donations are accepted! My PayPal is sjcrambl@hotmail.com