A Python script that uses AI models to translate large .srt subtitle files for movies, lectures, or any long-form content.
Since large subtitle files can't be translated in a single pass, the script splits the file into chunks and sends them to the AI model one at a time. Chunk size is user-configurable, giving direct control over a quality-vs-cost tradeoff: larger chunks use less quota and processing time but produce lower translation quality, while smaller chunks cost more in API/compute usage but yield more accurate, context-aware results.
To keep translations consistent across the whole file, the script tracks unique words and names as it goes, so recurring terms and proper nouns are translated the same way throughout — rather than drifting or being re-interpreted chunk by chunk. The result reads as a natural, faithful translation rather than a stiff, literal one.
The script was tested using Ollama Cloud as the provider across various models, and has yielded strong results translating from English to Arabic.