On Sun, 25 Oct 2015 17:17:28 -0700 Montana Burr <montana.b...@gmail.com> wrote:
> I'm looking for a library that will allow Python to listen for the > shriek of a smoke alarm. Once it detects this shriek, it is to notify > someone. Ideally, specificity can be adjusted for the user's > environment. I've used python to detect and record ambient sound by launching the simple command-line program sox (in its guise as "rec") as a python subprocess. I hope someone corrects me, but the few python audio libraries seemed to me to be overkill in terms of coding required and underkill in terms of features. With sox, it's easy to set things like length of recording and a triggering threshold etc.. The latter is good for your use-case because you can set it high enough to only start recording when something is loud enough to be an alarm. Once you have your recording, as others have pointed out, what you do to detect an alarm sound in it will depend on what alarms sound like where you live. > I'm thinking of recording a smoke alarm and having the program try to > find the recorded sound in the stream from the microphone. That kind of matching is IMO unlikely to work. The human ear (or rather the brain's auditory processing) is very good at picking out the same general sound in different contexts. Getting software to do this is hard. I had a quick look at the acoustid module, which uses Shazam-style acoustic fingerprinting. It has a method for measuring the similarity of different recordings, but my little trials weren't promising. A test recording of my ringtone measured as identical to itself (so far so good), but only about 25% identical to another recording of the same ringtone. A recording of me randomly whistling also measured about 25% similar to the ringtones. If your smoke alarms are anything like mine, they have a fixed pitch, volume and pulse, simple machine-friendly properties that are unlikely to happen by accident. You could try the aubio module (not a typo, that's aubio with a "b"). I've never used it and it's python 2 only, but it has pitch, onset time and "beat" detection. You might be able to use it to measure those properties from a sample recording, and then check your monitored recordings to see if they have roughly the same measurements. Regards John -- https://mail.python.org/mailman/listinfo/python-list