Spaces:
Paused
Paused
Commit Β·
f495ad5
0
Parent(s):
Update PRD: QWEN-TTS-0.6B, Gradio/HF Spaces, gr.Server, Stitch UI
Browse files- Replace ElevenLabs with local QWEN-TTS-0.6B for voice cloning and TTS
- Replace React Native + GCP with Gradio app on Hugging Face Spaces
- Add gr.Server for frontend customization
- Add Google Stitch-inspired UI design patterns
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- mission.md +74 -0
- tech_stack.md +166 -0
mission.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Mission
|
| 2 |
+
|
| 3 |
+
## Product Vision
|
| 4 |
+
|
| 5 |
+
**ReadBookMom** is a voice-first interactive audiobook app for children ages 0β7. The app reads books aloud, lets children ask questions mid-story and hear answers grounded in the book, and lets parents record their voice so their child hears *them* reading β even when they aren't there.
|
| 6 |
+
|
| 7 |
+
## Problem
|
| 8 |
+
|
| 9 |
+
Young children learn by asking "why?" and "what happens next?" β but passive audiobooks can't answer back. Parents want to be the voice their child hears, but can't always be present. Existing children's audiobook apps offer neither real-time Q&A nor voice personalization.
|
| 10 |
+
|
| 11 |
+
## Core Product Loop
|
| 12 |
+
|
| 13 |
+
```
|
| 14 |
+
Listen β Interrupt with a question β Hear an answer β Resume
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
The app also proactively asks comprehension questions at chapter breaks to encourage active engagement.
|
| 18 |
+
|
| 19 |
+
## Target Users
|
| 20 |
+
|
| 21 |
+
| Role | Age | Relationship to App |
|
| 22 |
+
|---|---|---|
|
| 23 |
+
| Child listener | 0β7 | Primary interactor (voice, large buttons) |
|
| 24 |
+
| Parent / guardian | Adult | Account owner, voice donor, progress viewer |
|
| 25 |
+
| Educator / caregiver | Adult | Secondary β monitors engagement |
|
| 26 |
+
|
| 27 |
+
## Key Outcomes (12-week MVP)
|
| 28 |
+
|
| 29 |
+
- β₯ 25 curated titles for ages 0β7
|
| 30 |
+
- Avg. session length β₯ 12 minutes with β₯ 2 voice interactions per session
|
| 31 |
+
- Q&A helpfulness β₯ 80% (parent survey)
|
| 32 |
+
- Comprehension quiz participation β₯ 50% of sessions
|
| 33 |
+
|
| 34 |
+
## Success Metrics
|
| 35 |
+
|
| 36 |
+
| Metric | Target |
|
| 37 |
+
|---|---|
|
| 38 |
+
| End-to-end voice latency (PTT release β first TTS audio) | β€ 3.0s median, β€ 5.0s p95 (local model) |
|
| 39 |
+
| ASR round-trip | < 540ms target |
|
| 40 |
+
| App load (Gradio Space) | β€ 5s |
|
| 41 |
+
| Audio playback start | β€ 2.0s |
|
| 42 |
+
| Crash-free sessions | β₯ 99.5% |
|
| 43 |
+
| Uptime | β₯ 99.5% (Hugging Face Spaces) |
|
| 44 |
+
| Concurrent users (MVP) | 50 (scale to 500, constrained by GPU) |
|
| 45 |
+
|
| 46 |
+
## MVP Scope
|
| 47 |
+
|
| 48 |
+
**In scope:**
|
| 49 |
+
- Browse and play curated English audiobooks (Home, My Library, Categories screens)
|
| 50 |
+
- Voice Q&A: child asks, app answers from book content only
|
| 51 |
+
- Comprehension prompts at chapter breaks (1β3 per 10 min)
|
| 52 |
+
- Parent account + child profile (no personally identifying child data)
|
| 53 |
+
- Progress tracking, favorites, basic offline caching (chapter-level)
|
| 54 |
+
- Parent voice cloning via QWEN-TTS-0.6B (local model, no external API dependency)
|
| 55 |
+
|
| 56 |
+
**Out of scope for MVP:**
|
| 57 |
+
- Open-domain conversation (all answers must cite book content)
|
| 58 |
+
- Social features, user-generated content
|
| 59 |
+
- Multi-language catalog beyond English
|
| 60 |
+
- In-app content purchases
|
| 61 |
+
|
| 62 |
+
## Guardrails
|
| 63 |
+
|
| 64 |
+
| Constraint | Requirement |
|
| 65 |
+
|---|---|
|
| 66 |
+
| Content grounding | 80%+ of Q&A answers must cite or paraphrase in-book passages; out-of-scope queries declined gracefully |
|
| 67 |
+
| Privacy | COPPA-compliant: verifiable parental consent, no behavioral ads, data minimization, parental deletion dashboard |
|
| 68 |
+
| Voice cloning | Biometric data encrypted at rest; local inference only (QWEN-TTS-0.6B); purpose-limited to in-app narration; not used to train general models; deletable on request |
|
| 69 |
+
| Child safety | Content filter and prompt guardrails active; no sensitive topics; answers in Pre-A1 language level |
|
| 70 |
+
| Security | TLS 1.2+, bcrypt/Argon2 passwords, parameterized queries, JWT with rotation, KMS-managed secrets |
|
| 71 |
+
|
| 72 |
+
## Differentiator
|
| 73 |
+
|
| 74 |
+
Real-time, child-safe, two-way voice Q&A tied to each specific book β plus parent voice cloning β in a single app designed for ages 0β7.
|
tech_stack.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Tech Stack
|
| 2 |
+
|
| 3 |
+
## Architecture Overview
|
| 4 |
+
|
| 5 |
+
A Gradio web application deployed as a Hugging Face Space, with local QWEN-TTS-0.6B for voice cloning and TTS. UI design informed by Google Stitch for polished interface patterns.
|
| 6 |
+
|
| 7 |
+
```
|
| 8 |
+
Gradio App (gr.Server β customized UI)
|
| 9 |
+
β Hugging Face Space
|
| 10 |
+
β
|
| 11 |
+
βββ Content Backend (Python)
|
| 12 |
+
β β
|
| 13 |
+
β βββ PostgreSQL (book metadata, users)
|
| 14 |
+
β βββ Pinecone (RAG embeddings)
|
| 15 |
+
β
|
| 16 |
+
βββ Voice Service (local)
|
| 17 |
+
β
|
| 18 |
+
βββ QWEN-TTS-0.6B (TTS + voice cloning)
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
## 1. Front-End (Gradio + gr.Server)
|
| 24 |
+
|
| 25 |
+
| Layer | Choice | Details |
|
| 26 |
+
|---|---|---|
|
| 27 |
+
| Framework | Gradio 5.x | Hugging Face-native, Python-first UI |
|
| 28 |
+
| Customization | `gr.Server` | Custom routes, middleware, and frontend overrides |
|
| 29 |
+
| Hosting | Hugging Face Spaces (GPU) | Free tier or upgraded Space for GPU inference |
|
| 30 |
+
| UI Design | Google Stitch-inspired | Modern card layouts, smooth transitions, child-friendly large-button interface |
|
| 31 |
+
| Local dev | `gradio app.py` | Hot-reload; same app runs locally and on HF Spaces |
|
| 32 |
+
|
| 33 |
+
**Key UI components:**
|
| 34 |
+
- Audio player with playback controls (book narration)
|
| 35 |
+
- Voice recording interface (parent voice samples)
|
| 36 |
+
- Large-button child interaction panel
|
| 37 |
+
- Book library grid (card-based, Stitch-style)
|
| 38 |
+
- Q&A chat interface with voice input/output
|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
## 2. Voice Cloning & TTS Service (Local)
|
| 43 |
+
|
| 44 |
+
| Layer | Choice | Details |
|
| 45 |
+
|---|---|---|
|
| 46 |
+
| Model | QWEN-TTS-0.6B | Local 0.6B parameter TTS model with voice cloning capability |
|
| 47 |
+
| Inference | Transformers / local GPU | Runs on HF Space GPU or local CUDA device |
|
| 48 |
+
| Voice cloning | QWEN-TTS-0.6B zero-shot | Few-second reference audio β cloned voice |
|
| 49 |
+
| TTS | QWEN-TTS-0.6B | Text-to-speech for narration and Q&A answers |
|
| 50 |
+
| ASR | Whisper (local) or browser Web Speech API | Speech-to-text for child voice input |
|
| 51 |
+
| Audio format | WAV/MP3 | Generated on-the-fly or pre-cached |
|
| 52 |
+
|
| 53 |
+
**Voice cloning constraints:**
|
| 54 |
+
- Min reference audio: 5s, recommended: 15β30s
|
| 55 |
+
- Local inference only β no audio data sent to external APIs
|
| 56 |
+
- `child_safe_mode = True`, `content_filter_enabled = True`
|
| 57 |
+
|
| 58 |
+
---
|
| 59 |
+
|
| 60 |
+
## 3. Content Backend (Python)
|
| 61 |
+
|
| 62 |
+
| Layer | Choice | Details |
|
| 63 |
+
|---|---|---|
|
| 64 |
+
| Framework | Gradio app (integrated) | Backend logic co-located with Gradio app |
|
| 65 |
+
| Language | Python 3.12 | |
|
| 66 |
+
| LLM | OpenAI GPT-4 (`gpt-4`) | Q&A answer composition |
|
| 67 |
+
| Embeddings | OpenAI `text-embedding-3-large` | 3072-dim vectors |
|
| 68 |
+
| Vector DB | Pinecone | RAG retrieval over book passage chunks |
|
| 69 |
+
| RAG framework | LangChain | Chunking (`size=1000, overlap=200`), retrieval (`k=5`) |
|
| 70 |
+
| Auth | Hugging Face OAuth or simple login | Gradio built-in auth support |
|
| 71 |
+
| Logging | structlog (JSON) | |
|
| 72 |
+
|
| 73 |
+
---
|
| 74 |
+
|
| 75 |
+
## 4. Database (PostgreSQL 17)
|
| 76 |
+
|
| 77 |
+
Four tables:
|
| 78 |
+
|
| 79 |
+
| Table | PK | Foreign Keys | Purpose |
|
| 80 |
+
|---|---|---|---|
|
| 81 |
+
| `users` | `user_id` (UUID) | β | User profiles (HF OAuth or local) |
|
| 82 |
+
| `booktext` | `book_id` | β | Book metadata + full text |
|
| 83 |
+
| `voicesample` | `voice_id` | `user_id β users` | Parent voice recording (local file path or HF dataset) |
|
| 84 |
+
| `audiobook_cloned` | `audiobook_cloned_id` | `book_id`, `user_id`, `voice_id` | User-specific cloned audio; `processing_status`: pending β complete |
|
| 85 |
+
|
| 86 |
+
Naming convention: `snake_case`.
|
| 87 |
+
|
| 88 |
+
---
|
| 89 |
+
|
| 90 |
+
## 5. Infrastructure (Hugging Face Spaces)
|
| 91 |
+
|
| 92 |
+
| Component | Service | Config |
|
| 93 |
+
|---|---|---|
|
| 94 |
+
| App hosting | Hugging Face Spaces (Gradio) | `app.py` + `requirements.txt` |
|
| 95 |
+
| GPU inference | HF Space GPU (T4/A10G) | For QWEN-TTS-0.6B local inference |
|
| 96 |
+
| Model hosting | Hugging Face Hub | QWEN-TTS-0.6B weights auto-downloaded |
|
| 97 |
+
| File storage | HF Datasets / local persistent storage | Audio files, book files |
|
| 98 |
+
| Secrets | HF Space Secrets | API keys (OpenAI, Pinecone) |
|
| 99 |
+
| Database | External PostgreSQL (e.g., Supabase, Neon) | Lightweight managed DB |
|
| 100 |
+
|
| 101 |
+
---
|
| 102 |
+
|
| 103 |
+
## 6. CI/CD
|
| 104 |
+
|
| 105 |
+
| Pipeline | File | Trigger |
|
| 106 |
+
|---|---|---|
|
| 107 |
+
| App deploy | HF Spaces auto-deploy | Push to `main` branch (linked repo) |
|
| 108 |
+
| Tests | `.github/workflows/test.yaml` | Push to main |
|
| 109 |
+
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
## 7. Local Development
|
| 113 |
+
|
| 114 |
+
```bash
|
| 115 |
+
# Install dependencies
|
| 116 |
+
pip install -r requirements.txt
|
| 117 |
+
|
| 118 |
+
# Run locally (same app as HF Space)
|
| 119 |
+
python app.py
|
| 120 |
+
# or
|
| 121 |
+
gradio app.py
|
| 122 |
+
|
| 123 |
+
# Access at http://localhost:7860
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
---
|
| 127 |
+
|
| 128 |
+
## 8. Key External APIs
|
| 129 |
+
|
| 130 |
+
| API | Used For | Auth |
|
| 131 |
+
|---|---|---|
|
| 132 |
+
| OpenAI | GPT-4 (Q&A), `text-embedding-3-large` (RAG indexing) | `OPENAI_API_KEY` |
|
| 133 |
+
| Pinecone | Vector similarity search over book passages | `PINECONE_API_KEY` |
|
| 134 |
+
| Hugging Face Hub | Model weights (QWEN-TTS-0.6B), Spaces hosting | `HF_TOKEN` |
|
| 135 |
+
|
| 136 |
+
**Removed external dependencies (now local):**
|
| 137 |
+
- ~~ElevenLabs~~ β replaced by QWEN-TTS-0.6B (local)
|
| 138 |
+
- ~~LiveKit~~ β replaced by Gradio audio components
|
| 139 |
+
- ~~Google Cloud (GCS, Cloud Run, Cloud SQL)~~ β replaced by Hugging Face Spaces
|
| 140 |
+
|
| 141 |
+
---
|
| 142 |
+
|
| 143 |
+
## 9. UI Design (Google Stitch-Inspired)
|
| 144 |
+
|
| 145 |
+
| Pattern | Application |
|
| 146 |
+
|---|---|
|
| 147 |
+
| Card-based layouts | Book library grid, chapter selection |
|
| 148 |
+
| Smooth micro-animations | Page transitions, button feedback |
|
| 149 |
+
| Large touch targets | Child-friendly interaction (β₯ 48px tap areas) |
|
| 150 |
+
| Consistent color system | Warm, playful palette for ages 0β7 |
|
| 151 |
+
| Responsive design | Works on desktop (parents) and tablet (children) |
|
| 152 |
+
|
| 153 |
+
`gr.Server` enables custom CSS/JS injection and route handling for Stitch-style polish beyond default Gradio theming.
|
| 154 |
+
|
| 155 |
+
---
|
| 156 |
+
|
| 157 |
+
## 10. Tooling
|
| 158 |
+
|
| 159 |
+
| Tool | Purpose |
|
| 160 |
+
|---|---|
|
| 161 |
+
| `black` | Python code formatting |
|
| 162 |
+
| `isort` | Import sorting |
|
| 163 |
+
| `flake8` | Linting |
|
| 164 |
+
| `mypy` | Type checking |
|
| 165 |
+
| `pytest` + `pytest-asyncio` | Testing |
|
| 166 |
+
| `admintool/gutenberg_downloader.py` | Bulk download public-domain books from Project Gutenberg |
|