Step 2 — Segmentation
Status: ✅ Live (Chapter XII)
Unlocks when: Episode is draft
Advances to: segmented (on explicit approval)
Gemini 2.5-flash splits the chapter prose into scenes at narrative beats — location change, POV shift, tone shift, beat resolution. Never splits mid-sentence.
How It Works
- Tomas sets min/max scene count (defaults: min 8, max 12) on the Step 2 panel
- Clicks "Segment Episode" — background task starts, page polls every 3 seconds
- On completion: scene cards render below the stepper
- Tomas reviews scenes, edits mood briefs and effect types as needed
- Clicks "Approve Segmentation" — episode advances to
segmented, Step 3 unlocks
Re-segmenting a previously approved episode resets it back to draft before running.
Scene Cards
Each scene card shows: scene number, word count, estimated duration. Editable fields: - Mood Brief — free-text music/visual mood description (e.g. "low industrial drone, claustrophobic, tension building"). Used by MusicGen in Step 6. - Effect — one of 6 Ken Burns / pan / fade effects. Applied to the background image during merge (Step 7). Custom dropdown, not a native select. - Prose — expandable section showing the full scene text (click ▶ Prose to toggle).
Scene Count
Min/max inputs give control over granularity per chapter. Gemini treats these as hard constraints — if natural beats produce fewer scenes, it subdivides; if more, it merges. Defaults 8/12 work well for a ~2000-word chapter.
Service
studio/segmentation.py — segment_chapter(chapter_text, llm_client, min_scenes, max_scenes) — pure Python, zero Django imports. Raises SegmentationError on malformed response. JSON parsing handles Gemini 2.5-flash thinking output by trying all {...} blocks largest-first.
studio/service.py — run_segmentation(episode_id, min_scenes, max_scenes) — background thread, StudioTask polling. approve_segmentation(episode_id) — advances status.
New URLs (Sprint 57):
POST /studio/project/<slug>/episode/<n>/segment/ — trigger segmentation
POST /studio/project/<slug>/episode/<n>/approve-segmentation/ — approve and advance
GET /studio/task/<task_id>/ — poll task status
POST /studio/scene/<scene_id>/update/ — save mood_brief or effect_type