Generate professional, web-styled daily workout plans with on-demand images, motivation speech, and PDF/HTML export — built with Streamlit & OpenAI
Built with the tools and technologies:
Python | Streamlit | OpenAI | DALL·E-2 | Playwright (Chromium) | Requests | Pillow
Daily Workout Planner is an interactive Streamlit application that builds a single-day workout tailored to your goal, environment (Gym/Home), level, duration, and optional calorie target. The app renders a clean, website-style HTML fragment, lists real exercise names, lets you generate per-exercise images on demand (cached locally), and produces a personalized motivation speech as MP3. You can also export the full plan with embedded thumbnails as self-contained HTML or PDF (via Playwright/Chromium).
- Structured AI Plans: Uses OpenAI Chat Completions with JSON Schema for robust, predictable workout data.
- Website-Style Rendering: Local HTML fragment renderer for consistent, polished visuals.
- On-Demand Images: Generate one image per exercise with DALL·E-2; files are cached under
assets/images/. - Motivation Speech: Short, powerful speech generated (text via GPT-5-nano with fallback; TTS via
tts-1) and saved to MP3. - Export Ready: One-click HTML (self-contained) and PDF (Chromium print-to-PDF) exports.
- Audio History: “Last MP3” download plus a recent files panel.
- Zero Secret Leaks: API key read from Streamlit Secrets.
- Configure Goal, Environment, Level, Duration, and optional Calorie Target.
- Generate a structured Warm-up / Main / Cool-down plan with realistic sets, reps, rest, intensity, and notes.
- Per-exercise images: generate only when needed; cached images are reused automatically.
- Motivation speech: generates text (not displayed), appends to a local log, and plays MP3 inline.
- Export / Share: Download HTML with embedded thumbnails or PDF using Playwright (Chromium).
- Clean, modern UI with tabs (Plan / Images / Export / Audio) and subtle design polish.
Follow these steps to set up and run the project locally.
daily-workout-planner/
├─ app.py
├─ services/
│ └─ openai_ops.py # OpenAI calls: plan JSON, images (DALL·E-2), motivation+TTS
├─ utils/
│ ├─ exporters.py # Export: HTML compose + Playwright PDF
│ ├─ parse.py # Filename sanitization helpers
│ └─ ui.py # Safe HTML fragment rendering
├─ assets/
│ ├─ images/ # Cached exercise images (PNG)
│ ├─ audio/ # Generated MP3s
│ └─ text/ # motivation_log.txt
├─ .streamlit/
│ └─ secrets.toml # contains your OPENAI_API_KEY (not committed)
├─ requirements.txt
├─ LICENSE # MIT License
└─ README.md
- Python 3.9+ recommended
- OpenAI API key with access to:
- Text models (e.g.,
gpt-4o-mini,gpt-5-nano) - Images (
dall-e-2) - TTS (
tts-1)
- Text models (e.g.,
- For PDF export:
playwrightand a local Chromium:python -m playwright install chromium
-
Create and activate a virtual environment (optional but recommended).
python -m venv .venv # Windows: .venv\Scripts\activate # macOS/Linux: source .venv/bin/activate -
Install dependencies.
pip install -r requirements.txt # For PDF export (Chromium print-to-PDF): python -m playwright install chromium
-
Create
.streamlit/secrets.toml(the folder/file may not exist by default).OPENAI_API_KEY = "sk-...your-key..." -
Confirm
app.pyreads fromst.secrets["OPENAI_API_KEY"](already wired). -
(Optional) Corporate networks/AV: ensure Playwright can launch Chromium.
-
Run the Streamlit app.
streamlit run app.py -
In the sidebar, set your plan parameters (Goal, Environment, Level, Duration, optional Calorie Target). Enter Your Name and choose TTS Voice.
-
Click “⚡ Generate Workout Plan”.
-
Plan Tab: Review the formatted workout with block cards (Warm-up / Main / Cool-down).
-
Images Tab:
- See a Cached Gallery at the top (if any images exist).
- For each exercise, click Generate image to create a DALL·E-2 image; it’s saved under
assets/images/and instantly reused next time.
-
Export Tab:
- Download HTML: self-contained page with embedded thumbnails.
- Download PDF: Chromium print-to-PDF via Playwright.
-
Audio Tab:
- Click “🎧 Generate Motivation” to create a personalized speech (text appended to
assets/text/motivation_log.txt) and play the MP3. - Download last MP3 and browse recent audio files.
- Click “🎧 Generate Motivation” to create a personalized speech (text appended to
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or feedback, connect with me on LinkedIn