SRTran is a command-line tool for translating subtitle files (.srt) from one language to another using various AI language models. Written in Go.
- Translate .srt subtitle files between any language pair
- Support for multiple AI providers:
- Google AI Studio (Gemini)
- OpenAI
- OpenRouter
- LM Studio
- Easy-to-use command-line interface
SRTran can be configured using a TOML configuration file or environment variables.
Create a config.toml
file in one of these locations:
./config.toml
(current directory)~/.config/srtran/config.toml
~/.srtran.toml
Example configuration:
See config.toml
You can also specify a custom config file location using the -c
flag:
srtran translate -c /path/to/config.toml -i input.srt -o output.srt -s english -t norwegian
Alternatively, you can use environment variables:
# Google AI Studio
export GOOGLE_AI_API_KEY='your-key' GOOGLE_AI_MODEL='gemini-2.0-flash-exp'
# OpenRouter
export OPENROUTER_API_KEY='your-key' OPENROUTER_MODEL='anthropic/claude-3.5-sonnet'
# OpenAI
export OPENAI_API_KEY='your-key' OPENAI_MODEL='gpt-4'
The tool will try API keys in this order: Google AI → OpenRouter → OpenAI
-i, --input
: Input subtitle file (required)-o, --output
: Output subtitle file (required)-s, --source-language
: Source language (required)-t, --target-language
: Target language (required)-c, --config
: /path/to/file-v, --verbose
: Enable verbose output
-
Translate from English to French with verbose output:
srtran translate -i movie.srt -o movie_fr.srt -s english -t french -v
-
Translate from Spanish to German:
srtran translate -i spanish.srt -o german.srt -s spanish -t german
SRTran supports translation between any language pair. The supported languages depend on the AI provider being used.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.