--- title: Lulluna - Bedtime Story Weaver emoji: ๐ŸŒ™ colorFrom: purple colorTo: indigo sdk: docker app_port: 7860 pinned: true license: apache-2.0 tags: - gradio - llama-cpp - text-generation - text-to-speech - image-generation - children - storytelling - small-models - build-small-hackathon - minicpm - kokoro - sd-turbo --- # ๐ŸŒ™ Lulluna โ€” Bedtime Story Weaver > **HuggingFace Build Small Hackathon 2026 ยท Track: Backyard AI** Lulluna solves a nightly challenge for busy parents: **"What story do I read tonight?"** In about 10 seconds it weaves a personalized bedtime story tailored to your child's age, name, and interests โ€” drawing from rich traditions like Aesop, Panchatantra, Norse mythology, and African folktales โ€” with a gentle value quietly threaded in and a soft closing line that helps little ones drift off to sleep. Every story can be **narrated aloud** in a warm voice and **illustrated** with a watercolour storybook image โ€” all on-device, with no API keys and no data leaving the machine. --- ## ๐Ÿค– AI Stack โ€” 100% Local, ~1.96 B Parameters Total | Component | Model | Params | Runtime | |---|---|---|---| | Story generation | [MiniCPM5-1B](https://huggingface.co/openbmb/MiniCPM5-1B-GGUF) (OpenBMB) | **1.0 B** | llama.cpp (GGUF Q4_K_M) | | Voice narration | [Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) (hexgrad) | **82 M** | PyTorch | | Illustration | [SD Turbo](https://huggingface.co/stabilityai/sd-turbo) (Stability AI) | **~860 M** | Diffusers (4-step) | | **Total** | | **~1.96 B** | All models โ‰ค 32 B โœ“ | --- ## ๐Ÿ… Badge Claims | Badge | How | |---|---| | ๐Ÿฆ™ **Llama Champion** | Story engine uses **llama.cpp** with GGUF Q4_K_M quantization | | ๐Ÿ”Œ **Off the Grid** | Zero cloud API calls โ€” all three models run entirely on-device | | ๐Ÿ““ **Field Notes** | [Read the build log โ†’](https://huggingface.co/blog/lulluna-build-small) | --- ## โœจ How to Use 1. **Fill in the form** on the left: child's name, age, interests, value/theme, cultural tradition, and length. 2. Click **โœจ Weave tonight's story** โ€” the story appears in ~10 s. 3. Click **๐ŸŽ™๏ธ Narrate** to hear it read aloud in a warm voice. 4. Click **๐ŸŽจ Illustrate** to generate a watercolour storybook cover (takes ~30 s). ### Traditions available Aesop ยท Panchatantra ยท Jataka ยท Japanese ยท African ยท Norse ยท Native American ยท Sufi ยท Celtic ยท Arabian ยท Chinese ยท Grimm ### Values available Kindness ยท Courage ยท Love ยท Honesty ยท Patience ยท Generosity ยท Friendship ยท Perseverance ยท Wisdom ยท Humility --- ## ๐Ÿ”Œ REST API (companion frontend) The Space exposes three endpoints for the companion React app: ``` POST /api/generate Request: {"data": [age, value, tradition, length, name, interests]} Response: {"data": [{"title": "...", "emoji": "...", "body": "..."}]} POST /api/narrate Request: {"data": ["full story text"]} Response: {"data": ["{\"audio\": \"\", \"mime\": \"audio/wav\"}"]} POST /api/illustrate Request: {"data": ["title", "body"]} Response: {"data": ["{\"image\": \"\", \"mime\": \"image/png\"}"]} ``` --- ## ๐Ÿ› ๏ธ Local Setup ```bash # 1. Clone and enter the backend directory git clone https://huggingface.co/spaces/YOUR_USERNAME/lulluna cd lulluna # 2. Create a venv (Python 3.10+) python -m venv .venv && source .venv/bin/activate # 3. Install deps โ€” Metal on Apple Silicon, CUDA on NVIDIA CMAKE_ARGS="-DGGML_METAL=on" pip install llama-cpp-python --no-binary llama-cpp-python pip install -r requirements.txt # 4. Download the story model (~800 MB, one-time) python download_model.py # 5. Launch python app.py # โ†’ http://localhost:7860 ``` > **HF Spaces GPU note:** Set the Space env var `CMAKE_ARGS="-DGGML_CUDA=on"` so > llama-cpp-python is compiled with CUDA on first boot. --- ## ๐Ÿ“ Repository Structure ``` app.py โ† Gradio UI + REST API endpoints engine.py โ† StoryEngine: loads MiniCPM5-1B via llama-cpp-python prompts.py โ† System-prompt builder (age / value / tradition) narrate.py โ† Kokoro-82M TTS (reads stdin โ†’ base64 WAV JSON on stdout) illustrate.py โ† SD Turbo image gen (reads JSON prompt โ†’ base64 PNG JSON) download_model.py โ† One-time model downloader from HF Hub requirements.txt โ† All Python dependencies (single environment) packages.txt โ† System packages for HF Spaces (espeak-ng, ffmpeg) ``` --- *Built with โค๏ธ for the [HuggingFace Build Small Hackathon 2026](https://huggingface.co/build-small-hackathon)*