Skip to content

SnowWarri0r/slumbr

Repository files navigation

Slumbr

Slumbr

Smart sleep-aid app that plays ambient sounds and auto-fades volume as you fall asleep

Stars License Release Flutter Dart Platform

Pick a sound, press play, fall asleep — Slumbr detects your sleep and gently fades the volume to silence. No timers to set, no manual adjustments. Just sleep.


Features

  • 19 Curated Sounds — Hand-picked ambient sounds across 4 categories
  • Sleep Detection — Microphone-based monitoring detects when you fall asleep
  • Smooth Volume Fade — Continuous linear interpolation, not jarring step changes
  • Live Switching — Change sounds mid-session without restarting detection
  • Sleep Summary — Duration, stage breakdown, and timeline when you stop
  • Categorized Browser — Expandable categories: Rain, Nature, Noise, Other
  • Zero Config — No account, no cloud, no timers to set — just press play

How It Works

┌─────────────┐   audio_streamer  ┌─────────────┐   Volume    ┌─────────────┐
│  Microphone │───────────────►│  Silero VAD │────────────►│    Fade     │
│  (PCM 16k)  │   Float→PCM16   │  Voice Det. │   Factor    │   Volume   │
└─────────────┘                  └─────────────┘  (linear)   └─────────────┘
  1. Pick a sound from 4 categories and tap Start
  2. Audio plays immediately while Silero VAD loads in background
  3. Microphone captures audio via audio_streamer, fed into Silero VAD model
  4. VAD distinguishes human voice from speaker playback in real-time
  5. As silence duration increases, sleep stages progress:
Quiet Duration Stage Volume Behavior
0 – 10 min Awake 100% Full volume
10 – 30 min Falling Asleep 100% → 64% Gradual fade
30 – 60 min Light Sleep 64% → 10% Continues fading
60+ min Deep Sleep 10% Fades to silence, stops
  1. If voice is detected, volume smoothly ramps back up (5-second fade)
  2. On stop, a Sleep Summary dialog shows stage timeline chart and duration breakdown

Sound Library

Category Sounds
🌧 Rain Heavy Rain, Light Rain, Rain on Window, Rain on Tent, Thunder
🌿 Nature Campfire, River, Waterfall, Waves, Wind in Trees, Jungle, Crickets
🔊 Noise Brown Noise, Pink Noise, White Noise
✨ Other Cat Purring, Singing Bowl, Inside a Train, Underwater

Getting Started

Prerequisites

  • Flutter SDK >= 3.11
  • Android SDK (compileSdk 36) or Xcode for iOS
  • Java 17

Install & Run

# Clone
git clone https://github.com/SnowWarri0r/slumbr.git
cd slumbr

# Install dependencies
flutter pub get

# Run on connected device
flutter run

Build

# Android APK
flutter build apk --release

# iOS (requires macOS + Xcode)
flutter build ios --release

Tech Stack

Layer Technology
Framework Flutter + Material Design
Audio Playback just_audio (looping, volume control)
Microphone audio_streamer (raw PCM capture)
Voice Detection vad (Silero VAD model)
Background flutter_foreground_task (screen-off operation)
Charts fl_chart (sleep timeline)
Permissions permission_handler
i18n Custom lightweight (en/zh)

Architecture

lib/
  main.dart            # App entry, MaterialApp with i18n config
  home_page.dart       # Main UI — sound picker, playback, volume fade, summary chart
  sleep_detector.dart  # audio_streamer + Silero VAD, stage detection, foreground service

assets/audio/
  rain/                # 5 rain & storm sounds
  nature/              # 7 nature & wildlife sounds
  noise/               # 3 colored noise variants
  other/               # 4 unique ambient sounds

CI/CD

Workflow Trigger Action
CI Push / PR to main flutter analyze
Release Push v* tag Build APK → GitHub Release
# Create a release
git tag v1.0.0
git push origin v1.0.0
# → GitHub Actions builds APK and publishes release automatically

Sound Credits

Ambient sounds sourced from Moodist (MIT License).

Contributing

Issues and PRs are welcome! Feel free to open an issue for bug reports or feature requests.

License

MIT © SnowWarri0r


If this project helps you sleep better, consider giving it a ⭐

About

Smart sleep-aid app — 19 ambient sounds with microphone-based sleep detection and auto volume fade

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors