Loud Noise Detector
A Python system designed to detect and record significant noises in your home when you're away. Inspired by the need to monitor our pets when they're left alone at home for short periods, detecting barks or other sounds that might indicate distress or discomfort. It's also an ideal practical solution for parents who need to know if their baby is crying in another room. Perfect for any situation where you need to know about loud sounds in spaces where you can't be physically present.
Features
- Real-time detection of any sound louder than a threshold (barking, crying, etc.); it measures loudness (RMS) and doesn't tell sounds apart
- Customizable noise thresholds to match your needs
- Automatic recording when relevant sounds are detected
- Slack notification with the recording attached
- Detailed event logging
- Easy to configure and customize
Requirements
- Python 3.10 to 3.13
- PortAudio (for PyAudio) Ubuntu:
sudo apt install python3-dev portaudio19-dev - Working microphone
Installation
From PyPI
pip install loud-noise-detector
From Source
- Clone the repository:
git clone https://github.com/Endika/loud-noise-detector.git
cd loud-noise-detector
- Install dependencies with uv:
make install # uv sync --no-dev
# or, with the development tools
make develop # uv sync --all-groups
Configuration
Command Line Arguments
| Argument | Default Value | Description |
|---|---|---|
--config |
config/default_config.yaml |
Path to configuration file |
--verbose, -v |
False |
Enable verbose output |
--output-dir, -o |
data/recordings |
Directory to save recordings |
--threshold, -t |
- | RMS threshold to trigger detection |
--language, -l |
en |
Language for messages (en or es) |
--no-keep-files |
False |
Delete recording files after sending |
Configuration File Options
| Parameter | Default Value | Description |
|---|---|---|
threshold |
0.1 |
Sound level threshold to trigger detection |
cooldown_seconds |
5 |
Time to wait between detections |
seconds_to_record |
5 |
Duration of recording after detection |
pre_buffer_seconds |
2 |
Seconds of audio to keep before detection |
rate |
44100 |
Audio sampling rate |
channels |
1 |
Number of audio channels (1=mono, 2=stereo) |
format |
8 |
Audio format (pyaudio.paInt16) |
chunk_size |
1024 |
Size of audio chunks to process |
keep_files |
True |
Whether to keep recording files |
verbose |
False |
Enable detailed logging |
timestamp_format |
%Y%m%d_%H%M%S |
Format for timestamp in filenames |
language |
en |
Interface language (en or es) |
notifier_options |
{} |
Additional options for notification services |
Environment Setup
Generate your .env file with all necessary configurations:
# Generate .env file
cat > .env << EOL
# Slack configuration (required for Slack notifications)
SLACK_TOKEN=xoxb-your-token-here
SLACK_CHANNEL=CHANNEL-ID-HERE
EOL
Environment Variables Description
| Variable | Required | Default | Description |
|---|---|---|---|
SLACK_TOKEN |
No | - | Your Slack bot token (starts with xoxb-) |
SLACK_CHANNEL |
No | - | Channel where notifications will be sent |
Without a token and a channel, Slack notifications are disabled and the detector only records. Both can also be set in the configuration file under notifier_options.slack (token, channel), which takes precedence over the environment.
Note: For Slack notifications, you'll need to:
- Create a Slack App in your workspace
- Add
chat:writeandfiles:writeOAuth scopes- Install the app to your workspace
- Copy the Bot User OAuth Token to
SLACK_TOKEN- Copy the Channel ID to
SLACK_CHANNEL
Configuration Examples
For Pet Monitoring
threshold: 0.2 # Higher threshold for louder sounds like barking
cooldown_seconds: 30 # Longer cooldown to avoid too many notifications
seconds_to_record: 10 # Longer recording to capture context
pre_buffer_seconds: 3 # Capture sound before the bark
notifier_options:
slack:
channel: CHANNEL-ID-HERE
For Baby Monitoring
threshold: 0.15 # Lower threshold to detect crying
cooldown_seconds: 10 # Shorter cooldown for more frequent checks
seconds_to_record: 5 # Shorter recording duration
pre_buffer_seconds: 1 # Less pre-recording needed
notifier_options:
slack:
channel: CHANNEL-ID-HERE
You can create a configuration file in either YAML or JSON format and pass its path with --config. Without it, the detector reads config/default_config.yaml relative to the current directory, and falls back to the defaults above if that file doesn't exist.
Usage
Basic Usage
# Start the noise detector with default settings
loud-noise-detector
# Start with custom configuration file
loud-noise-detector --config path/to/config.yml
# Run with verbose output
loud-noise-detector --verbose
As a Python Module
python -m src.main
Development
Running Tests
# Run all tests
make test
Code Quality
# Run ruff and mypy
make lint
# Run lint, then fix and format the code
make quality
Contributing
This project uses release-please for versioning.
Commit Message Format
Commit messages follow Conventional Commits (feat: …, fix: …); release-please reads them to pick the next version.
Development Workflow
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Commit with appropriate message format
- Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Thanks to all contributors who have helped shape this project
- Built with Python and PyAudio
- Inspired by the need for reliable noise monitoring solutions
Contact
Endika Iglesias - endika2@gmail.com
Project Link: https://github.com/Endika/loud-noise-detector
Metadata
Release files for loud-noise-detector 3.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| loud_noise_detector-3.1.3.tar.gz | 10.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| loud_noise_detector-3.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.4 kB
Release files / loud_noise_detector-3.1.3.tar.gz
| Download URL | loud_noise_detector-3.1.3.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d2798968142f5e2a4502e925ba29a8757a202814aeb880edca31f74b2b443f7
|
|
BLAKE2b-256 checksum How to use checksums |
c5a7252b44916dc3547f144ff4ef51bf73b3b038e118cfebd94a9ce42946404e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / loud_noise_detector-3.1.3-py3-none-any.whl
| Download URL | loud_noise_detector-3.1.3-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a9ad4ea4a5e615276303672694111244047d601e71b64ba54907e9b5dc29cfce
|
|
BLAKE2b-256 checksum How to use checksums |
d119c0245281b2566ebb8887a0ae0a4ad20b0c4f6724e82f36faa9c6c180e6a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency log