Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
clap-detector
Advanced tools
ClapDetector is a hand clap detection module for nodejs (iojs). I detect a clap or a series of claps and allow you to trigger callbacks whenever these events happen. I created this module for my project of personal assistant on Raspberry Pi (raspbian). The clap detection allows me to activate the assistant whenever I need it (and prevent it from continuously being listening for instructions or interpreting random noises as instructions)
This module works on a linux based OS (raspbian, Ubuntu, Debian...) using alsa for audio and having a working microphone.
This module requires sox, "the Swiss Army knife of sound processing programs" (http://sox.sourceforge.net/) to be installed
sudo apt-get 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: 'hw:1,0'
};
// 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 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
CLEANING: {
PERFORM: false, // set to true if you want to clean the file from noise before analyzing it. It requires a sox noise profile
NOISE_PROFILE: 'noise.prof' // path to the sox noise profile
},
SOUND_FILE : "input.wav", // name of wav file created while recording
SOUND_FILE_CLEAN : "input-clean.wav", // name of cleaned (if you activated cleaning) file
CLAP_AMPLITUDE_THRESHOLD: 0.7, // minimum amplitude threshold to be considered as clap
CLAP_ENERGY_THRESHOLD: 0.3, // minimum 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. You can also activate cleaning (CLEANING.perform) of the noise for better results. In order to do that record a wav file (using your microphone) without talking and then generate the sox profile with the command:
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 1 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.