New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

clap-detector

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clap-detector - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

8

index.js

@@ -64,3 +64,2 @@ var _ = require('lodash');

function _listen() {
console.log("------ Listen for noise --------");
// Listen for sound

@@ -97,3 +96,3 @@ var cmd = 'sox -t alsa ' + CONFIG.AUDIO_SOURCE + ' ' + CONFIG.SOUND_FILE + ' silence 1 0.0001 ' + CONFIG.DETECTION_PERCENTAGE_START + ' 1 0.1 ' + CONFIG.DETECTION_PERCENTAGE_END;

// Check that file is a clap
var cmd = "sox " + SOUND_FILE_CLEAN + " -n stat 2>&1"; //| sed -n 's#^Length (seconds):[^0-9]*\\([0-9.]*\\)$#\\1#p'
var cmd = "sox " + CONFIG.SOUND_FILE_CLEAN + " -n stat 2>&1"; //| sed -n 's#^Length (seconds):[^0-9]*\\([0-9.]*\\)$#\\1#p'
var regExDuration = /Length[\s]+\(seconds\):[\s]+([0-9.]+)/;

@@ -104,3 +103,2 @@ var regExRms = /RMS[\s]+amplitude:[\s]+([0-9.]+)/;

// Is this a clap of hand ?
console.log('debug', error, out, stderr);
var durationData = out.match(regExDuration);

@@ -142,3 +140,5 @@ var duration = parseFloat(durationData[1]);

start: function (props) {
_.assign(CONFIG, props);
if(props) {
_.assign(CONFIG, props);
}
_listen();

@@ -145,0 +145,0 @@ },

{
"name": "clap-detector",
"version": "0.1.0",
"version": "0.1.1",
"description": "Clap detection for node js (linux, raspberry systems)",

@@ -11,3 +11,3 @@ "main": "index.js",

"type": "git",
"url": "git+ssh://git@github.com/tom-s/clapDetector.git"
"url": "http://git@github.com/tom-s/clapDetector.git"
},

@@ -19,3 +19,5 @@ "keywords": [

"detection",
"sox"
"sox",
"alsa",
"microphone"
],

@@ -22,0 +24,0 @@ "author": "tom-s",

@@ -1,2 +0,70 @@

# clapDetector
Clap detection module for node js
===
## Synopsis
At the top of the file there should be a short introduction and/ or overview that explains **what** the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)
I created this module for my project of personal assistant on Raspberry Pi. 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)
## Requirements
This module works on a linux based OS (raspbian, Ubuntu, Debian...) using alsa for audio and having a working microphone.
## Installation
This module requires sox, "the Swiss Army knife of sound processing programs" (http://sox.sourceforge.net/) to be installed
```bash
sudo apt-get install sox
```
You can simply add this module to your node.js project with
```bash
// sudo might be required depending on your system
npm install --save clap-detector
```
## Usage
There are thee public methods you can use:
- clapDetector.start(clapConfig);
=> this needs to be called to initialize clap detection. The clapConfig object is not mandatory but you can use it to overwrite the default configuration (see next section)
- clapDetector.onClap(yourcallbackfunctionhere)
=> register a callback that will be triggered whenever a clap of hand is detected
- clapDetector.onClaps(numberOfClaps, delay, yourcallbackfunctionhere)
=> register a callback that will be triggered whenever a serie of claps (determined by the number of claps) is detected within the period of time you've specified (delay).
```bash
// 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 3 seconds
clapDetector.onClaps(3, 2000, function(delay) {
//console.log('your callback code here ');
}.bind(this));
```
## Tests
These will be added soon. Please do not hesitate to add some !
## About the Author
I am a full-stack Javascript developer based in Lyon, France.
[Check out my website](http://www.thomschell.com)
## License
clap-detector is dual licensed under the MIT license and GPL.
For more information click [here](https://opensource.org/licenses/MIT).

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc