SlothSnooze:獎勵極度懶散的離線牀邊伴侶
SlothSnooze: The Air-Gapped Bedside Companion That Rewards Extreme Laziness
SlothSnooze 是一款開源、可離線運作的 AI 睡前伴侶,利用本機模型或內置離線引擎生成睡前故事,並以 Web Audio API 合成環境音。它提供慢速旁白、雙耳節拍、呼吸引導及自動淡出功能,並設有一鍵睡眠模式和 45 分鐘定時器。呼吸日誌儲存在本機 JSON 檔案,項目稱可免費永久使用。
Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady
What I Built
Sloths sleep between 15 and 20 hours a day. They don’t doomscroll, they don't count steps, they don't subscribe to wellness apps, and they never stress about tomorrow.
In honor of International Sloth Day and this week’s "Slow and Steady" Hacktoberfest challenge, I built SlothSnooze: an air-gapped, open-source AI bedtime companion designed to reward absolute, unadulterated laziness.
Instead of fighting insomnia by staring into phone screens or paying $70/year to have commercial apps transmit your bedroom audio to corporate clouds, SlothSnooze does all the heavy lifting with a single click:
- Generates hyper-soothing, slow-cadence bedtime stories powered by local open-weight models (Llama 3.2, Qwen 2.5, or its built-in offline neural engine) grounded in rainforest sensory details (cool mountain mist, damp moss, twilight canopies).
- Synthesizes real-time procedural ambient soundscapes using pure mathematical Web Audio (rain on canopy leaves, gentle wind gusts, night crickets, bubbling mountain brooks, and Tibetan singing bowls).
- Entrains your brainwaves into restorative delta/theta sleep using authentic stereo binaural beats (4.0 Hz Theta wave & 2.5 Hz Delta wave).
- Narrates the story at an ultra-slow sloth cadence (~75 words per minute) with built-in acoustic ducking—automatically softening ambient rain when the voice speaks and swelling gently during breath pauses.
- Slows your pulse with a bioluminescent sloth breathing guide (Sloth 4-7-8 and Deep Hibernation rhythms).
- Fades out automatically with an exponential 3-minute sleep timer.
Who gets to be lazy? Anyone who has ever laid awake in bed with a spinning mind. You press one button, roll over, and fall asleep.
Demo
Here is a look at SlothSnooze in action:
Key Features in Action:
- 1-Click Lazy Sleep Mode: Directly activates Night Dim mode, launches the ambient soundscape, starts the 45-minute canopy snooze timer, and begins slow bedtime narration.
- Pure Mathematical Sound Synthesizer: 6-channel mixer running directly on Web Audio API—zero audio files downloaded, 100% offline.
- Audio Oscilloscope & Visualizer: Displays live sound frequencies with a bioluminescent emerald glow.
- Sloth 4-7-8 Breathing Orb: Gently expands and contracts with glowing firefly particles to guide parasympathetic nervous system relaxation.
- Night Dim Mode: Softens blue light to protect melatonin production at your bedside.
Code
The complete source code is available in the repository.
Key Architecture:
- Backend (
FastAPI+Python):-
app/engine/story_agent.py: Probes local Ollama instances (http://localhost:11434), auto-detects downloaded open weights (Llama 3.2, Qwen 2.5, Mistral), and provides an instant offline fallback engine for completely air-gapped operation. -
app/engine/soundscape_engine.py: Defines acoustic harmonics, binaural beat offsets, and sloth breath timings. -
app/engine/journal_engine.py: Air-gapped local sleep journal that stores dream logs in local JSON files without telemetry.
-
- Frontend (Pure Modern CSS & JavaScript):
-
app/static/js/audio_synth.js: Web Audio node network (Pink noise generators, biquad bandpass filters, LFO frequency modulation, stereo channel mergers). -
app/static/js/story_reader.js: Offline Speech Synthesis reader tuned to sloth pacing with dynamic audio ducking. -
app/static/js/app.js: Dynamic starfield canvas, audio oscilloscope, breathing engine, and sleep timer.
-
How I Built It
SlothSnooze is built from the ground up around open-source AI and local inference:
- Open-Weight Language Models:
- SlothSnooze integrates with local open-weight models via Ollama and OpenAI-compatible local servers (like LM Studio or llama.cpp).
- It shines brightest with compact, ultra-efficient open weights like Meta’s Llama 3.2 (1B and 3B) and Alibaba’s Qwen 2.5 (3B). These models run fast on standard laptops without requiring monster GPUs, producing vivid, descriptive bedtime imagery in milliseconds.
- The Sloth Prompt Engineering Framework:
- Traditional LLM prompts generate brisk, action-oriented responses. SlothSnooze uses a specialized prompt structure that forces low informational density, deliberate sentence rhythms, sensory grounding (tactile moss, nocturnal mist, slow sway), and an absence of any plot conflict.
- Air-Gapped Atmospheric Fallback Engine:
- To make sure SlothSnooze works when camping off-grid or on an airplane with zero dependencies running, we implemented a procedural atmospheric generator that weaves randomized sloth folklore and sensory passages into a cohesive sleepy narrative.
- Pure Procedural Audio Synthesis:
- Rather than streaming gigabytes of repetitive MP3 loops, SlothSnooze uses the browser’s Web Audio API to generate all sounds mathematically (pink noise algorithms, low-pass filter sweeps, and dual-oscillator binaural beats).
Why Does Open Innovation Matter?
Open innovation is not just an implementation detail for SlothSnooze—it is the only reason the project can exist:
Bedside Privacy & Sanctuary (Air-Gapped AI)
Your bedroom is your most vulnerable, intimate environment. Commercial sleep apps like Calm or Headspace rely on closed cloud services, and smart bedside speakers keep active microphones connected to corporate cloud servers. With open-weight models running on your local machine, you can switch your WiFi completely off. No audio leaves your machine, no sleep habits are harvested, and no advertising profiles are built.The Death of Subscription Fatigue ($0 Forever)
Commercial sleep and meditation apps have turned basic human rest into a monthly rent-seeking scheme ($70–$100/year). Because open-source AI and open-weight models have no per-token API charges and zero recurring subscriptions, SlothSnooze is 100% free to run forever.Independence from Cloud Outages & Latency
When you are on a red-eye flight across the Atlantic or staying in an off-grid cabin in the woods, closed APIs like OpenAI or Anthropic fail completely. Because SlothSnooze executes local weights on-device, it operates seamlessly wherever you sleep.Total Model Freedom & Customization
With closed models, you are stuck with whatever safety filters and conversational tone the cloud provider dictates. With open weights, you can run SmolLM on a tiny handheld, Llama 3.2 on a MacBook Air, or fine-tune your own sloth bedtime narrator without asking permission from anyone.
My Agent Session
This project was built pair-programming with Antigravity, an advanced coding agent from Google DeepMind. The session involved:
- Conceptualizing the International Sloth Day theme and lazy user experience.
- Generating the bespoke digital artwork (
sloth_snooze_hero.jpgandsloth_mascot_avatar.jpg) using text-to-image tools. - Architecting the Python FastAPI backend with local Ollama auto-discovery.
- Implementing the procedural Web Audio synthesis engine with real-time binaural brainwave modulation and audio ducking.
- Designing a bioluminescent dark-mode interface with an interactive starfield and breathing guide.
The Lazy Payoff
Let's measure the actual lazy return on investment:
- Time saved from doomscroll insomnia: ~45 minutes per night.
- Mental effort required: Exactly 1 mouse click on "Lazy Sleep Mode".
- Money saved: ~$84.00/year in commercial app subscriptions avoided.
- Energy Conserved: 99.4% (Barnaby the Sloth approved).
Prize Categories
- Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady
- Best Use of Local Inference / Open-Weight Models
- Best Offline / Air-Gapped Application
來源:DEV Community · dev.to