Spaces:
Running
Running
File size: 13,192 Bytes
fff13d1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
# NeuroAnim Gradio Interface - Quick Start Guide
Welcome to the NeuroAnim web interface! This guide will help you get started with generating educational STEM animations through an intuitive web UI.
---
## π Quick Start
### 1. Installation
First, ensure you have all dependencies installed:
```bash
cd /path/to/manim-agent
pip install -e .
```
This will install all required packages including Gradio.
### 2. Configure API Keys
Create or edit your `.env` file in the project root:
```bash
# Required
HUGGINGFACE_API_KEY=your_huggingface_api_key_here
# Optional but recommended for better audio quality
ELEVENLABS_API_KEY=your_elevenlabs_api_key_here
# Optional for secure sandboxed execution
BLAXEL_API_KEY=your_blaxel_api_key_here
```
**Get API Keys:**
- **Hugging Face**: Sign up at [huggingface.co](https://huggingface.co) β Settings β Access Tokens
- **ElevenLabs**: Sign up at [elevenlabs.io](https://elevenlabs.io) β Profile β API Key
- **Blaxel**: Sign up at [blaxel.ai](https://blaxel.ai) (optional)
### 3. Launch the Interface
```bash
python app.py
```
You should see output like:
```
β Running on local URL: http://127.0.0.1:7860
β Running on public URL: https://xxxxx.gradio.live (if sharing enabled)
```
### 4. Access the Web Interface
Open your browser and navigate to: **http://localhost:7860**
---
## π¬ Using the Interface
### Main Tab: Generate Animation
#### Step 1: Enter Your Topic
In the "Topic / Concept" field, enter a mathematical or scientific concept you want to explain.
**Good Examples:**
- "Pythagorean Theorem"
- "How photosynthesis works"
- "Newton's Second Law of Motion"
- "Solving quadratic equations"
- "Binary number system"
**Tips:**
- Be specific rather than vague
- Include the key concept name
- Avoid overly broad topics (e.g., "all of calculus")
#### Step 2: Choose Target Audience
Select the appropriate education level:
- **Elementary**: Ages 6-11 (simple language, basic concepts)
- **Middle School**: Ages 11-14 (moderate complexity)
- **High School**: Ages 14-18 (standard academic level)
- **Undergraduate**: College level (technical depth)
- **General**: Mixed audience (accessible but informative)
#### Step 3: Set Duration
Use the slider to choose animation length:
- **0.5-1.5 minutes**: Quick concept introduction
- **2-3 minutes**: Standard explanation (recommended)
- **3-5 minutes**: Detailed walkthrough
- **5-10 minutes**: Comprehensive lesson
**Note:** Longer animations take more time to generate and may be harder to follow.
#### Step 4: Generate!
Click the **"π Generate Animation"** button and wait for the magic to happen!
**Generation typically takes 2-5 minutes** depending on:
- Animation duration
- System resources
- API response times
- Rendering complexity
### Progress Tracking
Watch the progress bar to see what's happening:
1. **Planning concept...** - AI analyzes your topic
2. **Generating narration script...** - Creating the story
3. **Creating Manim animation code...** - Writing Python code
4. **Rendering animation video...** - Manim creates the video
5. **Generating audio narration...** - Text-to-speech conversion
6. **Merging video and audio...** - Final production
7. **Creating quiz questions...** - Assessment generation
### Results
Once complete, you'll see:
1. **Video Player**: Watch your generated animation
- Use the download button to save the video
- Videos are saved in the `outputs/` directory
2. **Status Message**: Confirmation with details
- Topic, audience, output filename
- Success or error information
3. **Additional Content** (expandable accordion):
- **Narration Script**: The spoken text
- **Manim Code**: Python code used to create the animation
- **Quiz Questions**: Assessment questions about the topic
- **Concept Plan**: Educational planning details
---
## π‘ Tips for Best Results
### Topic Selection
β
**Good Topics:**
- "Explain the Pythagorean theorem with a proof"
- "Visualize the quadratic formula"
- "Show how binary addition works"
- "Demonstrate Newton's laws with examples"
β **Avoid:**
- Overly vague: "math stuff"
- Too broad: "all of physics"
- Non-visual: "history of mathematics"
- Too niche: "Riemann hypothesis proof"
### Audience Matching
- **Elementary**: Use for basic arithmetic, simple science, introductory concepts
- **Middle School**: Algebra basics, pre-algebra, earth science, basic chemistry
- **High School**: Advanced algebra, geometry, trigonometry, physics, chemistry
- **Undergraduate**: Calculus, linear algebra, advanced physics, computer science
- **General**: When unsure or for mixed audiences
### Duration Guidelines
| Duration | Best For | Typical Content |
|----------|----------|-----------------|
| 0.5-1 min | Single formula/concept | Definition + example |
| 1.5-2 min | Standard lesson | Concept + explanation + example |
| 2-3 min | Detailed explanation | Theory + multiple examples + applications |
| 3-5 min | Comprehensive topic | Multiple concepts + derivations + practice |
### Common Issues & Solutions
**Problem:** "Generation Failed" error
- **Check** your API keys are correctly set in `.env`
- **Verify** you have internet connection
- **Try** a simpler topic or shorter duration
- **Look** at the status message for specific error details
**Problem:** Audio sounds wrong or missing
- **Check** ELEVENLABS_API_KEY is set (for best quality)
- **Verify** the narration script looks correct (in the accordion)
- **Note** that HF fallback TTS has lower quality but should work
**Problem:** Video doesn't render
- **Ensure** Manim is properly installed: `manim --version`
- **Check** FFmpeg is installed: `ffmpeg -version`
- **Look** at the generated code tab for syntax errors
- **Try** regenerating - AI can sometimes produce invalid code
**Problem:** "Topic too vague" or poor quality output
- **Be more specific** in your topic description
- **Include keywords** like "explain", "prove", "demonstrate"
- **Try different phrasing** if results aren't good
---
## βοΈ Settings Tab
### Check API Key Status
View which API keys are configured:
- β
Green checkmark = configured
- β Red X = not set (required)
- β οΈ Warning = not set (optional, will use fallback)
### System Information
View system configuration:
- Output directory location
- Default rendering settings
- Manim version
### Reconfiguring Keys
If you need to change API keys:
1. Edit the `.env` file in the project root
2. Restart the Gradio application
3. Check the Settings tab to verify new keys are detected
---
## βΉοΈ About Tab
Learn more about:
- NeuroAnim features
- Technology stack
- How the system works
- Example use cases
- Tips for best results
---
## π Output Files
Generated animations are saved in the `outputs/` directory with filenames like:
```
Pythagorean_Theorem_20240120_143022.mp4
```
The filename includes:
- Sanitized topic name (alphanumeric + underscores)
- Timestamp (YYYYMMDD_HHMMSS)
- .mp4 extension
**Downloading:**
- Click the download button in the video player
- Or navigate to `outputs/` and copy files directly
**File Management:**
- Old files are NOT automatically deleted
- Clean up the `outputs/` directory periodically
- Each generation creates a new file with unique timestamp
---
## π§ Advanced Usage
### Using Example Topics
Click any example to auto-fill the form:
1. Find "π‘ Example Topics" section
2. Click on any row
3. Topic, audience, and duration will populate
4. Click "Generate Animation"
### Batch Generation
To generate multiple animations:
1. Generate first animation
2. While it's processing, you can prepare the next one
3. Wait for completion before starting the next
4. Note: Concurrent generation is not supported
### Custom Prompts
For more control, you can:
1. Generate an animation
2. Review the narration and code
3. If not satisfied, regenerate with different parameters
4. Try varying the topic phrasing for different results
### API Access
The Gradio interface also provides an API endpoint:
```python
from gradio_client import Client
client = Client("http://localhost:7860")
result = client.predict(
topic="Pythagorean Theorem",
audience="high_school",
duration=2.0,
api_name="/generate"
)
```
---
## π Troubleshooting
### Port Already in Use
If port 7860 is occupied, edit `app.py` line 522:
```python
interface.launch(
server_port=7861, # Change to different port
...
)
```
### Slow Generation
Generation speed depends on:
- **API rate limits**: HuggingFace may throttle requests
- **Model availability**: Some models load slower
- **Rendering complexity**: More objects = longer render
- **System resources**: CPU, RAM, disk speed
**To speed up:**
- Use shorter durations (1-2 min instead of 5-10)
- Choose simpler topics
- Ensure good internet connection
- Use local GPU if available (advanced)
### Memory Issues
If you encounter out-of-memory errors:
- Close other applications
- Restart the Gradio app
- Use shorter animation durations
- Reduce rendering quality (requires code changes)
### Connection Timeout
If API calls timeout:
- Check internet connection
- Verify API keys are valid
- Try again in a few minutes (may be temporary API issue)
- Check HuggingFace status page
---
## π Learning Resources
### Understanding Generated Code
The Manim code uses these key components:
```python
from manim import * # Import Manim library
class MyScene(MovingCameraScene): # Scene class
def construct(self): # Main animation method
# Create objects
circle = Circle(radius=1, color=BLUE)
# Animate them
self.play(Create(circle))
self.wait(1)
```
**Learn More:**
- [Manim Documentation](https://docs.manim.community/)
- [Manim Tutorial](https://docs.manim.community/en/stable/tutorials.html)
- [Example Gallery](https://docs.manim.community/en/stable/examples.html)
### Improving Narration
Good narration:
- Starts with context ("Today we'll explore...")
- Explains step-by-step
- Uses analogies and examples
- Ends with summary or takeaway
Review the generated narration script and note what works well for future reference.
---
## π Educational Best Practices
### For Teachers
- **Preview First**: Generate and review before showing to students
- **Customize**: Use generated content as a starting point
- **Supplement**: Combine with traditional teaching methods
- **Assess**: Use the quiz questions for homework or tests
- **Iterate**: Regenerate if the first attempt isn't perfect
### For Students
- **Active Learning**: Pause and try problems yourself
- **Take Notes**: Write down key points from narration
- **Rewatch**: Complex topics benefit from multiple viewings
- **Practice**: Do the quiz questions to test understanding
- **Ask Questions**: Use as supplementary material, not replacement for asking teachers
### For Content Creators
- **Brand Consistency**: Edit narration/code for your style
- **Quality Control**: Always review before publishing
- **Add Value**: Enhance with your own insights
- **Credit**: Mention AI-generated if appropriate
- **Engage**: Ask viewers questions, encourage comments
---
## π Privacy & Security
### Data Handling
- Topics and generated content are sent to external APIs (HuggingFace, ElevenLabs)
- No content is stored by NeuroAnim except locally on your machine
- API providers have their own privacy policies
- Generated videos are saved only to your local `outputs/` directory
### API Key Security
- Never share your `.env` file
- Don't commit API keys to version control
- Keep keys confidential
- Rotate keys periodically
- Use read-only or limited scopes when available
### Sharing Generated Content
- Videos are yours to use as you see fit
- Be aware AI-generated content may have limitations
- Verify accuracy before using in critical contexts
- Consider licensing if publishing commercially
---
## π Getting Help
### Check Logs
The console where you ran `python app.py` shows detailed logs:
```
2024-01-20 14:30:22 - INFO - Generating speech with elevenlabs...
2024-01-20 14:30:25 - ERROR - TTS failed: API key invalid
```
### Common Error Messages
**"HUGGINGFACE_API_KEY not set"**
- Add key to `.env` file and restart
**"Rendering failed"**
- Check Manim code tab for syntax errors
- Verify Manim and FFmpeg are installed
**"TTS generation failed"**
- Check ElevenLabs API key or rely on fallback
- Verify narration text is valid
**"All TTS providers failed"**
- Check both API keys
- Install gtts: `pip install gtts`
### Contact & Support
- Check the GitHub repository Issues page
- Review IMPROVEMENTS.md for known issues
- Consult Manim Community forums for rendering issues
- Check HuggingFace/ElevenLabs documentation for API issues
---
## π Success Stories
Once you've mastered the basics, you can:
- Create a library of math explainer videos
- Build a YouTube channel with AI-assisted content
- Develop course materials for online classes
- Generate study aids for exams
- Prototype animation ideas before manual creation
**Happy animating! π**
---
*Last updated: 2024*
*For more information, see README.md and IMPROVEMENTS.md* |