Sign inSign up

agoddrie/srtgen

By agoddrie

Updated 10 months ago

AI-powered subtitle generator and translator with NVIDIA GPU acceleration

Image
Machine learning & AI
0

1.7K

agoddrie/srtgen repository overview

SRTGEN - AI-Powered Subtitle Generator

SRTGEN Logo

GPU-accelerated subtitle generation for video files using OpenAI Whisper AI and NLLB translation

Docker Hub License: MIT Docker Image Size

FeaturesQuick StartUsageConfigurationDocker Hub


✨ Features

  • 🎯 AI-Powered Transcription - OpenAI Whisper with GPU acceleration
  • 🌍 Multi-Language Translation - Facebook's NLLB-200-1.3B for 200+ languages
  • 🎬 Triple SRT Output - Original language, English, and target language
  • 📝 Word-Level Timestamps - Precise subtitle timing synchronization
  • 🌐 Modern Web UI - Browse files, monitor jobs, configure settings
  • 🚀 Background Processing - Queue multiple transcription jobs
  • 🔍 Smart File Browser - Search, filter, path memory, existing SRT detection
  • 🐳 Docker Ready - One-click deployment on Unraid
  • 💾 Persistent Settings - Language preferences saved in browser
  • GPU Optimized - CUDA acceleration for 10x faster processing

🚀 Quick Start

Docker Run (Fastest)
docker run -d --name srtgen \
  --gpus all \
  -p 5000:5000 \
  -v /path/to/media:/media \
  -e WHISPER_MODEL=medium \
  agoddrie/srtgen:latest

Access: http://localhost:5000

Create docker-compose.yml:

version: '3.8'
services:
  srtgen:
    image: agoddrie/srtgen:latest
    container_name: srtgen
    ports:
      - "5000:5000"
    volumes:
      - /mnt/user/TV-Series:/media/tv:rw
      - /mnt/user/Movies:/media/movies:rw
    environment:
      - WHISPER_MODEL=medium
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    restart: unless-stopped

Start:

docker-compose up -d
First Run Setup

Install translation dependencies (one-time):

docker exec -it srtgen pip install transformers sentencepiece protobuf sacremoses
Unraid Template
  1. Go to Docker tab → Add Container
  2. Click Template repositories → Add: https://github.com/agoddrie/srtgen
  3. Search for SRTGEN
  4. Configure paths and click Apply

📋 Requirements

  • NVIDIA GPU (recommended for speed)
  • Docker with NVIDIA Container Runtime
  • 8GB+ VRAM for medium Whisper model + NLLB-1.3B

🎮 Usage

  1. Open browser: http://localhost:5000
  2. Browse media folders or use search
  3. Select video file (MKV, MP4, AVI)
  4. Choose language or enable auto-detect
  5. Configure overwrite settings
  6. Click "Generate Subtitles"
  7. Monitor progress in sidebar
Output Files

For movie.mkv, generates:

movie.en.srt      # Original language transcription
movie.en.srt      # English translation (if not English)
movie.nl.srt      # Target language (e.g., Dutch)
Supported Formats
  • Video: .mkv, .mp4, .avi
  • Languages: 99+ via Whisper (EN, NL, FR, DE, ES, IT, PT, PL, RU, JA, ZH, KO, AR, TR, etc.)
  • Translation: 200+ via NLLB-200

⚙️ Configuration

Whisper Model Selection

Set via environment variable:

ModelVRAMSpeedAccuracyRecommended
tiny~1GBFastestGoodTesting
base~1GBVery FastBetterQuick jobs
small~2GBFastGoodBalanced
medium~5GBModerateExcellentProduction
large~10GBSlowBestMaximum quality

Example:

environment:
  - WHISPER_MODEL=medium
Settings Modal

Access via ⚙️ icon in web UI:

  • Default Language - Preset translation target
  • Settings persist in browser localStorage
Volume Mapping
volumes:
  - /host/path:/media/name:rw  # Read-write required for SRT creation

