Skip to main content

Audio monitoring system that detects and alerts you about important sounds in your home while you're away.

Project description

Loud Noise Detector

PyPI version Python Versions License: MIT

"Buy Me A Coffee"

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 be informed about important sounds occurring in spaces where you can't be physically present.

🚀 Features

  • Real-time detection of significant sounds (barking, crying, etc.)
  • Customizable noise thresholds to match your needs
  • Automatic recording when relevant sounds are detected
  • Instant notification system
  • Detailed event logging
  • Easy to configure and customize

📋 Requirements

  • Python 3.6 or higher
  • PortAudio (for PyAudio) Ubuntu: sudo apt install python3-dev portaudio19-dev
  • Working microphone

🔧 Installation

From PyPI

pip install loud-noise-detector

From Source

  1. Clone the repository:
git clone https://github.com/Endika/loud-noise-detector.git
cd loud-noise-detector
  1. Create and activate a virtual environment:
python -m venv .venv
# On Windows
.\.venv\Scripts\activate
# On Unix or MacOS
source .venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Install development dependencies (optional):
pip install -r dev-requirements.txt

⚙️ 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 Yes - Your Slack bot token (starts with xoxb-)
SLACK_CHANNEL Yes - Channel where notifications will be sent

Note: For Slack notifications, you'll need to:

  1. Create a Slack App in your workspace
  2. Add chat:write and files:write OAuth scopes
  3. Install the app to your workspace
  4. Copy the Bot User OAuth Token to SLACK_TOKEN
  5. 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. Place it in the config/ directory or specify its location using the --config argument.

🎯 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 in debug mode
loud-noise-detector --debug

As a Python Module

python -m src.main

📊 Development

Running Tests

# Run all tests
make test

Code Quality

# Run linting
make lint

# Run type checking
make quality

🤝 Contributing

This project uses Semantic Release for versioning.

Commit Message Format

Your commit messages must follow this format to trigger automatic version updates:

Development Workflow

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Commit with appropriate message format
  5. Push to your branch (git push origin feature/amazing-feature)
  6. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loud_noise_detector-3.0.0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loud_noise_detector-3.0.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file loud_noise_detector-3.0.0.tar.gz.

File metadata

  • Download URL: loud_noise_detector-3.0.0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for loud_noise_detector-3.0.0.tar.gz
Algorithm Hash digest
SHA256 db8120eb013b3acbfd47e398a8172e4ffd4630aa92fbe377c7600fd93df1e26b
MD5 48ff9942d37c424376639ea298cc6f2d
BLAKE2b-256 afc8d0a0b8e7f2d2ebe600cf70548bf884479213f27276243378ceb67f26d45f

See more details on using hashes here.

Provenance

The following attestation bundles were made for loud_noise_detector-3.0.0.tar.gz:

Publisher: release.yml on Endika/loud-noise-detector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file loud_noise_detector-3.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for loud_noise_detector-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9eefbe198940672f3b900de61b486f3fe2b55bb6d505a0587c150bccaa2085a
MD5 f7b7bca6e61ff017b31e05b75aab310c
BLAKE2b-256 0dc3f843e1848e98d38b625ab8ce37041cbc1d5e7a1d8b003f48182c73b71a2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for loud_noise_detector-3.0.0-py3-none-any.whl:

Publisher: release.yml on Endika/loud-noise-detector

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page