DEV Community

Cover image for Sloth Hour: a bedtime story and soundscape that run entirely on your laptop
Lagnadeep Samal
Lagnadeep Samal

Posted on

Sloth Hour: a bedtime story and soundscape that run entirely on your laptop

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

Sloth Hour is a wind-down companion that does the work so you don't have to. Pick a theme, press one button, and a local open-weight model writes a calm bedtime story while rain, ocean, wind or a low hum plays. The story can be read aloud slowly, and a sleep timer fades everything out, so you never have to pick up your phone again.

The effort it saves: no scrolling for something to listen to, and no getting up to turn it off. Anyone who struggles to switch off at night gets to be a little lazier.

Demo

Live page: https://lagnadeep-samal.github.io/sloth_hour/

The hosted page plays a built-in sample story to anyone who opens it. If you run Ollama on your own computer, it switches to real stories from your own model (setup is in the README). After one visit it also works offline.

Code

Sloth Hour

A bedtime story and soft background sound, generated on your own machine No build step, no accounts, no API keys. After the model is downloaded, it works offline.

  • Stories: a local open-weight model served by Ollama
  • Sound: rain, ocean, wind and a deep hum, synthesized live with the Web Audio API (no audio files)
  • Voice: your browser's built-in speech synthesis, read slowly
  • Sleep timer: fades everything out and stops
  • Demo mode: if Ollama isn't found, the page plays a built-in sample story so it still works
  • Installable: works as an offline app (PWA)

Run locally

ollama pull llama3.2
python -m http.server 8000     # use python3 on Mac/Linux
# open http://localhost:8000
Enter fullscreen mode Exit fullscreen mode

If Ollama says the port is in use, it is already running. Skip ollama serve.

Deploy (GitHub Pages)

  1. Create a repo and push this folder to the main branch.
  2. In the repo, go to Settings > Pages…

How I Built It

  • Model: llama3.2 running locally through Ollama. The page streams text from the /api/generate endpoint, and the model dropdown is filled from whatever models you have installed.
  • Sound: generated live in the browser with the Web Audio API (filtered noise and slow oscillators). There are no audio files.
  • Voice: the browser's built-in speech synthesis, read slowly.
  • Frontend: plain HTML, CSS and JavaScript. No framework and no build step.
  • Fallback: if Ollama isn't found, a built-in sample story plays, so the hosted page never looks broken.
  • Offline: a small service worker caches the page after the first visit.
  • Deployment: a GitHub Actions workflow publishes the static files to GitHub Pages. The model itself still runs on the visitor's own computer.

Why Does Open Innovation Matter?

A bedtime tool should work with the Wi-Fi off and should not send anything you say or hear to a server. A local open-weight model makes both true. It also costs nothing to run every night, and I can swap the model from a dropdown instead of waiting for an API to change.

Running the model locally has a catch: a hosted page can only talk to your Ollama if Ollama allows that page's address. I solved it with Ollama's OLLAMA_ORIGINS setting and documented it in the README. A closed API would have been simpler to connect, but it would have meant sending a person's bedtime thoughts to someone else's server and paying for every story.

The Lazy Payoff

One click replaces searching for a story or a playlist, and the sleep timer replaces getting up to turn it off.

Top comments (0)