A Python-based tool for automatically translating Korean webtoons to English. This tool uses OCR to detect text in speech bubbles, translates the text using OpenAI's GPT-3.5-turbo (the cheapest model), and renders it back onto the image while preserving the original artwork.
- Automatic text detection in speech bubbles using EasyOCR
- Korean to English translation using OpenAI GPT-3.5-turbo (much better quality than MarianMT)
- Intelligent sound effect translation (e.g., "어허회" → "sob", "퍽" → "whack")
- Context-aware translations that maintain plot coherence
- Text removal and inpainting to preserve artwork
- Support for both single panels and long webtoon strips
- Automatic panel splitting for long webtoon images
- Translation caching to reduce API costs
- Clone the repository:
git clone https://github.com/cphanhth/Webtoon-Translator.git
cd Webtoon-Translator- Create a virtual environment and install dependencies:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt- Set up OpenAI API key (required for translation):
python setup_openai.pyOr manually create a .env file with:
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-3.5-turbo
OPENAI_MAX_TOKENS=1000
OPENAI_TEMPERATURE=0.3
python src/main.py input_panel.png output_panel.pngpython src/main.py long_webtoon.png translated_webtoon.png --mode webtoonpython src/main.py input.png output.png --font path/to/font.ttfpython src/main.py input.png output.png --openai-key YOUR_API_KEYfrom src.main import WebtoonTranslator
# Initialize translator
translator = WebtoonTranslator()
# Translate single panel
translator.translate_panel("input_panel.png", "output_panel.png")
# Translate long webtoon
translator.translate_webtoon("long_webtoon.png", "translated_webtoon.png")Test the OpenAI integration:
python test_openai.pyUsing GPT-3.5-turbo (the cheapest model):
- Input tokens: $0.0015 per 1K tokens
- Output tokens: $0.002 per 1K tokens
- Typical cost per panel: ~$0.0001 - $0.0005
- 1000 panels: ~$0.10 - $0.50
The system includes caching to avoid re-translating identical text.
You can customize the OpenAI settings in your .env file:
OPENAI_MODEL: Model to use (default: gpt-3.5-turbo)OPENAI_MAX_TOKENS: Maximum response length (default: 1000)OPENAI_TEMPERATURE: Response creativity 0.0-1.0 (default: 0.3)
- Python 3.7+
- OpenCV
- NumPy
- Pillow
- EasyOCR
- OpenAI (for translation)
- python-dotenv (for configuration)
This project is licensed under the MIT License - see the LICENSE file for details.