peff / knock Goto Github PK
View Code? Open in Web Editor NEWrecognize audio secret knocks
recognize audio secret knocks
This is a tool for recognizing audio "secret knocks". Usage is something like: 1. Record a knock. You can use any program you like, or even pipe directly into "listen" in step 2, though keeping a copy is handy if you want to be able to teach anybody your knock. The "trim" here just limits the recording length; you don't need to trim silence yourself. $ rec knock.mp3 trim 0 5 2. Compute the knock times using the "listen" tool. Weirdly sox doesn't seem to handle mp3 over stdin, hence the conversion here. $ sox knock.mp3 -t wav - | ./listen 0.812500 1.593750 2.343750 2.718750 -- 2. Check for similar knocks by feeding a live recording into "listen", which finds knocks, and then check for matches using knock.pl. Note that even though our desired knock doesn't start at t=0, all times will be normalized against the first knock (so the first knock of an attempt always starts at the same time as the first knock of the match). A match is found if we saw the same number of knocks (followed by at least 1.5s of silence to indicate the end of the sequence), and if the timing of the knocks is close-ish (based on some arbitrary scoring heuristic) to the desired sequence. rec -q -t wav - | ./listen | perl knock.pl 0.8125 1.59375 2.34375 2.71875 | while read r; do case "$r" in ok) play -q bell.mp3 ;; *) play -q buzzer.mp3 ;; esac done There are a lot of heuristics and magic numbers in various programs: - the "listen" program breaks time into 2000-sample chunks (sox seems to default to 2 channels, 32000Hz, so that's about 31ms). It computes the "energy" for a chunk by looking for noise; anything over a certain cutoff is counted as a knock. That cutoff is hard-coded and just a guess (too low and you get noise counting as a knock; too high and you miss a knock). - the amount of silence to end a sequence is hard-coded to 1.5s. Shortening this makes the program more responsive (since it has to wait to decide the sequence is done) at the risk of cutting off knocks that come after long pauses. - the scoring heuristic in knock.pl is the sum of squares of the differences between each knock's time, with an arbitrary cutoff of 0.05 (which is not unit-less; we're ultimately comparing seconds). These could probably use some tweaking, but it seems to work OK in practice for my setup.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.