A production-ready, AI-powered video translation application that automatically translates video content across multiple languages using advanced speech recognition, machine translation, and natural text-to-speech synthesis.
- ๐ฏ Multi-Language Support: Translate videos between 7 languages (English, Spanish, Italian, Japanese, Russian, German, Portuguese)
- ๐ค AI-Powered Pipeline: Leverages Google Speech Recognition, Deep Translator, and gTTS for high-quality translations
- ๐จ Modern Web Interface: Beautiful, responsive Gradio-based UI for easy interaction
- ๐๏ธ Production-Ready: Enterprise-grade code with comprehensive error handling, logging, and type hints
- ๐ฆ Modular Architecture: Clean, maintainable codebase following industry best practices
- โ Type-Safe: Full type hinting throughout the codebase
- ๐ Progress Tracking: Real-time progress updates during translation
- ๐งช Well-Tested: Comprehensive test suite with pytest
- About
- Installation
- Usage
- Features
- Architecture
- Development
- API Reference
- Contributing
- License
- Author
Video Translator is a sophisticated application that transforms video content across language barriers. It uses a multi-stage AI pipeline to:
- Extract audio from video files
- Recognize speech using Google's Speech Recognition API
- Translate text using advanced neural translation models
- Synthesize natural-sounding speech in the target language
- Compose a new video with the translated audio track
Built with modern Python practices, this application is designed for both ease of use and production deployment.
- Python: 3.9 or higher
- uv: Fast Python package installer (astral-sh/uv)
- FFmpeg: Required by moviepy for video processing
Ubuntu/Debian:
sudo apt update
sudo apt install ffmpegmacOS:
brew install ffmpegWindows: Download from ffmpeg.org and add to PATH.
# Clone the repository
git clone https://github.com/ruslanmv/Video-Translator.git
cd Video-Translator
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install dependencies
make install
# For development (includes testing tools)
make install-dev# Clone the repository
git clone https://github.com/ruslanmv/Video-Translator.git
cd Video-Translator
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in editable mode
pip install -e .Launch the interactive web interface:
# Using make
make run
# Or directly
video-translator
# Or using Python
python -m video_translator.mainThen open your browser to http://localhost:7860
from video_translator import VideoTranslator
# Initialize translator
translator = VideoTranslator()
# Translate a single video
output = translator.translate_video(
video_path="my_video.mp4",
source_language="English",
target_language="Spanish"
)
print(f"Translation complete: {output}")
# Batch translate to multiple languages
results = translator.batch_translate(
video_path="my_video.mp4",
source_language="English",
target_languages=["Spanish", "French", "German"]
)
for language, output_path in results.items():
print(f"{language}: {output_path}")from video_translator.config import Config
from video_translator.translator import VideoTranslator
# Custom configuration
config = Config(
temp_dir="./temp",
output_dir="./output",
max_file_size_mb=1000
)
# Initialize with custom config
translator = VideoTranslator(config)
# Translate
output = translator.translate_video(
"video.mp4",
"English",
"Japanese"
)Video-Translator/
โโโ video_translator/ # Main package
โ โโโ __init__.py # Package initialization
โ โโโ main.py # Gradio web interface
โ โโโ translator.py # Main translation orchestrator
โ โโโ video.py # Video processing module
โ โโโ audio.py # Audio processing module
โ โโโ config.py # Configuration and constants
โ โโโ exceptions.py # Custom exceptions
โ โโโ logger.py # Logging configuration
โ โโโ utils.py # Utility functions
โโโ tests/ # Test suite
โ โโโ __init__.py
โ โโโ test_translator.py
โ โโโ test_video.py
โ โโโ test_audio.py
โ โโโ test_utils.py
โโโ pyproject.toml # Project metadata and dependencies
โโโ Makefile # Automation commands
โโโ README.md # This file
โโโ LICENSE # Apache 2.0 license
โโโ .gitignore # Git ignore patterns
โโโโโโโโโโโโโโโโโโโ
โ Upload Video โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Extract Audio โ (moviepy)
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Speech-to-Text โ (Google Speech Recognition)
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Translation โ (Deep Translator)
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Text-to-Speech โ (gTTS)
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Replace Audio โ (moviepy)
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Translated Videoโ
โโโโโโโโโโโโโโโโโโโ
# Install with development dependencies
make install-dev
# Or using uv directly
uv pip install -e ".[dev]"# Format code
make format
# Run linters
make lint
# Type checking
make type-check
# Run all checks
make check# Run tests
make test
# Run tests with coverage
make test-cov
# View coverage report
open htmlcov/index.htmlmake help # Show all available commands
make install # Install production dependencies
make install-dev # Install all dependencies (including dev tools)
make clean # Remove build artifacts and cache
make lint # Run code linting
make format # Format code with black and isort
make type-check # Run mypy type checking
make test # Run tests
make test-cov # Run tests with coverage report
make run # Run the application
make build # Build distribution packages
make ci # Run all CI checksMain class for video translation operations.
class VideoTranslator:
def __init__(self, config: Optional[Config] = None)
def translate_video(
self,
video_path: str,
source_language: str,
target_language: str,
output_path: Optional[str] = None
) -> str
def batch_translate(
self,
video_path: str,
source_language: str,
target_languages: list
) -> dict- ๐ฌ๐ง English (en-US)
- ๐ฎ๐น Italian (it-IT)
- ๐ฏ๐ต Japanese (ja-JP)
- ๐ท๐บ Russian (ru-RU)
- ๐ช๐ธ Spanish (es-MX)
- ๐ฉ๐ช German (de-DE)
- ๐ง๐ท Portuguese (pt-BR)
VideoTranslatorError # Base exception
VideoProcessingError # Video processing failures
AudioExtractionError # Audio extraction failures
SpeechRecognitionError # Speech recognition failures
TranslationError # Translation failures
TextToSpeechError # Text-to-speech failures
InvalidInputError # Invalid input parametersContributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 style guidelines
- Add type hints to all functions
- Write comprehensive docstrings
- Include unit tests for new features
- Update documentation as needed
- Run
make cibefore submitting PR
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Copyright 2024 Ruslan Magana
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Ruslan Magana
- Website: ruslanmv.com
- GitHub: @ruslanmv
- Email: contact@ruslanmv.com
- Gradio - For the amazing web interface framework
- moviepy - For video processing capabilities
- gTTS - For text-to-speech synthesis
- SpeechRecognition - For speech-to-text
- deep-translator - For robust translation
This project is actively maintained and production-ready. For issues, feature requests, or questions, please open an issue on GitHub.
Made with โค๏ธ by Ruslan Magana
