Jump to content

Subtitle translation using local LLM or API calls - Very accurate language - cheap.


Recommended Posts

Posted

As many of us, I am not a native english speaker, nor are many of my friends and family that use my Emby instance.  Thus, I am constantly asked for subtitles for various tv-shows and movies.
Now I have a VIP account on Opensubtitles.com and that is well and good, but often the subs are missing or sync is wrong. 
I have used AI tools both as a hobby and professionally for several years already, but until these last months, getting reliable AND cheap translations of whole movies and episodes has been a challenge.. that is .. until now.

I have made a project that uses whatever llm you would like, either local, if you have some hefty hardware, or via API calls to commercial LLM's like chatgpt, claude, deepseek etc.
This project has A LOT of redundancies built in, and uses batch translation to keep context, and ensure the llm understand the actual plot and handles slang and such in a good way.

It is super easy to use, just edit the config files to reflect what are your target language, point the script to a folder with either a tv-series, a movie, or even a whole library, and it will go forth and find ALL embedded subtitles in mkv's extract one (there is a priority list you can use) translate it, and mux it into the mkv.  For other file formats, eg. .mp4, .avi etc, it uses external files, and will translate those, and putting them back with the right language tag and filename.  There is A LOT more to this, but if I can come with a simple suggestion: Use Deepseek API.  It is really good for translation, and it is so cheap to use, I still can't wrap my head around it.  If you need something like this, take a look at my repo, where all you need to know is, including one line installers.  

The project is of course fully open source, MIT license, so you can do with it what you want, and also it includes script wrappers for both powershell for use on windows, and bash scripts for use on Linux. (debian / ubuntu). 

One more thing, just to get it out of the way.. I take no responsibility for anything that happens by using the script. I have done all in my power to make it idiot-proof (mostly for myself :-)) but you never know what some people are capable of.. so use on your own risk..  Here is the repo:

https://github.com/dexusno/Translate_Subs

Best regards, dexus - Norway.

  • Like 2
Posted (edited)

I would love something like that (and I never cease hoping that one day would be feasible) as it would finally get wifey off my back - unfortunately, my native language is of such complexity that simple word-for-word translation or even Ai reading context can't provide acceptable outcome based on text-input only (words, nouns, verbs - everything changes in respect who's speaking, female or male + not 2 but 3 genders), voice sample is mandatory. If you know any method to automate that, I - and the better part of regional community - would likely be eternally grateful. 

For reference, I've just asked Gemini few common languages gradation by difficuly. 🙄 

Screenshot_20260404_221013_com_opera_browser_BrowserActivity.jpg

Edited by GrimReaper
Posted (edited)

@GrimReaper I would suggest that you try it out.  I am Norwegian, and that is also not one of the easiest languages to translate to or from, but with Deepseek API, it is virtually flawless..  I did a lot of previous attempts, using language translation engines like NLLB-200 from Meta, which is a pure translation LLM between the 200 FLORES languages.  It was easy to run locally, but was, as you mentioned, a word for word translation machine... 

That meant sentences like: "Hi, do you want coffee? - No, I'm good" was translated literally, but the "No, I'm good" actually mean, well.. just.. no.  But with a premium LLM with 500 lines of context, it understands the flow and knows about slang, sayings, and other linguistic traps, and takes it into account, making just beautiful translations. I was flabbergasted to use a fancy word, when I first saw the outcome.  I use DeepSeek, because the price is just ridiculous..  To give you a hint of the prices i have been hitting:

Based on a typical 45-minute TV episode with ~600 subtitle groups.
Uses worst-case pricing (no cache discount).

  Per episode: about 1 cent

    1 episode .............. ~$0.01
    1 season (10 episodes) . ~$0.10
    1 series (50 episodes) . ~$0.50
    100 episodes ........... ~$1
    500 episodes ........... ~$5
    1,000 episodes ......... ~$10

  For the price of a cup of coffee you can translate
  over 500 episodes. A monthly Netflix subscription
  would cover about 1,500 episodes. ;-D

Now, that is a far bit cheaper than OpenAI or Claude.. but you can of course use those in this project as well.

My main use for this is actually to make it part of my Sonarr and Radarr workflow.  I will have them run it on the target folder each time they transfer a movie or episode to the final destination in my library.  The script will always skip files that already have a subtitle in the target language, so running the script more than once on the same folder will only resume, or pick up new files that need treatment.   So if a file already have in my case norwegian subs, it will just ignore, and quit, but if it finds no norwegian, but ANY other languguage, it will extract, translate, mux.. or if not mkv, write to external .srt file.

Edited by dexus
Neminem
Posted (edited)
22 hours ago, dexus said:

ANY other languguage, it will extract, translate, mux.. or if not mkv, write to external .srt file.

Curious if its will always embed the subs into MKV files?

I have not played with this yet 😁 

Ohh its a script / barebone install, any chance for a docker version 🤔

Edited by Neminem
Adding

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...