
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
clap-detector
Advanced tools
ClapDetector is a hand clap detection module for nodejs (iojs). It detects a clap or a series of claps and allows you to trigger callbacks whenever these events happen. I created this module for my personal assistant project on a Raspberry Pi (raspbian). The clap detection allows me to activate the assistant whenever I need it (and prevents it from continuously listening out for instructions or interpreting random noises as instructions)
This module works on linux based OS (raspbian, Ubuntu, Debian...) using alsa for audio and a working microphone or Mac OS X using coreaudio.
This module requires sox, "the Swiss Army knife of sound processing programs" (http://sox.sourceforge.net/) to be installed
sudo apt-get install sox
brew install sox
You can simply add this module to your node.js project with
// sudo might be required depending on your system
npm install --save clap-detector
There are thee public methods you can use:
// Require the module
var clapDetector = require('clap-detector');
// Define configuration
var clapConfig = {
AUDIO_SOURCE: 'alsa hw:1,0'// default for linux
};
// Start clap detection
clapDetector.start(clapConfig);
// Register on clap event
clapDetector.onClap(function() {
//console.log('your callback code here ');
}.bind(this));
// Register to a serie of 3 claps occuring within 2 seconds
clapDetector.onClaps(3, 2000, function(delay) {
//console.log('your callback code here ');
}.bind(this));
You can pass a configuration object at the initialisation time (clapDetector.init(yourConfObject)). If you don't the following config will be used. You should at least provide the audio input (if different from the default config).
// DEFAULT CONFIG
var CONFIG = {
AUDIO_SOURCE: 'hw:1,0', // this is your microphone input. If you don't know it you can refer to this thread (http://www.voxforge.org/home/docs/faq/faq/linux-how-to-determine-your-audio-cards-or-usb-mics-maximum-sampling-rate)
DETECTION_PERCENTAGE_START : '5%', // minimum noise percentage threshold necessary to start recording sound
DETECTION_PERCENTAGE_END: '5%', // minimum noise percentage threshold necessary to stop recording sound
CLAP_AMPLITUDE_THRESHOLD: 0.7, // minimum amplitude threshold to be considered as clap
CLAP_ENERGY_THRESHOLD: 0.3, // maximum energy threshold to be considered as clap
MAX_HISTORY_LENGTH: 10 // all claps are stored in history, this is its max length
};
If you wish to improve the clap detection you can fiddle with the CLAP_AMPLITUDE_THRESHOLD and CLAP_ENERGY_THRESHOLD values. Depending on your microphone these might need to be modified.
sox -c 1 SILENCE.WAV -n trim 0 2 noiseprof noise.prof
These will be added soon. Please do not hesitate to add some !
I am a full-stack Javascript developer based in Lyon, France.
clap-detector is dual licensed under the MIT license and GPL. For more information click here.
FAQs
Clap detection for node js (linux, raspberry systems)
The npm package clap-detector receives a total of 5 weekly downloads. As such, clap-detector popularity was classified as not popular.
We found that clap-detector demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.