This program can detect simple, continuous sounds, like the sound of a doorbell or entryphone, if it is generated by a buzzer. It is not suitable for "dling dlong"-like doorbells.
This program can discriminate between multiple different sounds. It uses Fast Fourier Transform for sound similarity analysis.
Once the sound is detected, an arbitrary action can be performed, such as calling a webhook. You can use services like IFTT to react to sound detection. For example, you may send a notification to your phone.
The program can be run on ARM-based devices, such as Odroid C2, incurring a minimal CPU usage.
Install dependencies:
sudo python3 -m pip install -r requirements.txt
On ARM-based devices, you may need to install NumPy from your Linux distribution. For example, in Ubuntu:
sudo apt-get update
sudo apt-get install python3-numpy
Then, in src
directory create a settings.py
file by copying settings.py.tpl
:
cd src
cp settings.py.tpl settings.py
You may need to explicitly set your sound card device id in settings.py
. To get the id of available sound cards, run the following command:
python -m sounddevice
First, you need to record a sample for each sound you want to detect.
Enter src
directory, and when no sound is played, run the command:
python doorbell.py SOUND_NAME
Wait for Waiting for sound
message. Then, shortly play your sound. 1 second is enough. The program detects your sound and saves a SOUND_NAME.npy
"fingerprint" of your sound in current working directory.
Repeat the operation for all the sounds you want to detect.
Start sound detector by running
python doorbell.py
If you want to call a webhook upon sound detection, set a webhook URL in settings.py
.