ZenSloth:為「無所事事的藝術」打造的離線優先睡前伴侶
ZenSloth: An Offline-First Bedtime Companion Built for the Art of Doing Nothing
ZenSloth 是一款離線優先的睡前伴侶,透過 Ollama 本機運行 qwen2.5:1.5b,生成舒緩故事與正念冥想。它以 Web Audio API 即時合成環境音,並提供 4-7-8 呼吸引導;個人睡眠筆記和睡前想法不會離開用戶裝置。
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady
What I Built
In celebration of International Sloth Day and the Slow and Steady theme, I built ZenSloth — a private, offline-first bedtime sleep companion and ambient narrative generator that invites you to slow down, conserve your energy, and do absolutely nothing.
Modern bedtime apps and AI tools are full of stimulation: subscription paywalls, notifications, cloud tracking, dopamine loops, and chatbots trying to solve problems. ZenSloth does the exact opposite. Channeling the unhurried spirit of a sloth, it creates a calming, low-stimulation cocoon for your mind:
- 🦥 Unrushed Ambient Narratives: Generates calming, low-stimulation bedtime stories and mindful meditations tailored to 4 serene archetypes (The Sloth Sanctuary, Ancient Moss Forest, Rainy Cedar Cabin, and Velvet Twilight).
- 🌊 Procedural Soundscape Synthesizer: Four ambient channels (Deep Brown Noise, Gentle Rain, Soft Wind, and Warm Hearth) synthesized 100% on the fly in the browser using the Web Audio API — no gigabytes of looping audio files or buffering.
- 🫁 4-7-8 Sloth Breathing Guide: A gentle pulsing orb with a warm amber glow guiding a 4-second inhale, 7-second hold, and 8-second exhale to trigger the body's natural relaxation response.
- 🔒 100% Local & Private: Powered by local open-weight inference with Ollama. No personal sleep notes or bedtime thoughts ever leave your machine.
ZenSloth lets you be as lazy as possible: pick a mood, tap once, close your eyes, and drift off to sleep.
Demo
ZenSloth is an offline-first companion designed to run privately and reliably on your own machine without third-party cloud tracking.
Run Locally with Docker (One Command)
Clone the repository and spin up the containers:
git clone https://github.com/AryanMohan818/ZenSloth.git
cd ZenSloth
docker compose up -d
Pull the lightweight open-weight model:
docker exec -it zensloth-ollama ollama pull qwen2.5:1.5b
Open http://localhost:3000 in your browser, lay back, and enjoy your wind-down session.
Code
This is a Next.js project bootstrapped with create-next-app.
Getting Started
First, run the development server:
npm run dev # or yarn dev # or pnpm dev # or bun dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
Learn More
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
Deploy on Vercel
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more…
How I Built It
ZenSloth is built entirely around an open-source, local-first stack designed for calm aesthetics, zero network latency, and complete privacy:
1. Local Open-Weight Inference with Ollama (qwen2.5:1.5b)
Bedtime apps shouldn't depend on cloud API rate limits, subscription keys, or internet connectivity. ZenSloth uses Ollama running lightweight open-weight models (defaulting to qwen2.5:1.5b).
- Low-Stimulation Prompt Engineering: The system prompt enforces strict calming narrative rules: short 2–3 sentence paragraphs, sensory-rich textures, zero cliffhangers, and natural drowsiness pacing (250–350 words).
-
Edge Streaming: The Next.js Route Handler (
/api/generate) leveragesReadableStreamto stream tokens directly from Ollama to the browser in real-time, giving listeners an immediate, flowing experience without waiting for full generation.
2. Pure Procedural Web Audio Engine
Instead of bundling heavy MP3 assets or streaming audio over Wi-Fi, ZenSloth includes a custom procedural audio engine built on the native Web Audio API:
- Brown Noise: Continuous noise filtered through a lowpass biquad filter at 400Hz to mask room sounds.
- Rain: Pink noise algorithm passing through a 1000Hz filter.
- Wind: Low-frequency bandpass-filtered noise with organic gain modulation.
- Fireplace Hearth: Brown noise interspersed with algorithmic crackle and pop bursts.
3. Next.js 16 + Tailwind CSS v4
- Next.js 16 (App Router) & React 19: Built with standalone output and containerized with Docker.
-
Tailwind CSS v4: Designed with an ultra-dark palette (
#07080b), soft amber/stone hues, and blur filters to minimize blue light before sleep. - Docker Compose: Orchestrates both the frontend web app and Ollama service with persistent model caching.
Why Does Open Innovation Matter?
Your bedroom is your most personal, private space. When you tell a sleep app about the anxiety keeping you awake, your racing thoughts, or your bedtime routine, that data shouldn't be packaged into an advertising profile or logged on proprietary cloud servers.
Open innovation made ZenSloth possible in ways closed APIs never could:
- Complete Privacy & Offline Capability: By using open-weight models with Ollama, ZenSloth can run on an airplane, in a rustic cabin off the grid, or with Wi-Fi completely turned off. Closed AI models break the moment your internet disconnects.
- Freedom from Subscriptions: Closed sleep apps frequently lock soundscapes and stories behind expensive annual paywalls. With open-weight AI and browser-synthesized audio, this app belongs to the user forever.
-
Low-Resource Accessibility: Open-weight models like
qwen2.5:1.5brun smoothly on standard laptops and budget mini-PCs without needing expensive enterprise GPUs.
The Lazy Payoff
Building bedtime routines usually feels like work: searching for a meditation podcast, adjusting white noise playlists, skipping mid-roll ads, or staring at bright screens trying to decide what to listen to.
ZenSloth reduces all of that friction to zero effort:
- One click sets the scene, balances the ambient rain, wind, and brown noise, starts the 4-7-8 breathing guide, and streams an unhurried, gentle bedtime story.
- Time & Effort Saved: 15–20 minutes of nighttime screen scrolling replaced by instant relaxation.
- Tested this week for actual bedtime wind-downs: no ads, no cliffhangers, and zero blue light overload.
Prize Categories
- Overall Winner (Hacktoberfest Open-Source AI Challenge: Week 3 - Slow and Steady)
-
Best Use of Gemma (Powered locally via Ollama using Google's open-weight
gemma2:2b)
來源:DEV Community · dev.to