Skip to content

Repository files navigation

VideoTeaching - AI-Powered Video Presentation Generator

Tự động tạo video thuyết trình với avatar nói chuyện sử dụng AI (SadTalker + VieNeu-TTS)

Python PyTorch CUDA Docker GHCR CI/CD License

✨ Features

  • 🎬 SadTalker Video Generation - Tạo video talking head từ ảnh tĩnh + audio
  • 🎤 VieNeu-TTS - Chuyển văn bản tiếng Việt thành giọng nói tự nhiên
  • 🎭 Voice Cloning - Clone giọng nói từ file audio hoặc ghi âm trực tiếp
  • 🤖 Multi-Model Support - Chọn model TTS (GGUF Q4/Q8, PyTorch) tùy theo CPU/GPU
  • 🧠 Google Gemini - Tự động tạo script thuyết trình từ slide PowerPoint/PDF
  • 📊 Presentation Processing - Đọc và xử lý file PPTX, PPT, PDF
  • 🎨 Modern UI - Giao diện Bootstrap 5 responsive, dễ sử dụng
  • 🐳 Docker Ready - Triển khai dễ dàng với Docker Compose + GPU support

🚀 Quick Start

Option 1: Pre-built Docker Image (Fastest ⚡)

Pull optimized image từ GitHub Container Registry - đã được tối ưu hóa với docker-slim!

Prerequisites:

  • Docker Desktop 20.10+
  • NVIDIA GPU + NVIDIA Container Toolkit (for GPU acceleration)
# Set your API key
export GEMINI_API_KEY=your_api_key_here
# Windows PowerShell: $env:GEMINI_API_KEY = "your_api_key_here"

# Run the pull and run script
bash scripts/pull-and-run.sh
# Windows: .\scripts\pull-and-run.ps1

Access: http://localhost:8000

📦 See deployment guide →

Option 2: Build Docker Locally

Prerequisites:

  • Docker Desktop 20.10+
  • NVIDIA GPU + NVIDIA Container Toolkit (for GPU acceleration)
# 1. Clone repository
git clone https://github.com/Cong-ty-TNNH-Q-Tech/CreateVideo-Website.git
cd VideoTeaching

# 2. Setup environment
cp .env.example .env
# Edit .env and add your GEMINI_API_KEY

# 3. Download AI models
python download_models.py

# 4. Run with Docker
.\docker-run.ps1 build    # Build image
.\docker-run.ps1 start    # Start production
# or
.\docker-run.ps1 dev      # Start development mode

Access: http://localhost:8000

📚 See full Docker documentation →

Option 3: Local Development (Không cần Docker)

Yêu cầu hệ thống:

  • Python 3.10 hoặc 3.11
  • FFmpeg
  • Git
  • (Tùy chọn) CUDA 11.8+ và NVIDIA GPU để tăng tốc

🐧 Linux / macOS

# 0. Cài Python 3.11 (nếu chưa có)
# Ubuntu/Debian:
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt-get update
sudo apt-get install -y python3.11 python3.11-venv python3.11-dev

# macOS (dùng Homebrew):
brew install python@3.11

# Kiểm tra:
python3.11 --version

# 1. Cài FFmpeg
# Ubuntu/Debian:
sudo apt-get install -y ffmpeg git build-essential
# macOS:
brew install ffmpeg

# 2. Clone repository
git clone https://github.com/Cong-ty-TNNH-Q-Tech/CreateVideo-Website.git
cd CreateVideo-Website

# 3. Tạo và kích hoạt virtual environment
python3.11 -m venv venv
source venv/bin/activate

# 4a. Cài PyTorch — GPU (CUDA 11.8)
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \
  --index-url https://download.pytorch.org/whl/cu118

# 4b. Cài PyTorch — CPU only
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 \
  --index-url https://download.pytorch.org/whl/cpu

# 5. Cài dependencies
pip install -r requirements.txt

# 6. Tạo file .env
cp .env.example .env          # hoặc tạo thủ công nếu không có .env.example
echo "GEMINI_API_KEY=your_api_key_here" >> .env

