Intelligent Video Generation Platform: Draft 1
Building an AI-Powered CBSE Educational Video Generator
Combining the intelligence of the Gemini 2.5 Flash model with the beautiful visuals of Manim and FastAPI to create dynamic micro-lessons in under 3 minutes.
The Vision: Educational Videos in Seconds
Creating high-quality, engaging educational content for high school students is notoriously hard. Students are easily overwhelmed by abstract equations and dry textbook jargon. Standard slide decks are boring, and professional motion graphic animations require days of manual labor.
To address this challenge, we built a fully automated CBSE Class 12 Storyboard Generator & Video Compiler. The workflow is simple: enter a CBSE curriculum topic (like Capacitors, DNA Replication, or Matrix Multiplication), and the application handles the rest—generating a pedagogically sound script and rendering a beautifully styled math/scientific animation using Manim and MoviePy.
"By starting with a vivid application hook first, we capture student interest instantly. We then build the conceptual analogy, followed by the rigorous mathematics, strictly keeping cognitive load minimal and runtime under 3 minutes."
Pedagogy First: The Design Rules
Our AI is not just writing arbitrary scripts; it behaves like an elite educational psychologist specializing in high school curricula. The generator strictly enforces two core design philosophies:
1. Jeremy Howard's Principle
Always show the "whole picture first". The storyboard must start with a vivid, relatable, real-world application (the "hook") showing why a concept matters, BEFORE introducing formal definitions or calculations.
2. Micro-Learning & Analogies
Lessons must fit within a 3-minute cap (strictly < 180 seconds). The script uses a slow, clear reading pace (~130 words/min), replaces dry jargon with a central analogy, and splits the lesson into 3 to 5 clean scenes.
The Architecture: How It Works Under the Hood
The system is built as a modular python microservice. Here are the core components that make it possible:
-
Phase 1
Strict Pydantic Schema Definitions
We declare Pydantic structures for our scenes and storyboards. This lets us define exactly what parameters we need (titles, narration, durations, pedagogical focus) and validate them programmatically.
-
Phase 2
Structured Output with Gemini 2.5 Flash
Using the new
google-genaiSDK, we send a prompt coupled with our custom schema config. The Gemini model generates a structured JSON object that exactly fits our Pydantic classes—guaranteeing type safety and structural alignment. -
Phase 3
Programmatic Animation with Manim
We map the pedagogical focus of each scene to custom Manim classes (e.g., concentric radar waves for application_hooks, expanding containers/rectangles for analogy_concepts, and rotating coordinate planes for theory_math).
-
Phase 4
API Orchestration & File Pipelines
A FastAPI backend exposes endpoints to generate and trigger renders in background threads. An asynchronous folder watcher monitors completion and organizes files into logical directories (e.g.,
/media/cbse12/{Subject}/{Chapter}/).
A Peek at the Code
Here is how we set up the structured storyboard generator using the brand-new Google GenAI client:
from google import genai
from google.genai import types
from schemas import Storyboard
def generate_storyboard(topic: str, model_name: str = "gemini-2.5-flash") -> Storyboard:
client = genai.Client()
prompt = f"Create a structured storyboard for the CBSE Class 12 topic: '{topic}'"
response = client.models.generate_content(
model=model_name,
contents=prompt,
config=types.GenerateContentConfig(
system_instruction=SYSTEM_INSTRUCTION,
response_mime_type="application/json",
response_schema=Storyboard,
temperature=0.2
)
)
# Parse and validate the response into Pydantic models
storyboard = Storyboard.model_validate_json(response.text)
return storyboard
The Journey: How We Reached Here
Building this required overcoming several design and engineering milestones:
1. Aligning LLM Outputs with Rigorous Constraints: Initially, models generated scripts that were too long or started immediately with formulas. By creating runtime validation functions that raise ValueErrors when constraints are violated, we forced the system to strictly reject and regenerate outliers.
2. Bridging Code and Visual Renderers: Setting up Manim on a system can be tricky due to dynamic dependencies like FFmpeg and LaTeX. We resolved this programmatically in our renderer module by bundle-querying imageio-ffmpeg and dynamically inserting the retrieved paths into the system PATH on initialization, eliminating manual setup headaches.
3. Decoupling Rendering from Client Requests: Rendering videos with complex math curves and textures takes time. If done inside a standard request, it would timeout. We migrated this to an asynchronous background queue inside FastAPI, utilizing a custom sidecar metadata file system monitored by an active file watcher loop to structure output folders in real-time.
Explore the Codebase
The entire implementation is open-source. You can check out the repository, run the code locally, and adapt the schemas for your own curriculum needs:
Next Steps
This service marks a powerful leap towards zero-effort educational video generation. In future posts, we'll look at incorporating Text-To-Speech (TTS) audio streams to overlay custom audio narrations onto the video clips, building interactive quiz cards, and styling a React-based frontend dashboard for educators. Stay tuned!
Comments
Post a Comment