I’d like to use my Raspberry Pi to record when and how often my dog barks. But for privacy reasons, I don’t simply want to record the loudness in the room, so I have to automatically detect barks.
How would I do that?
I’d like to use my Raspberry Pi to record when and how often my dog barks. But for privacy reasons, I don’t simply want to record the loudness in the room, so I have to automatically detect barks.
How would I do that?
Interesting question. Take a look at: http://www.dsprelated.com/showthread/comp.dsp/129392-1.php And keep in mind that there are commercial products out there to identify barking and emit ultrasound when a dog barks, such as: http://www.ultimatebarkcontrol.com/dog-silencer.htm#tabContent
I don't know how complicated you'd want to make things (ie: detect just your dog barking, other dogs barking, detect a single bark, mutiple barks, etc.). Or, as mentioned by Moti, what kind of probability of detection (PD) or false alarm rate (PFAR) you'd like to achieve. I suppose the simplest approach would be to record several single barks from your dog, then set your phone to listening, and process the incoming signal. If the loudness level exceeds a certain threshold, and the time length seems appropriate, you'd suspect that it's a bark, and either cross correlate the suspected bark with your previous recordings, or compute the coherence function to determine the similarity of the incoming signal with the previous recordings.
Maximizing correct detections and minimizing false alarms may be difficult with a simple system, though. I don't know how sophisticated the commercial systems get, but you may want to look into them and see if you can garner any hints/suggestions.
You don't necessarily have to keep a recording of the sound in order to process it. Just read in frames, compute the RMS energy (for example), and recycle your frame buffer. Essentially rewriting history and preserving your privacy. A circular buffer design would be suitable for audio processing (think about sliding windows in FFTs).
That said, while most commercial and open source dog bark detection systems rely on simply the volume of the dog bark, they are not very robust. If your neighbour is hammering away at some DIY woodwork, your system will trigger.
Regarding the Pi, if you're still working on this, maybe check out David Hunt's Pi-Rex project... maybe you can even improve upon it!
You could train a deep learning AI to classify the sounds for you, then use that as an event source.
https://medium.com/@mikesmales/sound-classification-using-deep-learning-8bc2aa1990b7
Use a directional microphone. Shotgun mikes work excellent. Point at dog location and have recording start at a db level you determine by experiment. You can weed out high frequencies (non dog barks) by simply placing a piece of plastic wrap looselystretched over a toilet paper roll attached to and in front of the microphone.