# 7. Tải AI models (SadTalker checkpoints ~4GB)
python download_models.py

# 8. Chạy ứng dụng
python run.py

🪟 Windows

# 0. Cài Python 3.11 (nếu chưa có)
# Cách 1 — winget (khuyên dùng):
winget install Python.Python.3.11

# Cách 2 — pyenv-win:
pip install pyenv-win --target "$HOME\.pyenv"
[System.Environment]::SetEnvironmentVariable('PYENV', "$HOME\.pyenv\pyenv-win", 'User')
pyenv install 3.11.9
pyenv global 3.11.9

# Kiểm tra:
py -3.11 --version
# hoặc:
python --version

# 1. Cài FFmpeg (dùng winget hoặc tải từ https://ffmpeg.org/download.html)
winget install ffmpeg

# 2. Clone repository
git clone https://github.com/Cong-ty-TNNH-Q-Tech/CreateVideo-Website.git
cd CreateVideo-Website

# 3. Tạo và kích hoạt virtual environment
py -3.11 -m venv venv
venv\Scripts\Activate.ps1

# (Nếu bị lỗi ExecutionPolicy)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

# 4a. Cài PyTorch — GPU (CUDA 11.8)
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 `
  --index-url https://download.pytorch.org/whl/cu118

# 4b. Cài PyTorch — CPU only
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 `
  --index-url https://download.pytorch.org/whl/cpu

# 5. Cài dependencies (Windows-specific)
pip install -r requirements-windows.txt

# 6. Tạo file .env (tạo thủ công hoặc copy)
Copy-Item .env.example .env   # nếu có file mẫu
# Mở .env và điền GEMINI_API_KEY

# 7. Tải AI models
python download_models.py

# 8. Chạy ứng dụng
python run.py

📖 Xem hướng dẫn cài đặt Windows chi tiết →


Access: http://localhost:8000

CPU mode: Ứng dụng tự động chạy ở CPU mode nếu không có GPU. Chỉ nên dùng model VieNeu-TTS-0.3B-q4-gguf trên CPU để giữ tốc độ chấp nhận được.

📁 Project Structure

VideoTeaching/
├── app/
│   ├── controllers/        # API routes and handlers
│   │   ├── main.py        # Main routes, test pages
│   │   └── generation.py  # SadTalker & TTS API endpoints
│   ├── services/          # Business logic
│   │   ├── gemini_service.py    # Google Gemini integration
│   │   └── video_generator.py  # SadTalker wrapper
│   ├── models/            # Data models
│   ├── utils/             # Utilities (presentation reader)
│   ├── SadTalker/         # SadTalker model (submodule)
│   └── VieNeu-TTS/        # VieNeu-TTS model (submodule)
├── templates/             # HTML templates
│   ├── presentation.html  # Main presentation upload page
│   ├── test_sadtalker.html  # SadTalker test page
│   └── test_tts.html      # VieNeu-TTS test page
├── static/                # Static files
│   ├── uploads/           # Uploaded presentations
│   └── results/           # Generated videos/audio
├── tests/                 # Unit & integration tests
├── docs/ai/              # AI DevKit documentation
├── Dockerfile            # Multi-stage Docker build
├── docker-compose.yml    # Production Docker config
├── docker-compose.dev.yml # Development Docker config
├── requirements.txt      # Python dependencies
├── config.py            # Flask configuration
└── run.py               # Application entry point

🎯 Usage

1. Test TTS (Text-to-Speech)

Navigate to: http://localhost:5000/test/tts

  • Text Input: Nhập văn bản tiếng Việt cần đọc
  • Model Selection: Chọn model TTS (Q4-GGUF cho CPU, Q8/PyTorch cho GPU)
  • Voice Selection:
    • Giọng preset: Tuyên, Ngọc, Ly, Bình, Vĩnh, Đoan
    • Voice cloning: Upload audio mẫu hoặc ghi âm trực tiếp
  • Generate: Tạo giọng nói và tải về file WAV

