A clap detector that can detect claps in patterns of single, double, etc.
Project description
Clap Detection System
Overview
This project implements a clap detection system using an a mic or raw audio data as input. It can detect clap patterns including single and double claps.
If you found this repository useful, please give it a ⭐!.
Features
- Clap pattern detection.
- Dynamic threshold adjustment for robust clap detection.
- Bandpass filtering to focus on clap frequencies.
- Audio recording and saving capabilities.
Troubleshooting
PyAudio
-
Option A
If clap-detector fails to install due to pyaudio issues, try to installportaudio19usingsudo apt install portaudio19-dev, then install clap-detector normally usingpip install clap-detector. -
Option B
If pyaudio still fails to install after trying option A, try to install it usingsudo apt install python3-pyaudio, then install clap-detector normallypip install clap-detector.
Input
- If there are issues with audio input, check the inputDevice in the
ClapDetectorconstructor.
Accuracy
- Adjust the bandpass filter parameters for better clap detection in different environments.
Requirements
- Python3
- PyAudio
- NumPy
- SciPy
Installation
option A:
- install from the official pypi package:
pip install clap-detector
option B:
-
Install the required Python packages:
pip install pyaudio numpy scipy
-
Clone the repository:
git clone https://github.com/TzurSoffer/clapDetection/ cd clapDetection/src/clapDetector
-
Run the clap detection script:
python clapDetector.py
Configuration
- Adjust parameters in the
ClapDetectorclass constructor to fine-tune the clap detection system.
Usage
option A:
-
clone the repository, if you have not already using
git clone https://github.com/TzurSoffer/clapDetection/ -
go into the examples folder and choose one of the scripts you would like to run.
option B:
-
Create a script that uses this library
import time from clapDetector import ClapDetector, printDeviceInfo print(""" -------------------------------- The application initially attempts to use the system's default audio device. If this doesn't work or if you prefer to use a different device, you can change it. Below are the available audio devices. Find the one you are using and change the 'inputDevice' variable to the name or index of your preferred audio device. Then, restart the program, and it should properly capture audio. -------------------------------- """) printDeviceInfo() thresholdBias = 6000 lowcut=200 #< increase this to make claps detection more strict highcut=3200 #< decrease this to make claps detection more strict clapDetector = ClapDetector(inputDevice=-1, logLevel=10) clapDetector.initAudio() try: while True: audioData = clapDetector.getAudio() result = clapDetector.run(thresholdBias=thresholdBias, lowcut=lowcut, highcut=highcut, audioData=audioData) resultLength = len(result) if resultLength == 2: print(f"Double clap detected! bias {thresholdBias}, lowcut {lowcut}, and highcut {highcut}") clapDetector.saveAudio(folder="./") time.sleep(1/60) except KeyboardInterrupt: print("Exited gracefully") except Exception as e: print(f"error: {e}") finally: clapDetector.stop()
-
The system will continuously monitor audio input and detect claps.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clap_detector-2.0.7.tar.gz.
File metadata
- Download URL: clap_detector-2.0.7.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61801fb4fe903f53d17131950fd4a7939bb97a79c94cc0cb28d37896923d7b1e
|
|
| MD5 |
c5a3067ff9b9dff21e65e98bc4ec63f3
|
|
| BLAKE2b-256 |
c623be1f259e45881b4b7fe7bbef0b6e21fa1cc4a44b28df6b5d3177931eabee
|
File details
Details for the file clap_detector-2.0.7-py3-none-any.whl.
File metadata
- Download URL: clap_detector-2.0.7-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2bffe7e287d119683faaeda229c0724230ab08085dad58a41d111681e4be8e9
|
|
| MD5 |
7ea3a63b17f1f27d79f87766165ec766
|
|
| BLAKE2b-256 |
c7f685d0c375efe004f881f2f0293b1cc2086dea01358f4f506a821d6aeafaf1
|