Littlesleeper is an MP3 stream noise level monitor. It can be used as a baby crying monitor. It identifies crying blocks based on the peak volume that exceeds a threshold volume level and when that peak volume is present for a pre-set amount of time. These variables can be set in the configuration file config.ini.
This is a port of the noise monitor written by Neil Yager called LittleSleeper. Many kudos to Neil for writing this.
The main difference between LittleSleeper2 and Neil's is that instead of reading the audio directly from a microphone, Littlesleeper2 processes the audio data from an MP3 stream hosted by a Raspbery Pi.
This allows the processing and web hosting to be handled completely by the RPi or offloaded to another computer that has a python environment. I primarily use the latter, so I can offload the processing to another server. However, I have briefly tested Littlesleeper2 on the Raspberry Pi and it seemed to outperform my Ubuntu Server based on CPU load.
The architecure is shown below:
The RPi can be the Icecast + Darkice server with a mic and Littlesleeper2 can run on any commputer with python.
- matplotlib
- numpy
- scipy
- tornado
- librosa
- sqlalchemy
- audioread (branch/master that supports audioread.decode()) See this issue
- You will also need to have FFMPEG installed to decode the audio stream.
- Setup Icecast + Darkice on Raspberry Pi
- Set variables in
config.iniandwww/static/config.js:
- For
config.ini:- Copy
example.config.initoconfig.ini - Set the url to the MP3 stream with
STREAM_URL - Set the port for the Tornado web server with
WEB_SERVER_PORT - Set the bit rate of the MP3 stream with
BIT_RATE. This is necessary to calculate the block of bytes read from the stream based on theSAMPLE_RATE. - Other variables, such as
NOISE_THRESHOLD,MIN_QUIET_TIME, andMIN_NOISE_TIME, can be set based on your preferences.
- Copy
- For
www/static/config.js:- Copy
www/static/example.config.jstowww/static/config.js - Set the url to the Web Socket server with
ws_server ws_servershould be the LAN/WAN IP or FQDN of the Tornado Web Server and port set withWEB_SERVER_PORT
- Copy
- Run Littlesleeper2:
./littlesleeper.py
Littlesleeper can connect to an authenticated Icecast stream. However, the username and password are stored as ASCII in the config.ini.