2. Test SadTalker (Video Generation)

Navigate to: http://localhost:5000/test/sadtalker

  • Image: Upload ảnh chân dung (portrait photo)
  • Audio: Upload file audio hoặc dùng TTS
  • Generate: Tạo video talking head
  • Download: Tải về video MP4

3. Presentation to Video (Full Pipeline)

Navigate to: http://localhost:5000

  • Upload: PPTX, PPT, hoặc PDF presentation
  • AI Script: Gemini tự động tạo script cho từng slide
  • Edit: Chỉnh sửa script nếu cần
  • Generate: Tạo TTS audio cho từng slide
  • Create Video: Kết hợp với SadTalker tạo video hoàn chỉnh

🛠️ Configuration

Environment Variables (.env)

# Flask
FLASK_APP=run.py
FLASK_ENV=production
SECRET_KEY=your-secret-key

# Google Gemini API
GEMINI_API_KEY=your_gemini_api_key_here

# GPU Settings
CUDA_VISIBLE_DEVICES=0
NVIDIA_VISIBLE_DEVICES=all

Model Selection

VieNeu-TTS Models:

  • VieNeu-TTS-0.3B-q4-gguf - CPU tối ưu, tốc độ nhanh nhất
  • VieNeu-TTS-0.3B-q8-gguf - Cân bằng chất lượng/tốc độ
  • VieNeu-TTS-0.3B - PyTorch 190 params, GPU accelerated
  • VieNeu-TTS - Chất lượng tốt nhất, yêu cầu GPU mạnh

SadTalker Settings:

  • Size: 256 (faster) hoặc 512 (better quality)
  • Enhancer: gfpgan (face enhancement)
  • Preprocess: full (best quality) hoặc crop (faster)

🧪 Testing

# Run all tests
pytest

# Run specific test
pytest tests/test_api_routes.py

# With coverage
pytest --cov=app tests/

🐛 Troubleshooting

GPU Not Detected

# Check CUDA availability
python -c "import torch; print(torch.cuda.is_available())"

# Check NVIDIA drivers
nvidia-smi

Face Detection Errors

  • Use clear portrait photos with visible face
  • Ensure good lighting in the image
  • Try different images if detection fails

TTS Model Loading Slow

  • First run downloads models from HuggingFace (may take time)
  • Models are cached in ~/.cache/huggingface/
  • Use GGUF models for faster CPU inference

Out of Memory

  • Use smaller model (Q4-GGUF)
  • Reduce batch size in SadTalker
  • Use CPU mode: --cpu flag

📦 Docker Deployment

Pre-built Images (GitHub Container Registry)

Tự động build và tối ưu hóa với docker-slim qua GitHub Actions CI/CD:

# Pull latest version
docker pull ghcr.io/cong-ty-tnnh-q-tech/createvideo-website:main

# Run with GPU
docker run -d \
  --gpus all \
  -p 8000:8000 \
  -e GEMINI_API_KEY=your_key \
  ghcr.io/cong-ty-tnnh-q-tech/createvideo-website:main

# Run without GPU (CPU only)
docker compose -f docker-compose.prod.yml -f docker-compose.cpu.yml up -d

Image Tags:

  • main - Latest build từ main branch
  • develop - Development builds
  • v1.0.0 - Semantic versioning tags
  • main-sha-<commit> - Specific commit builds

Image Optimization:

  • Original size: ~8.5 GB
  • Optimized with docker-slim: ~3-4 GB (50-60% reduction)
  • Multi-stage build với CUDA 11.8 support

📦 Full deployment guide →

Build from Source

See README.Docker.md for:

  • GPU setup with NVIDIA Container Toolkit
  • Production deployment with Docker Compose
  • Development mode with live reload
  • Troubleshooting and optimization
  • Security best practices

🤝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'feat: add amazing feature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

Follow Conventional Commits for commit messages.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support


Made with ❤️ by MoneyEveryWhere Team

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages