Translate text subtitles (including embedded subtitles) to any language using OpenAI's API.
- Install ffmpeg:
sudo apt install ffmpeg
- Install
node
andnpm
- Install ai-sub:
npm i -g ai-sub
- Copy
.env.example
to.env
and edit the values
ai-sub "path/to/movie.mkv"
or for all files in a directory
ai-sub "path/to/movies/**/*"
--debug
Print debug information
--batch
Batch translation requests using Open AI's Batch API (extremely recommended, allows doing double the requests, but takes a lot more time)
--wait
Wait until all jobs are finished (only works with --batch, may take a while)
Key | Value | Example |
---|---|---|
TARGET_LANGUAGE | Target language with first letter in upper case | Spanish |
TARGET_LANGUAGE_ALIAS | Array of alias of the target language, comma separated | es,spa,spanish |
EXTRA_SPECIFICATION | Extra specification for the translation | Translation must be in Latin American Spanish, not Spain Spanish |
MAX_TOKENS | Max tokens to send to the model | 1000 |
OPENAI_API_KEY | OpenAI API key | sk-XXX |
AI_MODEL | OpenAI model to use (for better translations use gpt-4, but its 10x more expensive) | gpt-3.5-turbo |
This project was inspired by yazinsai/srt-ai