AI-powered subtitle translation with context preservation
Features β’ The Problem β’ How It Works β’ Installation β’ Usage β’ API β’ Contributing
- π§ Smart Sentence Merging β Uses SpaCy NLP to detect sentence boundaries across subtitle blocks
- π Context-Aware Translation β Translates complete sentences, not fragmented blocks
- β‘ Proportional Splitting β Redistributes translations back to original timestamps using character ratios
- π 29+ Languages β Powered by DeepL API with support for major world languages
- π¨ Modern Web UI β Dark glassmorphism theme with drag-and-drop file upload
- π Real-time Progress β Server-Sent Events (SSE) for live translation status updates
- π Secure β API keys stored locally, never transmitted to third parties
- π οΈ Multi-Model Support β Install multiple SpaCy language models for different source languages
- π Auto Language Detection β Automatically detects source file language
β οΈ Smart Warnings β Alerts for language mismatches and same language selections
Turkish sentence structure places the verb at the end. When subtitles split a sentence into multiple lines, standard translators fail to capture the meaning of the first line because the action (verb) is missing until the end.
Original (Split in 3 lines):
- BΓΌtΓΌn bu olanlardan
- sonra, beni affetmeni
- beklemiyorum.
| Method | Output (Subtitle) | Why it fails/succeeds? |
|---|---|---|
| Standard (Line-by-Line) | 1. From all these things 2. after, to forgive me 3. I am not waiting. |
β FAIL: "Beklemiyorum" is translated as "waiting" physically, instead of "expecting". The sentence is broken and meaningless. |
| SRT Smart Translator | 1. After all that has happened, 2. I do not expect 3. you to forgive me. |
β SUCCESS: It merges lines, understands "affetmeni beklemiyorum" implies expectation, translates correctly, and re-splits by timing. |
Smart SRT Translator uses a 4-step pipeline:
ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ
β Parse βββββΆβ Merge βββββΆβTranslate βββββΆβ Split β
β SRT β βSentences β β (API) β β Back β
ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ
Reads the SRT file with UTF-8 BOM support using pysrt
SpaCy NLP detects sentence boundaries and merges split sentences
Complete sentences are sent to DeepL API for contextual translation
Translation is proportionally split back to original block structure using character ratios
- Python 3.8+ β Download from python.org
β οΈ Check "Add Python to PATH" during installation!
- DeepL API Key β Get free API key
# 1. Clone repository
git clone https://github.com/vseprr/srt-smart-translator.git
cd srt-smart-translator
# 2. Create virtual environment
python -m venv venv
# 3. Activate virtual environment
# Windows (PowerShell):
.\venv\Scripts\Activate.ps1
# Windows (CMD):
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# 4. Install dependencies
pip install -r requirements.txt
# 5. Start the application
python app.py- Browser opens automatically to http://localhost:5000
- You'll see the Setup Wizard π§ββοΈ
- Select one or more language models to install:
- π¬π§ English (en_core_web_sm)
- πΉπ· Turkish (tr_core_news_lg)
- πͺπΈ Spanish (es_core_news_sm)
- π«π· French (fr_core_news_sm)
- π©πͺ German (de_core_news_sm)
- π Multilingual (xx_sent_ud_sm) - works with any language
- β Custom (install from URL)
- Wait for installation to complete
- Enter your DeepL API key in Settings
- Start translating! π
π‘ Tip: For multilingual models (xx_*), just type the install command - language is auto-selected as "Multilingual / Universal".
After initial setup, double-click UI-Start.bat to launch (auto-setup if first time).
- Start the server:
python app.py(browser opens automatically) - Upload SRT file via drag-and-drop
- Select target language and click "Start Translation"
- Download the translated file when complete
- π΄ Language Mismatch β No SpaCy model for detected language, using fallback
- π£ Universal Model β Using multilingual model (works for all languages)
- π Same Language β Source and target languages are the same
srt-smart-translator/
βββ app.py # Flask server + API endpoints
βββ parser.py # SRT file reading/writing
βββ engine.py # Sentence merging algorithm
βββ translator.py # DeepL API integration
βββ requirements.txt # Python dependencies
βββ UI-Start.bat # Windows quick launcher
βββ backend/
β βββ model_manager.py # SpaCy model management
β βββ language_data.py # Language configurations
βββ templates/
β βββ index.html # Main translation page
β βββ setup.html # First-run setup wizard
β βββ settings.html # Settings & model management
βββ static/
β βββ style.css # Dark glassmorphism theme
βββ uploads/ # Temporary upload storage
βββ outputs/ # Translated files
- API Key Management β Save/remove DeepL API key
- Installed Models β View all installed SpaCy models
- Remove Model β Uninstalls model with
pip uninstall - Add Model β Install via:
python -m spacy download xx_modelpip install https://...whl- Direct wheel URL
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Main page (HTML) |
GET |
/setup |
Setup wizard (if no models) |
GET |
/settings |
Settings page |
GET |
/api/config |
Check API key status |
POST |
/api/config |
Save API key |
DELETE |
/api/config |
Remove API key |
POST |
/api/install-model |
Install SpaCy model |
POST |
/api/remove-model |
Uninstall SpaCy model |
POST |
/upload |
Upload SRT file |
POST |
/translate |
Start translation job |
GET |
/status/{job_id} |
Translation status (JSON) |
GET |
/progress/{job_id} |
Real-time progress (SSE) |
GET |
/download/{job_id} |
Download translated file |
| Component | Technology |
|---|---|
| Backend | Flask 3.x |
| NLP | SpaCy (multiple models) |
| Language Detection | langdetect |
| Translation | DeepL Free API |
| SRT Parsing | pysrt |
| Frontend | Vanilla HTML/CSS/JS |
| Design | Dark Glassmorphism |
- Single file only β No batch translation yet
- SRT format only β VTT, ASS not supported
- Internet required β DeepL API needs connectivity
-
Multi-language SpaCy model support -
Automatic source language detection -
First-run setup wizard -
Real pip uninstall for models - Batch file translation
- VTT/ASS format support
- Formality selection (formal/informal)
- Translation history
- PWA support for offline UI
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source and available under the MIT License.
- DeepL for their excellent translation API
- SpaCy for natural language processing
- pysrt for SRT file handling
- Turkish NLP Suite for Turkish SpaCy model
Made with β€οΈ for the subtitle community
