a pure bash script to detect hand claps
apt-get install sox gitmacOS (homebrew required)
brew install soxgit clone https://github.com/daweedm/bash-clap && cd bash-clap && chmod +x bash-clap.shWhat audio source to use ? ref.
First, install alsa-utils :
apt-get install alsa-utilsThen list all available devices :
arecord --list-devicesYou get an output similar to this
**** List of CAPTURE Hardware Devices ****
card X: (...), device Y: (..)
Subdevices: 1/1
Subdevice #0: subdevice #0
(...)
You might have more than one audio interface (integrated audio card, USB-wired mic, ...). Once you have chosen the interface you want to use, you can guess your audio source from the numbers X and Y : src="alsa hw:X,Y"
Open bash-clap.sh and change the src variable to your audio source if it differs from the default one.
Nothing to do ! You can leave src value to "auto"
When a clap is detected, the on_clap() function is executed. You can customize its behavior in the bash-clap.sh file.
You can use the screen for Linux tool to keep the process listening for claps in the background