DEV Community

Cover image for AI-Powered Calming Audio & Voice Companion for Dogs Home Alone

AI-Powered Calming Audio & Voice Companion for Dogs Home Alone

DEV Weekend Challenge: Dog Days Edition Submission 🐕

This is a submission for Weekend Challenge: Dog Days Edition

What I Built

Over 70% of dogs suffer from some degree of separation anxiety when their owners leave for work, errands, or travel. Symptoms include frantic barking, whining, pacing, destructive chewing, and prolonged stress spikes. Standard pet playlists on streaming platforms are static, repetitive, and lack the familiar reassurance pets crave most: their human's voice.

Paws & Peace is an intelligent, multi-platform sensory comfort system designed to give pets a peaceful home-alone experience. Available as both a modern web app and a native Android application, it combines:

  1. Personalized AI & Owner Voice Loops: Using ElevenLabs AI Voice Synthesis, pet parents can generate warm, soothing voice messages with their pet's name, customized reassurance phrases, and fine-tuned stability and clarity. Owners can also record their real voices directly in the built-in Voice Studio.
  2. Layered Procedural Soundscapes: Real-time synthesized pink-noise rainfall (to mask sudden doorbell and traffic sounds), a rhythmic maternal heartbeat simulator (60–70 BPM), and 432Hz harmonic drone frequencies scientifically proven to lower canine heart rates.
  3. Intelligent Departure & Interval Loops: Paced session scheduler with configurable departure delays (e.g., starts 5 minutes after leaving) and recurring voice reassurance (e.g., repeating loving phrases every 3 minutes).
  4. Biofeedback Breathing Visualizer: Luminous multi-ring ripple visualizer paired with live equalizers to create a tranquil visual atmosphere.
  5. One-Tap Smart Presets: Instant audio mixes tailored for Thunder Shield, Bedtime Lullaby, Leaving Home, and Quick Nap.

Demo

Web & Mobile Experience:

  • Web App: Glassmorphic, dark-mode responsive dashboard with Web Audio API procedural sound synthesis and Web Speech API fallback.
  • Android App: Native Jetpack Compose UI with AndroidX Media3 background foreground service that keeps soothing pets uninterrupted even when the device screen is locked.

Code


How I Built It

Building a truly effective sensory companion for dogs required blending canine psychoacoustics with modern cross-platform engineering.

1. Deep Integration with ElevenLabs AI Voice Synthesis

Voice is the strongest comfort cue for a dog. We integrated ElevenLabs' cutting-edge Text-to-Speech API to craft lifelike, warm voice tracks:

  • Turbo v2.5 Engine (eleven_turbo_v2_5): Upgraded synthesis to the newest ultra-low latency model (<300ms response time) with high throughput and lower credit usage.
  • Curated Soothing Voice Models: Selected gentle, calming voices (Rachel, Bella, Antoni, Domi, Elli) with adjustable Voice Stability (0.3 – 1.0) and Similarity / Clarity Boost (0.3 – 1.0) to achieve a soft, motherly or gentle fatherly cadence.
  • Auto-Retry & Rate Limit Handling: Implemented exponential backoff retry logic that catches burst rate limits (HTTP 429), waits 1.5 seconds, and transparently completes generation without failing.
  • Instant Audio Preview Engine: Embedded MediaPlayer (Android) and AudioContext (Web) previewers that immediately play synthesized tracks so owners can audit tone and volume before leaving.
  • Compile-Time Build Bridge: On Android, Gradle automatically reads VITE_ELEVENLABS_API_KEY from .env and injects it into BuildConfig, enabling zero-config out-of-the-box synthesis while still allowing user overrides in the Settings dialog.

2. Procedural Audio Synthesis (No Internet / No MP3 Loops)

Instead of streaming heavy, looping MP3 audio files:

  • Web: Implemented dynamic Web Audio API nodes with continuous pink noise buffers, a low-pass bi-quad filter, and an LFO oscillator for the rhythmic heartbeat.
  • Android: Engineered a native AudioSynthesizer using AudioTrack and direct PCM byte synthesis. This ensures zero network usage, minimal memory footprint, and infinite non-repeating acoustic variation.
  • Canine Acoustic Science:
    • Pink Noise: Has equal energy per octave ($1/f$ spectral density), which matches canine hearing frequency curves and masks sudden acoustic triggers (thunder, sirens).
    • Maternal Heartbeat: Low-pass filtered dual-pulse (lub-dub) at 65 BPM simulating a mother dog's calming presence.
    • 432Hz Sine Harmonic: Calibrated sinusoidal frequency associated with parasympathetic nervous system activation.

3. Native Android Architecture (Jetpack Compose & Media3)

  • UI & Design System: Built with 100% Jetpack Compose and Material 3, featuring glassmorphism, responsive 50/50 segmented tab controls, custom equalizers, and glowing gradient action buttons.
  • Background Foreground Service: Implemented PlaybackService powered by androidx.media3.exoplayer and MediaSessionService. This ensures that even when the owner locks the phone or puts it on the counter, the soothing playlist continues running indefinitely with interactive lock-screen media controls.
  • State Management: Built on unidirectional Data Flow with HomeViewModel, Kotlin Coroutines, StateFlow, and Jetpack Preferences DataStore for instant persistence of pet profiles and voice preferences.

Built for dogs everywhere who deserve peace and comfort while waiting for their best friends to come home.

Top comments (0)