Important: Use :rw flag to allow subtitle file creation

🛠️ Technology Stack

ComponentTechnologyPurpose
AI TranscriptionOpenAI WhisperSpeech-to-text with 99+ languages
AI TranslationFacebook NLLB-200-1.3BContext-aware translation (200+ languages)
BackendPython 3.11 + FlaskREST API and job management
GPU AccelerationPyTorch + CUDA10x faster processing
Audio ProcessingFFmpegExtract audio from video containers
FrontendVanilla JavaScriptLightweight, no dependencies
StoragelocalStorageSettings persistence
How It Works
graph LR
    A[Video File] -->|FFmpeg| B[Audio 16kHz WAV]
    B -->|Whisper| C[Original SRT + Language]
    C -->|Whisper Translate| D[English SRT]
    C -->|NLLB-200| E[Target Language SRT]
    D --> F[Triple SRT Output]
    E --> F
  1. Audio Extraction: FFmpeg → 16kHz mono WAV in /tmp
  2. Transcription: Whisper with word-level timestamps + auto language detection
  3. English Translation: Whisper's built-in translation task
  4. Target Translation: NLLB batch processing (5 segments) with context
  5. Timestamp Adjustment: Extends duration for longer translations
  6. SRT Generation: Filters non-speech, formats timestamps, saves files

🐛 Troubleshooting

Translation module not found
docker exec -it srtgen pip install transformers sentencepiece protobuf sacremoses

Note: Required on first run. Will be added to Dockerfile in future release.

GPU not detected

Verify NVIDIA runtime:

docker run --rm --gpus all nvidia/cuda:11.8.0-base-ubuntu22.04 nvidia-smi

Install nvidia-container-toolkit:

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
Template changes not visible
  1. Hard refresh browser: Ctrl+Shift+R
  2. Restart container: docker restart srtgen
  3. Clear browser cache
Permission denied writing SRT

Ensure volumes use :rw flag:

volumes:
  - /path/to/media:/media:rw  # Not :ro
Subtitle timing off by ~1 second

Word-level timestamps enabled by default. If issues persist:

  • Try different Whisper model
  • Check video/audio sync in source file
  • Report issue with example file

📦 Building from Source

git clone https://github.com/agoddrie/srtgen.git
cd srtgen
docker build -t agoddrie/srtgen:latest .
docker-compose up -d

🤝 Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing)
  5. Open Pull Request
Development Setup
# Clone repo
git clone https://github.com/agoddrie/srtgen.git
cd srtgen

# Build image
docker build -t srtgen:dev .

# Run with hot-reload
docker run -it --rm \
  --gpus all \
  -p 5000:5000 \
  -v $(pwd)/app.py:/app/app.py \
  -v $(pwd)/mkv_transcribe.py:/app/mkv_transcribe.py \
  -v /media:/media:rw \
  srtgen:dev

📊 Benchmarks

Test file: 22-minute episode (The IT Crowd S01E01)

ModelGPUTimeAccuracyVRAM
tinyRTX 5070 Ti45s85%1.2GB
baseRTX 5070 Ti1m 15s92%1.5GB
smallRTX 5070 Ti2m 30s96%2.8GB
mediumRTX 5070 Ti4m 20s98%5.2GB
largeRTX 5070 Ti8m 45s99%10.5GB

Translation adds ~2-3 minutes for NLLB-1.3B processing

📄 License

MIT License - See LICENSE file

Third-party components:

🙏 Acknowledgments

⭐ Support

If you find SRTGEN useful, please:

  • ⭐ Star the repository
  • 🐛 Report bugs via Issues
  • 💡 Request features
  • 📖 Improve documentation
  • 🔄 Share with others

Made with ❤️ for the Unraid community

Docker HubGitHubIssues

Tag summary

Content type

Image

Digest

sha256:df8a96ed0

Size

4.3 GB

Last updated

10 months ago

docker pull agoddrie/srtgen