You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chunks translated concurrently. Only cloud providers benefit; local providers (Ollama) are forced to 1. Values > 1 drop cross-chunk context
1
API Keys
Tip: any --*_api_key flag also accepts comma-separated values
(e.g. --gemini_api_key key1,key2,key3) for automatic rotation on HTTP 429.
See API_KEY_ROTATION.md.
Option
Description
--openrouter_api_key
OpenRouter API key
--openai_api_key
OpenAI API key (cloud only — not needed for local servers)
Enable refinement pass: runs a second pass to polish translation quality and literary style
--refine-only
Run ONLY a refinement pass on an already-translated file (skips the translation phase). The input file is assumed to already be in the target language.
--glossary
Path to a glossary file (.json or .csv) injected per-chunk to keep entity translations consistent
--auto-glossary
Derive a throwaway glossary from the input document with one extra LLM call before translating (no file, nothing saved). Ignored when --glossary is given or with --refine-only.
--auto-style
Derive style instructions from the input document with one extra LLM call before translating (no preset file, nothing saved).
TTS (Text-to-Speech)
Option
Description
Default
--tts
Generate audio from translated text using Edge-TTS
disabled
--tts-voice
TTS voice name
Auto-selected based on target language
--tts-rate
Speech rate adjustment (e.g., +10%, -20%)
+0%
--tts-bitrate
Audio bitrate (e.g., 64k, 96k)
48k
--tts-format
Audio output format: opus or mp3
opus
Display
Option
Description
--no-color
Disable colored output
Examples
Basic Translation
# Text file (auto-generates "book (French).txt")
python translate.py -i book.txt -sl English -tl French
# Subtitles (auto-generates "movie (French).srt")
python translate.py -i movie.srt -tl French
# EPUB (auto-generates "novel (French).epub")
python translate.py -i novel.epub -tl French
# DOCX (auto-generates "report (French).docx")
python translate.py -i report.docx -tl French
# Custom output filename
python translate.py -i book.txt -o my_custom_name.txt -tl French
# OCR cleanup (fix broken lines, spacing from scanned documents)
python translate.py -i scanned_book.txt -tl French --text-cleanup
# Refinement pass for higher quality literary translation
python translate.py -i novel.epub -tl French --refine
# Both options combined
python translate.py -i scanned_book.txt -tl French --text-cleanup --refine
# Auto glossary + auto style: no glossary file, no preset, derived from the# document itself with one extra LLM call each before translation starts
python translate.py -i novel.epub -sl Chinese -tl English --auto-glossary --auto-style
With TTS (Text-to-Speech)
# Generate audio with auto-selected voice
python translate.py -i book.txt -tl French --tts
# Specify voice and format
python translate.py -i book.txt -tl French --tts --tts-voice fr-FR-DeniseNeural --tts-format mp3
# Adjust speech rate and quality
python translate.py -i book.txt -tl French --tts --tts-rate "+10%" --tts-bitrate 96k
Environment Variables
Instead of passing options every time, use a .env file:
# Provider
LLM_PROVIDER=ollama
DEFAULT_MODEL=qwen3:14b
API_ENDPOINT=http://localhost:11434/api/generate
# API Keys (any of these accepts comma-separated values for rotation)
OPENROUTER_API_KEY=sk-or-v1-...
OPENAI_API_KEY=sk-...
GEMINI_API_KEY=...
MISTRAL_API_KEY=...
DEEPSEEK_API_KEY=...
POE_API_KEY=...
NIM_API_KEY=...
# Performance
REQUEST_TIMEOUT=900
MAX_TOKENS_PER_CHUNK=450 # Token-based chunking (default: 450 tokens)# Languages
DEFAULT_SOURCE_LANGUAGE=English
DEFAULT_TARGET_LANGUAGE=French
# TTS
TTS_ENABLED=false
TTS_VOICE= # Auto-selected if empty
TTS_RATE=+0%
TTS_BITRATE=48k
TTS_OUTPUT_FORMAT=opus