Skip to content

mateolafalce/topic2manim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

image

Topic2Manim

Automatic educational video generator using AI and Manim. Converts any topic into a professional animated video with narration and mathematical visualizations.

User Interface

video

Examples

propmt: How do machines learn to recognize MNIST dataset numbers?

model: claude-sonnet-4-5-20250929

response:

video

propmt: What is a Markov chain and how are they related to LLMs?

model: claude-sonnet-4-5-20250929

response:

video

propmt: How does Cramer's rule work for system of linear equations?

model: claude-sonnet-4-5-20250929

response:

video

propmt: how chat gpt works?

model: gpt-5.2

response:

video

propmt: how tokenization works in chat gpt?

model: gpt-5.2

response:

video

Features

  • Multi-LLM Support with automatic fallback (OpenAI GPT, Claude)
  • Automatic script generation using advanced language models
  • Educational animations with Manim Community Edition
  • Multi-language support (automatically detects topic language)
  • Optimized videos of ~60 seconds with multiple scenes
  • Automatic concatenation of fragments into final video

Architecture

System Overview

Topic2Manim is a multi-agent system that orchestrates several specialized components to transform a topic into an educational video. The system follows a pipeline architecture where each agent has a specific responsibility.

graph TB
    subgraph Input
        A[User Topic]
    end
    
    subgraph "LLM Configuration"
        B[setup_llm_client]
        B1[Claude API]
        B2[OpenAI API]
        B -->|Priority 1| B1
        B -->|Fallback| B2
    end
    
    subgraph "Agent 1: Script Generation"
        C[animations.py]
        C1[generate_script_json]
        C --> C1
    end
    
    subgraph "Agent 2: TTS Generation"
        D[tts_generator.py]
        D1[generate_complete_audio]
        D2[generate_audio_fragment]
        D3[concatenate_audio_fragments]
        D1 --> D2
        D2 --> D3
    end
    
    subgraph "Agent 3: Manim Code Generation"
        E[manim_generator.py]
        E1[generate_manim_code]
        E --> E1
    end
    
    subgraph "Agent 4: Video Compilation"
        F[concat_video.py]
        F1[compile_video]
        F2[concatenate_videos]
        F3[merge_video_and_audio]
        F1 --> F2
        F2 --> F3
    end
    
    subgraph Output
        G[Final Video with Audio]
    end
    
    A --> B
    B --> C1
    C1 -->|video-output.json| D1
    C1 -->|video-output.json| E1
    D1 -->|audio durations| E1
    E1 -->|.py files| F1
    F1 -->|.mp4 fragments| F2
    D3 -->|audio.mp3| F3
    F2 -->|output_silent.mp4| F3
    F3 --> G
    
    style A fill:#e1f5ff
    style G fill:#c8e6c9
    style C fill:#fff9c4
    style D fill:#ffe0b2
    style E fill:#f8bbd0
    style F fill:#d1c4e9
Loading

Installation

First, install uv (if you haven't already):

# On macOS and Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Or using pip
pip install uv

Setup

git clone https://github.com/mateolafalce/topic2manim.git
cd topic2manim

# Create virtual environment and install all dependencies
uv sync

# Activate the virtual environment
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

cp .env.example .env

Usage

Start the Flask server:

python src/main.py

Then open your browser and navigate to:

http://localhost:5000

or

docker compose up

About

Automatic educational video generator using AI and Manim. Converts any topic into a professional animated video with narration and mathematical visualizations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors