minhahwang commited on
Commit
53ace40
Β·
1 Parent(s): c5e89ef

Apply design critique fixes + add README

Browse files

mission.md:
- Make voice similarity testable (blind A/B test)
- Acknowledge 8s Q&A as compromise, add pre-generated Q&A target
- Add repeat-question and story-end behavior to demo loop
- Note demo time budget (3min allows ~2 Q&A rounds)

sprint.md:
- Fix underestimated tasks: #5 (30m->1h), #10 (1h->2h)
- Add pre-generated Q&A task (10a)
- Add latency measurement (20a) and state machine validation (20b)
- Add Day 1 overflow plan
- Add future_mobile doc to file structure

tech_stack.md:
- Add legal state transition rules
- Add VRAM budget table (~5-6GB of 16GB T4)
- Add concurrency model note
- Specify TF-IDF retrieval for Q&A
- Add audio format spec (24kHz, 16-bit, mono)

future_mobile_app_considerations.md:
- Add filler audio strategy for cache miss resume
- Clarify REST limitation for interrupt loop
- Add app size estimates (20MB thin to 4GB+ on-device)
- Add explicit offline fallback decision

README.md:
- New repo README with demo flow, models, tech stack, quick start

Files changed (5) hide show
  1. README.md +82 -0
  2. future_mobile_app_considerations.md +4 -3
  3. mission.md +10 -4
  4. sprint.md +9 -3
  5. tech_stack.md +26 -2
README.md ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ReadBookMom
2
+
3
+ **A parent records their voice. A bedtime story plays in that voice. The child can ask questions and hear answers β€” all in mom or dad's voice.**
4
+
5
+ Built for the Hugging Face Hackathon. Runs entirely on local models inside a Gradio app on Hugging Face Spaces β€” no external APIs, no data leaves the server.
6
+
7
+ ## Demo
8
+
9
+ ```
10
+ 🎀 Record 15s of your voice β†’ πŸ“– Pick a story β†’ ▢️ Story plays in your voice
11
+ ↓
12
+ ❓ Child taps Ask β†’ Story pauses
13
+ ↓
14
+ Child asks a question β†’ Hears answer in your voice
15
+ ↓
16
+ ▢️ Story resumes
17
+ ```
18
+
19
+ ## How It Works
20
+
21
+ | Step | What Happens | Model |
22
+ |---|---|---|
23
+ | **Clone** | Parent records or uploads 15–30s of audio. Voice representation is computed and cached. | QWEN-TTS-0.6B |
24
+ | **Listen** | Story plays in the cloned voice as interruptible paragraph chunks. | QWEN-TTS-0.6B |
25
+ | **Ask** | Child taps Ask, narration pauses, child types or speaks a question. | Whisper-small (ASR, on-demand) |
26
+ | **Answer** | A short grounded answer is generated from the story context and spoken in the cloned voice. | Qwen2.5-3B-Instruct + QWEN-TTS-0.6B |
27
+ | **Resume** | Story continues from where it left off. | Cached chunks |
28
+
29
+ ## Models
30
+
31
+ | Model | Role | Size |
32
+ |---|---|---|
33
+ | [QWEN-TTS-0.6B](https://huggingface.co/Qwen/Qwen-TTS-0.6B) | Voice cloning + TTS | 0.6B params |
34
+ | [Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct) | Story Q&A | 3B params (4-bit on T4) |
35
+ | [Whisper-small](https://huggingface.co/openai/whisper-small) | Child speech-to-text | 244M params (loaded on demand) |
36
+
37
+ ## Tech Stack
38
+
39
+ - **UI:** Gradio 5.x + gr.Server (custom CSS/JS for Google Stitch-inspired design)
40
+ - **Runtime:** Single `app.py` process on HF Spaces (T4 or A10G GPU)
41
+ - **Stories:** 3–5 public domain `.txt` files
42
+ - **Storage:** In-memory session cache (no database)
43
+
44
+ ## Quick Start (Local Dev)
45
+
46
+ ```bash
47
+ git clone https://github.com/MomsVoiceAI/HuggingFace_Hack.git
48
+ cd HuggingFace_Hack
49
+ pip install gradio transformers torch accelerate bitsandbytes soundfile numpy
50
+ python app.py
51
+ # β†’ http://localhost:7860
52
+ ```
53
+
54
+ ## Project Structure
55
+
56
+ ```
57
+ β”œβ”€β”€ app.py # Main Gradio app
58
+ β”œβ”€β”€ requirements.txt # Python deps
59
+ β”œβ”€β”€ stories/ # Public domain story texts
60
+ β”œβ”€β”€ static/ # Custom CSS/JS for Stitch-style UI
61
+ β”œβ”€β”€ assets/covers/ # Story cover images
62
+ β”œβ”€β”€ mission.md # Product vision
63
+ β”œβ”€β”€ sprint.md # 2-day hackathon sprint plan
64
+ β”œβ”€β”€ tech_stack.md # Technical architecture
65
+ └── future_mobile_app_considerations.md # Mobile deployment guidance
66
+ ```
67
+
68
+ ## Key Design Decisions
69
+
70
+ - **All local inference** β€” voice, Q&A, and ASR run on the Space GPU. No external APIs.
71
+ - **Interruptible chunked streaming** β€” paragraphs synthesized and played one at a time for fast start and clean pause/resume.
72
+ - **Pre-generated Q&A** β€” anticipated questions are generated in the background during narration for sub-1s response on cache hits.
73
+ - **Button-based interruption** β€” tap Ask to pause. No always-listening mic (privacy + complexity).
74
+ - **Privacy-first** β€” no audio leaves the server, no user accounts, no database.
75
+
76
+ ## Privacy
77
+
78
+ All inference runs on the Hugging Face Space GPU. Voice samples, story text, and generated audio stay on the server runtime and are not persisted after the session ends. No external APIs are called.
79
+
80
+ ## License
81
+
82
+ Hackathon project. Stories are public domain.
future_mobile_app_considerations.md CHANGED
@@ -42,7 +42,7 @@ Button-based interruption is the recommended first version. True voice barge-in,
42
  |---|---|---|
43
  | Mobile app | Recording, playback, Ask interruption, local state, local cache | Native iOS/Android app or React Native/Flutter with native audio modules. |
44
  | Backend API | Voice profile session, story chunk generation, Q&A answer generation, answer TTS | GPU backend using the same model stack as the Space demo. |
45
- | Streaming/control channel | Request chunks, pause/resume, cancel queued work, receive generation status | WebSocket for bidirectional control; REST plus polling is acceptable for a prototype. |
46
  | Audio delivery | Stream or download generated chunks | Prefer short chunk files with signed URLs and local prefetch cache. |
47
  | Session state | Track story and interruption position | Store `story_id`, `voice_session_id`, `current_chunk_index`, playback state, and cache keys. |
48
 
@@ -101,7 +101,7 @@ The phone runs ASR, Q&A, voice cloning TTS, chunk generation, and playback local
101
  | Q&A text answer | 1-3 seconds | Use short prompts, 1-2 sentence answers, and backend Qwen2.5-3B-Instruct. |
102
  | Spoken Q&A answer | Starts in 4-8 seconds after question submit | Keep answer text short and generate TTS server-side. |
103
  | Story resume | Under 1 second when next chunk is cached | Resume from saved chunk position; fetch missing chunks in the background. |
104
- | Cache miss resume | 2-5 seconds | Show a lightweight loading state while the next chunk is generated or downloaded. |
105
 
106
  Mobile latency depends heavily on network quality. The app should show resilient playback states instead of assuming the backend will always meet desktop demo timing.
107
 
@@ -115,6 +115,7 @@ Mobile latency depends heavily on network quality. The app should show resilient
115
  | Echo cancellation | Open-mic interruption can capture the story audio instead of the child. | Use tap-to-Ask first; research VAD and echo cancellation later. |
116
  | App lifecycle | Incoming calls, lock screen, and backgrounding can interrupt playback. | Treat v1 as foreground-first; persist playback state and chunk cache. |
117
  | Storage | Cached voice/story audio can grow quickly. | Cache by voice session, story ID, chunk index, and model version with TTL cleanup. |
 
118
  | Privacy | Family voice data and child questions are sensitive. | Make upload, retention, deletion, and cache behavior explicit. |
119
 
120
  ## Product Implications
@@ -122,7 +123,7 @@ Mobile latency depends heavily on network quality. The app should show resilient
122
  - The first mobile app should be a hybrid app, not a full local AI runtime.
123
  - The phone should own playback state and interruption responsiveness.
124
  - Privacy messaging must be explicit: explain what audio is sent to the backend, how long it is retained, and whether generated voice samples are cached.
125
- - If offline mode becomes a requirement, treat it as a separate research milestone, not a launch feature.
126
  - Device qualification matters. Fully on-device AI should start with a short list of supported flagship phones.
127
  - Chunk prefetching and caching are key to making bedtime story playback and resume feel instant.
128
  - Always-listening barge-in should not be promised until echo cancellation, VAD, and mobile privacy UX are proven.
 
42
  |---|---|---|
43
  | Mobile app | Recording, playback, Ask interruption, local state, local cache | Native iOS/Android app or React Native/Flutter with native audio modules. |
44
  | Backend API | Voice profile session, story chunk generation, Q&A answer generation, answer TTS | GPU backend using the same model stack as the Space demo. |
45
+ | Streaming/control channel | Request chunks, pause/resume, cancel queued work, receive generation status | WebSocket for bidirectional control; REST plus polling is acceptable for narration-only prototyping but will not support the full interrupt/answer/resume loop reliably. |
46
  | Audio delivery | Stream or download generated chunks | Prefer short chunk files with signed URLs and local prefetch cache. |
47
  | Session state | Track story and interruption position | Store `story_id`, `voice_session_id`, `current_chunk_index`, playback state, and cache keys. |
48
 
 
101
  | Q&A text answer | 1-3 seconds | Use short prompts, 1-2 sentence answers, and backend Qwen2.5-3B-Instruct. |
102
  | Spoken Q&A answer | Starts in 4-8 seconds after question submit | Keep answer text short and generate TTS server-side. |
103
  | Story resume | Under 1 second when next chunk is cached | Resume from saved chunk position; fetch missing chunks in the background. |
104
+ | Cache miss resume | 2-5 seconds | Show a lightweight loading state while the next chunk is generated or downloaded. Play a short filler clip (β€œHmm, let me find my place…”) pre-synthesized in the cloned voice during voice setup, so the child hears the parent’s voice instead of silence. |
105
 
106
  Mobile latency depends heavily on network quality. The app should show resilient playback states instead of assuming the backend will always meet desktop demo timing.
107
 
 
115
  | Echo cancellation | Open-mic interruption can capture the story audio instead of the child. | Use tap-to-Ask first; research VAD and echo cancellation later. |
116
  | App lifecycle | Incoming calls, lock screen, and backgrounding can interrupt playback. | Treat v1 as foreground-first; persist playback state and chunk cache. |
117
  | Storage | Cached voice/story audio can grow quickly. | Cache by voice session, story ID, chunk index, and model version with TTL cleanup. |
118
+ | App size | A thin cloud-backed client is ~20 MB. A hybrid app with on-device ASR (Whisper-tiny) may reach 100–200 MB. A fully on-device build with all models could exceed 4 GB. | Start thin; gate on-device model downloads behind user opt-in. |
119
  | Privacy | Family voice data and child questions are sensitive. | Make upload, retention, deletion, and cache behavior explicit. |
120
 
121
  ## Product Implications
 
123
  - The first mobile app should be a hybrid app, not a full local AI runtime.
124
  - The phone should own playback state and interruption responsiveness.
125
  - Privacy messaging must be explicit: explain what audio is sent to the backend, how long it is retained, and whether generated voice samples are cached.
126
+ - If offline mode becomes a requirement, treat it as a separate research milestone, not a launch feature. As a conscious tradeoff, v1 has no offline fallback β€” even a cached-story-only offline mode would add significant complexity.
127
  - Device qualification matters. Fully on-device AI should start with a short list of supported flagship phones.
128
  - Chunk prefetching and caching are key to making bedtime story playback and resume feel instant.
129
  - Always-listening barge-in should not be promised until echo cancellation, VAD, and mobile privacy UX are proven.
mission.md CHANGED
@@ -17,10 +17,14 @@ Parent records 15s of voice β†’ Pick a story β†’ Story starts in parent's voice
17
  ↓
18
  Child asks a question β†’ Hears answer in parent's voice
19
  ↓
20
- Resume story from the same position
 
 
21
  ```
22
 
23
- Latency and natural interruption are part of the demo promise: the story should start quickly, pause cleanly when the child wants to ask something, answer in the cloned voice, then resume without losing the story position.
 
 
24
 
25
  ## Hackathon Goal (2 days)
26
 
@@ -37,11 +41,12 @@ A parent at a laptop who records their voice, picks a short story, and shows the
37
 
38
  | Criteria | Target |
39
  |---|---|
40
- | Voice clone from ≀ 30s audio | Recognizable similarity |
41
  | Story start latency | First streamed audio chunk in ≀ 5s |
42
  | Narration interruption | Ask tap pauses playback in ≀ 500ms and preserves story position |
43
  | Cached story replay | Starts immediately after first generation |
44
- | Q&A answer (spoken) | Spoken answer starts in ≀ 8s from question submit |
 
45
  | Story resume latency | Resume from paused position in ≀ 1s when next chunk is cached |
46
  | Works on HF Spaces | Public link, no local setup needed |
47
  | Demo length | 3-minute live walkthrough |
@@ -83,6 +88,7 @@ A parent at a laptop who records their voice, picks a short story, and shows the
83
  | Story replay | Cache full generated narration by voice session and story ID. |
84
  | Q&A context | Send the current story position plus the most relevant story passages to Qwen2.5-3B-Instruct instead of the full story when possible. |
85
  | Q&A length | Cap answers to 1–2 short child-friendly sentences before sending to TTS. |
 
86
  | Story resume | Resume from the paused chunk after the spoken answer; use cached next chunks when available. |
87
  | Voice question input | Load ASR only when audio questions are used; text questions bypass ASR. |
88
 
 
17
  ↓
18
  Child asks a question β†’ Hears answer in parent's voice
19
  ↓
20
+ Resume story from the same position (or ask another question)
21
+ ↓
22
+ Story finishes β†’ Show "Pick another story" prompt
23
  ```
24
 
25
+ Latency and natural interruption are part of the demo promise: the story should start quickly, pause cleanly when the child wants to ask something, answer in the cloned voice, then resume without losing the story position. The child may ask multiple questions in a row before resuming. When the last chunk finishes playing, the app returns to the story selection screen.
26
+
27
+ **Demo time budget:** A 3-minute live walkthrough allows ~2 Q&A rounds (each round β‰ˆ 15s of dead air: pause + ask + wait + answer + resume). Plan the demo script around 1–2 questions placed at natural story moments.
28
 
29
  ## Hackathon Goal (2 days)
30
 
 
41
 
42
  | Criteria | Target |
43
  |---|---|
44
+ | Voice clone from ≀ 30s audio | 2 of 3 listeners identify the voice in a blind A/B test |
45
  | Story start latency | First streamed audio chunk in ≀ 5s |
46
  | Narration interruption | Ask tap pauses playback in ≀ 500ms and preserves story position |
47
  | Cached story replay | Starts immediately after first generation |
48
+ | Q&A answer (spoken, live) | Spoken answer starts in ≀ 8s from question submit (known compromise β€” a young child may lose attention) |
49
+ | Q&A answer (spoken, pre-generated) | Sub-1s for anticipated questions matched from background Q&A cache |
50
  | Story resume latency | Resume from paused position in ≀ 1s when next chunk is cached |
51
  | Works on HF Spaces | Public link, no local setup needed |
52
  | Demo length | 3-minute live walkthrough |
 
88
  | Story replay | Cache full generated narration by voice session and story ID. |
89
  | Q&A context | Send the current story position plus the most relevant story passages to Qwen2.5-3B-Instruct instead of the full story when possible. |
90
  | Q&A length | Cap answers to 1–2 short child-friendly sentences before sending to TTS. |
91
+ | Pre-generated Q&A | While each chunk plays, generate 2–3 anticipated Q&A pairs with audio in the background. Match incoming questions against the cache for sub-1s responses; fall back to live generation on miss. |
92
  | Story resume | Resume from the paused chunk after the spoken answer; use cached next chunks when available. |
93
  | Voice question input | Load ASR only when audio questions are used; text questions bypass ASR. |
94
 
sprint.md CHANGED
@@ -15,7 +15,7 @@ Ship a public Hugging Face Space: parent clones voice β†’ story streams in that
15
  | 2 | Load QWEN-TTS-0.6B locally, test basic TTS (text β†’ audio) | 1h | ☐ |
16
  | 3 | Implement voice cloning and cache voice representation after recording | 1.5h | ☐ |
17
  | 4 | Add 3 short stories as `.txt` files (public domain) | 30m | ☐ |
18
- | 5 | Wire up: pick story β†’ stream first narration chunk, track chunk index, cache story audio | 30m | ☐ |
19
 
20
  **Checkpoint:** Can generate a story audio file in a cloned voice from CLI.
21
 
@@ -27,10 +27,13 @@ Ship a public Hugging Face Space: parent clones voice β†’ story streams in that
27
  | 7 | Tab 1 (Clone): `gr.Audio` record/upload + preview button | 45m | ☐ |
28
  | 8 | Tab 2 (Listen): story dropdown + play/pause/resume controls for streamed chunks | 45m | ☐ |
29
  | 9 | Add on-demand ASR for child voice input; use lighter ASR fallback if needed | 30m | ☐ |
30
- | 10 | Tab 3 (Ask): interrupt narration β†’ short grounded Qwen answer β†’ TTS β†’ resume story | 1h | ☐ |
 
31
 
32
  **Checkpoint:** Full loop works locally β€” clone β†’ listen β†’ interrupt β†’ ask β†’ resume. Ugly but functional.
33
 
 
 
34
  ---
35
 
36
  ## Day 2: Polish + Deploy (Make It Demo-Ready)
@@ -56,6 +59,8 @@ Ship a public Hugging Face Space: parent clones voice β†’ story streams in that
56
  | 18 | Confirm no external LLM API secrets are required; set `HF_TOKEN` only if gated models require it | 5m | ☐ |
57
  | 19 | End-to-end test on live Space (clone β†’ listen β†’ interrupt β†’ ask β†’ resume) | 30m | ☐ |
58
  | 20 | Fix latency issues: preload weights, cache voice/story audio, cap Q&A tokens, validate pause/resume | 45m | ☐ |
 
 
59
  | 21 | Add error handling: graceful failures, loading messages | 30m | ☐ |
60
  | 22 | Record backup demo video (in case live demo fails) | 30m | ☐ |
61
  | 23 | Write README.md for the Space (screenshot, description) | 15m | ☐ |
@@ -99,7 +104,8 @@ VoiceClone/
99
  β”‚ └── covers/ # Story cover images
100
  β”œβ”€β”€ mission.md # Product vision (this hackathon)
101
  β”œβ”€β”€ tech_stack.md # Technical decisions
102
- └── sprint.md # This file
 
103
  ```
104
 
105
  ---
 
15
  | 2 | Load QWEN-TTS-0.6B locally, test basic TTS (text β†’ audio) | 1h | ☐ |
16
  | 3 | Implement voice cloning and cache voice representation after recording | 1.5h | ☐ |
17
  | 4 | Add 3 short stories as `.txt` files (public domain) | 30m | ☐ |
18
+ | 5 | Wire up: pick story β†’ stream first narration chunk, track chunk index, cache story audio | 1h | ☐ |
19
 
20
  **Checkpoint:** Can generate a story audio file in a cloned voice from CLI.
21
 
 
27
  | 7 | Tab 1 (Clone): `gr.Audio` record/upload + preview button | 45m | ☐ |
28
  | 8 | Tab 2 (Listen): story dropdown + play/pause/resume controls for streamed chunks | 45m | ☐ |
29
  | 9 | Add on-demand ASR for child voice input; use lighter ASR fallback if needed | 30m | ☐ |
30
+ | 10 | Tab 3 (Ask): interrupt narration β†’ short grounded Qwen answer β†’ TTS β†’ resume story | 2h | ☐ |
31
+ | 10a | Pre-generate 2–3 anticipated Q&A pairs per chunk during narration playback (background task) | 30m | ☐ |
32
 
33
  **Checkpoint:** Full loop works locally β€” clone β†’ listen β†’ interrupt β†’ ask β†’ resume. Ugly but functional.
34
 
35
+ **Day 1 Overflow Plan:** If the afternoon runs past 8h, cut Task 9 (on-demand ASR) and rely on text-only questions. CSS polish (Tasks 12–14) is the next cut candidate on Day 2.
36
+
37
  ---
38
 
39
  ## Day 2: Polish + Deploy (Make It Demo-Ready)
 
59
  | 18 | Confirm no external LLM API secrets are required; set `HF_TOKEN` only if gated models require it | 5m | ☐ |
60
  | 19 | End-to-end test on live Space (clone β†’ listen β†’ interrupt β†’ ask β†’ resume) | 30m | ☐ |
61
  | 20 | Fix latency issues: preload weights, cache voice/story audio, cap Q&A tokens, validate pause/resume | 45m | ☐ |
62
+ | 20a | Measure and log all latency targets from mission.md (first chunk, pause, Q&A, resume, replay) | 30m | ☐ |
63
+ | 20b | Validate playback state machine: test all 6 states and legal transitions from tech_stack.md | 30m | ☐ |
64
  | 21 | Add error handling: graceful failures, loading messages | 30m | ☐ |
65
  | 22 | Record backup demo video (in case live demo fails) | 30m | ☐ |
66
  | 23 | Write README.md for the Space (screenshot, description) | 15m | ☐ |
 
104
  β”‚ └── covers/ # Story cover images
105
  β”œβ”€β”€ mission.md # Product vision (this hackathon)
106
  β”œβ”€β”€ tech_stack.md # Technical decisions
107
+ β”œβ”€β”€ sprint.md # This file
108
+ └── future_mobile_app_considerations.md # Mobile deployment guidance
109
  ```
110
 
111
  ---
tech_stack.md CHANGED
@@ -20,6 +20,18 @@ Single Python file Gradio app. Everything runs in one process on a GPU-enabled H
20
 
21
  No database. No external storage. No external LLM API. Stories are flat files. Audio is generated as interruptible chunks, then cached in the session for replay and resume.
22
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ---
24
 
25
  ## 1. Front-End
@@ -49,7 +61,7 @@ No database. No external storage. No external LLM API. Stories are flat files. A
49
  | Size | 0.6B params β€” fits comfortably on T4 (16GB VRAM) |
50
  | Capability | Zero-shot voice cloning + TTS from text chunks |
51
  | Input | Reference audio (β‰₯5s) + target text |
52
- | Output | WAV audio in cloned voice |
53
  | Latency | ~3–5s for a paragraph on T4 |
54
  | Optimization | Cache the voice representation after recording; generate story audio in interruptible paragraph chunks |
55
 
@@ -73,7 +85,7 @@ No database. No external storage. No external LLM API. Stories are flat files. A
73
  | Model | `Qwen/Qwen2.5-3B-Instruct` |
74
  | Why | Strong small-model instruction following with lower latency and VRAM pressure than an 8B-class model |
75
  | Method | Current story position + relevant story passages + strict answer-from-story instruction + child question β†’ short answer |
76
- | Retrieval | Simple paragraph keyword overlap is enough for the demo; full-story prompt remains a fallback |
77
  | Output cap | 1–2 child-friendly sentences, typically 40–80 new tokens |
78
  | Runtime note | Use 4-bit/8-bit loading on T4; use bf16 or 8-bit on A10G for more headroom |
79
 
@@ -130,6 +142,18 @@ Each file: title on line 1, text below. No metadata DB needed.
130
  | `resuming` | Answer finished and story playback is restarting. | Resume chunk index, cached next chunk |
131
  | `finished` | Story narration completed. | Cached full-story audio |
132
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  ---
134
 
135
  ## 9. Local Dev
 
20
 
21
  No database. No external storage. No external LLM API. Stories are flat files. Audio is generated as interruptible chunks, then cached in the session for replay and resume.
22
 
23
+ **VRAM Budget (T4 β€” 16 GB):**
24
+
25
+ | Component | Estimated VRAM | Notes |
26
+ |---|---|---|
27
+ | QWEN-TTS-0.6B | ~1.2 GB | Always loaded |
28
+ | Qwen2.5-3B-Instruct (4-bit) | ~2 GB | Always loaded |
29
+ | Whisper-small | ~1 GB | Loaded on demand |
30
+ | Gradio + PyTorch overhead | ~1–2 GB | Runtime |
31
+ | **Total** | **~5–6 GB** | ~10 GB headroom for KV cache and activations |
32
+
33
+ **Concurrency:** Single-process Gradio serializes concurrent users. The hackathon demo is single-user. For multi-user, consider Gradio queue or separate worker processes.
34
+
35
  ---
36
 
37
  ## 1. Front-End
 
61
  | Size | 0.6B params β€” fits comfortably on T4 (16GB VRAM) |
62
  | Capability | Zero-shot voice cloning + TTS from text chunks |
63
  | Input | Reference audio (β‰₯5s) + target text |
64
+ | Output | WAV audio in cloned voice (24 kHz, 16-bit, mono) |
65
  | Latency | ~3–5s for a paragraph on T4 |
66
  | Optimization | Cache the voice representation after recording; generate story audio in interruptible paragraph chunks |
67
 
 
85
  | Model | `Qwen/Qwen2.5-3B-Instruct` |
86
  | Why | Strong small-model instruction following with lower latency and VRAM pressure than an 8B-class model |
87
  | Method | Current story position + relevant story passages + strict answer-from-story instruction + child question β†’ short answer |
88
+ | Retrieval | TF-IDF cosine similarity between the child's question and each story paragraph; return the top-2 paragraphs as context. Full-story prompt is the fallback when retrieval scores are low. |
89
  | Output cap | 1–2 child-friendly sentences, typically 40–80 new tokens |
90
  | Runtime note | Use 4-bit/8-bit loading on T4; use bf16 or 8-bit on A10G for more headroom |
91
 
 
142
  | `resuming` | Answer finished and story playback is restarting. | Resume chunk index, cached next chunk |
143
  | `finished` | Story narration completed. | Cached full-story audio |
144
 
145
+ **Legal transitions:**
146
+
147
+ ```
148
+ playing β†’ paused β†’ playing
149
+ playing β†’ asking β†’ answering β†’ resuming β†’ playing
150
+ playing β†’ finished
151
+ paused β†’ asking β†’ answering β†’ resuming β†’ playing
152
+ asking β†’ asking (child asks a follow-up before answer starts)
153
+ ```
154
+
155
+ All other transitions are illegal. The UI should disable buttons that would trigger an illegal transition.
156
+
157
  ---
158
 
159
  ## 9. Local Dev