LLM-Subtrans

CLI

Uses an LLM to translate SRT, ASS and VTT subtitles into any language in batches, convert formats and transcribe audio or video. Install the CLI from source (Python 3.10+); needs an API key (e.g. OpenRouter) or a local model, and subtitles go to that provider.

machinewrapped/llm-subtrans670
README

LLM-Subtrans

LLM-Subtrans is an open source subtitle translator that uses LLMs as a translation service. It can translate subtitles between any language pairs supported by the language model.

Supports multiple subtitle formats through a pluggable system (.srt, .ssa/.ass and .vtt).

Supports transcription from video files and audio tracks, with speaker identification to improve translation accuracy (with supported models).

When you use a hosted service, LLM-Subtrans sends subtitle text or audio clips to that provider. To translate without sending subtitle text to a hosted service, run the model locally with Custom Server.

Installation

For most users the packaged release is the easiest way to use the program. Download a package from the releases page, unzip to a folder and run gui-subtrans. You will be prompted for some basic setup on first run.

If you want to use the command line tools, modify the code or just prefer to have more control over the setup you will need to install from source.

Windows

Every release is packaged for Windows as (gui-subtrans-x.x.x.zip).

MacOS

Packaged builds are (usually) provided for MacOS with Apple Silicon (gui-subtrans-x.x.x.macos-arm64.zip). If you have an Intel Mac you will need to install from source.

Linux

Prebuilt Linux packages are not provided so you will need to install from source.

Translation Providers

Most hosted providers require an API key for that specific service. Use the provider configuration guide to find where to get a key and how to set up your provider in the GUI or on the command line.

OpenRouter

API terms · Privacy policy · Setup

OpenRouter is the default provider, based in New York, and requires an OpenRouter API key. You can pick from its model catalogue or let OpenRouter choose a model.

Google Gemini

API terms · Setup

Gemini Flash models have historically been the fastest and most fluent for subtitle translation, but Gemini’s safety filters are aggressive, so some subtitles may need to be translated with another provider.

OpenAI

API terms · Privacy policy · Setup

OpenAI models can translate using an API key or a ChatGPT plan.

If you have an eligible ChatGPT plan, you can sign in through the OpenAI provider. Transcription is not supported.

DeepSeek

API terms · Setup

DeepSeek is a low-cost option, and can bring useful knowledge of idiomatic usage for Chinese translations in particular.

Anthropic

API terms · Setup

Claude is relatively expensive for subtitle translation. Anthropic’s rate limits vary by usage tier and can slow down large jobs.

Mistral

API terms · Setup

Mistral is a European model provider, based in France. Smaller Mistral models have historically tended to follow translation instructions less reliably.

Gateways and routers

Hosted gateways give you access to models from multiple vendors with a single API key. The available models and prices vary by gateway.

  • API Route is run by an independent developer.
  • Atlas Cloud is based in New York and hosts its services in the US.
  • DemonRoute serves open-weight models, including community fine-tunes.
  • LiteLLM is an optional integration.
  • Opper is based in Sweden. Its platform runs in Stockholm, and EU-hosted models keep inference in the EU.
  • Requesty is based in the UK, with its infrastructure hosted in Frankfurt.
  • Runcrate is based in the US and serves open-weight models.
  • UberLLM uses prepaid credits.

Custom Server

Use Custom Server to translate with a model on your own machine or connect to a remote server that exposes an OpenAI-compatible API. When the server and model run locally, subtitle content stays on your machine.

For a local LM Studio server, start the server with your model loaded and select Custom Server. Supply a model ID or API key if the server requires one.

Enter http://localhost:1234 as the server address and /v1/chat/completions as the endpoint. Enable Supports Conversation for that endpoint.

For legacy text completions, use the endpoint your server provides, such as /v1/completions, and turn off Supports Conversation. Text completions use non-streaming responses.

If your model expects a specific prompt format, edit the prompt template and keep {prompt} where the subtitle batch should go. Small, heavily quantized models can produce weaker translations or fail to follow the expected subtitle response format. The Custom Server configuration guide includes a command-line example.

Cloud platforms

Azure and Bedrock probably only make sense if you already have access to models through those platforms. A direct model provider or a gateway requires much less setup.

OpenAI Azure

Use Azure if you already have an OpenAI model deployed there or your organization requires it. You’ll need the resource URL, deployment name, API version, and an API key for that resource. See the Azure setup guide for the corresponding settings.

Amazon Bedrock

Bedrock is worth considering if you already have model access in AWS. You’ll need AWS credentials with IAM permission to invoke the model and access to a model that supports the Converse API in your chosen region. The Bedrock setup guide lists the required permissions and settings. Packaged builds do not ship with Bedrock support. Install from source with the bedrock extra.

Transcription

LLM-Subtrans can transcribe audio and video files (mp4, mkv, mp3, wav, ...), which can then be translated with the normal workflow. This can produce better results than a text-only translation flow, with more accurate timings and speaker identification (depending on the provider).

Speaker labels are passed to the translator with each line, which may help it interpret a line or a scene. They restart with each chunk of audio, so the same label can refer to different people in different chunks, unless the provider transcribes the whole clip in one request. Save transcriptions as VTT or ASS to keep the labels.

Note: Transcription requires ffmpeg/ffprobe to be installed and accessible.

From the GUI, click Transcribe Audio in the toolbar (Ctrl+R) to open a separate dialog for transcription, or drag a media file onto the main window. A successful result will be opened as a translation project upon completion.

Cloud transcription services

  • OpenRouter: Provides several speech-to-text models, e.g. the excellent MAI Transcribe 2, ElevenLabs Scribe v2, DeepGram and Grok.
  • ElevenLabs: Scribe v2 with word timestamps and speaker diarization.
  • Gemini: gemini-3.5-transcribe with word timestamps and speaker diarization. Very good, but brutal rate limits.
  • Muse: Meta `muse-voice-transcribe-1. Slow, and only provides approximate timings.
  • OpenAI: whisper-1 (word timestamps) and gpt-4o-transcribe-diarize. Experimental support.

Local transcription

Qwen Local runs Qwen3-ASR on your computer without sending audio to a transcription service. This is a beta feature.

It requires a separate PyTorch installation suitable for your hardware. The first run downloads about 6 GB of model weights. For packaged builds, use Set up Qwen... in Qwen Local's settings, which installs Torch and the Qwen runtime into a separate environment. If you set up Torch with an earlier version, run the setup again and select the same environment to add the Qwen runtime. For source installs, install.bat and install.sh offer Qwen Local, MOSS Local or both, and install each runtime in its own environment beside envsubtrans: envqwen for Qwen and envmoss for MOSS.

The source runtime installer accepts Python 3.10 or later. Qwen runs in a worker process using envqwen's own interpreter, so Torch and Transformers are kept out of envsubtrans. With no explicit Torch directory setting, source runs prefer envqwen in the project root and fall back to the current interpreter for older installs that already contain Qwen.

MOSS Local runs MOSS-Transcribe-Diarize on your computer, and labels speakers. It returns short, closely timed segments without word timings. The first run downloads about 2 GB of model weights. MOSS needs its own environment, since it uses a newer Transformers than Qwen. For packaged builds, use Set up MOSS... in MOSS Local's settings, which installs Torch and the MOSS runtime into a separate environment. Source installs use envmoss.

Installing from source

If you want to use the command line tools or modify the program, you will need to have Python 3.10+ and pip installed on your system, then follow these steps.

Clone the LLM-Subtrans repository to your local machine using the following command or your preferred tool:

```sh
git clone https://github.com/machinewrapped/llm-subtrans.git
```

Setup scripts

The easiest setup method is to run the unified installation script:

  • Windows: Run install.bat
  • MacOS/Linux: Run install.sh

These scripts will create a virtual environment and offer install with GUI or install command line only options, with additional options to add support for specific providers. The script will guide you through the setup and generate command scripts to launch the application.

Pass --portable to install.bat or install.sh to create the local .settings directory without prompting. Use --configpath <directory> to configure a different settings and log directory; the installer saves that path in .env.

During the installing process, you can choose to input an API key for each selected provider when prompted, which will be saved in a .env file so that you don't need to provide it every time you run the program. This is largely redundant if you only plan to use the GUI, as keys can be saved in the app settings.

Manual configuration

If you ran an install script you can skip the remaining steps. Continue reading only if you want to configure the environment manually instead.

  1. Create a .env file in the project root and add the settings for your chosen provider. See the translation provider configuration guide for the variable names and API key links.

  2. Create a virtual environment for the project by running the following command in the root folder to create a local environment for the Python interpreter (optional, but highly recommended to avoid dependency conflicts with other Python applications):

    python -m venv envsubtrans
    
  3. Activate the virtual environment by running the appropriate command for your operating system. You will need to do this each time before running the app.

    .\envsubtrans\Scripts\activate      # Windows
    source ./envsubtrans/bin/activate   # Mac/Linux
    
  4. Install the project (add the -e switch for an editable install if you want to modify the code):

    pip install -e .                   # Minimal install of command line tools with support for OpenRouter or Custom Server
    pip install -e ".[gui]"            # Core module and default provider with GUI module
    pip install -e ".[gui,openai,gemini,claude,mistral,bedrock]"   # Full install with optional providers (delete to taste)
    
  5. Optionally install the Qwen runtime for local transcription into its own environment:

    ./envsubtrans/Scripts/python.exe scripts/install_qwen_runtime.py envqwen  # Windows
    ./envsubtrans/bin/python scripts/install_qwen_runtime.py envqwen          # Mac/Linux
    

    The script creates envqwen if needed, detects your hardware, installs the appropriate Torch build there, and then installs qwen-asr and its runtime dependencies without its demo app web frameworks. Run the installer with envsubtrans's Python; the target environment does not need PySubtrans installed. A different directory can be used by configuring Qwen Local's Torch installation directory setting. Existing environments with Python 3.10 or later can be reused without matching the application's Python version.

  6. Optionally install the MOSS runtime for local transcription with speaker labels into its own environment:

    ./envsubtrans/Scripts/python.exe scripts/install_moss_runtime.py envmoss  # Windows
    ./envsubtrans/bin/python scripts/install_moss_runtime.py envmoss          # Mac/Linux
    

    The script creates envmoss if needed, installs the appropriate Torch build there, and then installs MOSS and its dependencies. MOSS Local uses envmoss in the project root unless its installation directory is configured.

Usage

The program works by dividing the subtitles up into batches and sending each one to the translation service in turn.

It can potentially make many API calls for each subtitle file, depending on the batch size. Speed heavily depends on the selected model.

By default The translated subtitles will be written to a new file in the same directory with the target langugage appended to the original filename.

GUI

The Subtrans GUI is the best and easiest way to use the program.

After installation, launch the GUI with the gui-subtrans command or shell script, and hopefully the rest should be self-explanatory.

See the project wiki for further details on how to use the program.

Command Line

LLM-Subtrans can be used as a console command or shell script. The install scripts create a cmd or sh file in the project root for each provider you select, which will take care of activating the virtual environment and calling the corresponding translation script.

# Use OpenRouter with automatic model selection
llm-subtrans --auto -l <language> <path_to_subtitle_file>

# Use OpenRouter with a specific model
llm-subtrans --model google/gemini-4-hydrogen -l <language> <path_to_subtitle_file>

# Use any gateway by name, with its own model and API key settings (e.g. REQUESTY_API_KEY)
llm-subtrans --gateway "Requesty" --model openai/gpt-6-luna -l <language> <path_to_subtitle_file>

# Convert format while translating (ASS to SRT in this example)
llm-subtrans -l <language> -o output.srt input.ass

# Use any server with an OpenAI-compatible API
llm-subtrans -s <server_address> -e <endpoint> -k <api_key> -l <language> <path_to_subtitle_file>

# Use specific providers
gpt-subtrans --model gpt-6-luna --target-language <target_language> <path_to_subtitle_file>
gemini-subtrans --model gemini-4-hydrogen --target-language <target_language> <path_to_subtitle_file>
claude-subtrans --model claude-haiku-5-5 --target-language <target_language> <path_to_subtitle_file>

# List supported subtitle formats
llm-subtrans --list-formats

# Batch process files in a folder tree
batch-translate ./subtitles ./translated --provider OpenAI --model gpt-6-luna --apikey sk-... --language Spanish

# Any provider can be selected by name in batch-translate, including gateways such as Requesty or Atlas Cloud
batch-translate ./subtitles ./translated --provider "Atlas Cloud" --model openai/gpt-6-luna --language Spanish

The output format is inferred from file extensions. To convert between formats, provide an output path with the desired extension.

If the target language is not specified the default is English.

Other options that can be specified on the command line are detailed below.

Transcription

Transcription is a separate process.

# Transcribe with the default provider (OpenRouter, using microsoft/mai-transcribe-2)
python scripts/transcribe.py movie.mkv --apikey sk-or-... --language Japanese

# Transcribe locally with Qwen3-ASR (requires Torch and the Qwen runtime)
python scripts/transcribe.py movie.mkv --provider "Qwen Local" --language Chinese --format ass

# Transcribe locally with MOSS, with speaker labels (requires the MOSS runtime)
python scripts/transcribe.py movie.mkv --provider "MOSS Local" --format ass

Transcription options:

  • --provider — transcription provider (default: OpenRouter; use --list-providers to list)
  • --language — spoken language hint (e.g. Chinese, English)
  • --track — audio track index (default: 0; use --list-tracks to identify audio tracks in the source)
  • --diarize / --no-diarize — speaker identification (default: on; support is model-dependent)
  • --align / --no-align — word-level timestamps (default: on)
  • --format — output format: srt, ass, or vtt (default: vtt; ass/vtt preserve speaker labels)
  • -o / --output — output file path (defaults to alongside the media file)
  • -s / --server — server address for the provider
  • -k / --apikey — API key for cloud providers
  • -m / --model — model name
  • --capture — also write the provider's raw output to a JSON file, for replaying with scripts/replay_transcription.py (developer tool)

Project File

Note: Project files are enabled by default in the GUI.

The --project argument or PROJECT_FILE .env setting control whether a project file will be written to disc for the command line.

If enabled, a file will be created with the .subtrans extension when a subtitle file is loaded, containing details of the project. It will be updated as the translation progresses. Writing a project file allows, amongst other things, resuming a translation that was interrupted. It is highly recommended.

# Use OpenRouter and create a persistent project
llm-subtrans --project --auto -l <language> <path_to_subtitle_file>

# Use OpenRouter and resume a persistent project
llm-subtrans --project --auto -l <language> <path_to_subtrans_file>
llm-subtrans --project --auto -l <language> <path_to_subtitle_file>  # Project file will be detected automatically if it is in the same folder

Configuration directory

The GUI and command-line tools use the platform's standard application-data directory for settings and logs. Use --portable to store them in a .settings folder in the current directory, or --configpath <directory> to set a specific location. An existing .settings directory will automatically activate portable mode.

Format Conversion

LLM-Subtrans is primarily a translation application, and format conversion is probably best handled by dedicated tools, but the option exists to read one format and write another.

# Use OpenRouter and convert from .ass to .srt
llm-subtrans --project --auto -l <language> -o <path_to_output_file.srt> <path_to_subtitle_file.ass>

Advanced usage

There are a number of command-line arguments that offer more control over the translation process.

To use any of these arguments, add them to the command-line after the path to the source file. For example:

llm-subtrans path/to/my/subtitles.srt --moviename "My Awesome Movie" --ratelimit 10 --substitution cat::dog

Default values for many settings can be set in the .env file, using a NAME_IN_CAPS format. See Options.py and the various Provider_XXX files for the full list.

  • -l, --target-language: The language to translate the subtitles to.

  • -o, --output: Specify a filename for the translated subtitles.

  • --includeoriginal: Include the original text in the translated subtitles, above the translation unless set otherwise.

  • --originalabove, --originalbelow: Include the original text above or below the translation (either implies --includeoriginal).

  • --project: Read or Write a project file for the subtitles being translated (see above for details)

  • --ratelimit: Maximum number of requests to the translation service per minute (mainly relevant if you are using an OpenAI free trial account).

  • --moviename: Optionally identify the source material to give context to the translator.

  • --description: A brief description of the source material to give further context. Less is generally more here, or the AI can start improvising.

  • --name, --names: Optionally provide (a list of) names to use in the translation (more powerful AI models are more likely to actually use them).

  • --substitution: A pair of strings separated by ::, to substitute in either source or translation, or the name of a file containing a list of such pairs.

  • --build-terminology-map: Accumulates names, titles and technical terms into a terminology map that is provided to subsequent batches so that consistent translations can be used throughout.

  • --terminology: Seed the terminology map with a SOURCE::TRANSLATION pair, or a path to a text file of such pairs. Repeatable. Example: --terminology "Alice::アリス" --terminology wonderland_locations.txt

  • --scenethreshold: Number of seconds between lines to consider it a new scene.

  • --minbatchsize: Minimum number of lines to consider starting a new batch to send to the translator. Higher values typically result in faster and cheaper translations but increase the risk of desyncs.

  • --maxbatchsize: Maximum number of lines before starting a new batch is compulsory. This needs to take into account the token limit for the model being used, but the "optimal" value depends on many factors, so experimentation is encouraged. Larger batches are more cost-effective but increase the risk of the AI desynchronising, triggering expensive retries.

  • --preprocess: Preprocess the subtitles prior to batching. This performs various actions to prepare the subtitles for more efficient translation, e.g. splitting long (duration) lines into multiple lines. Mainly intended for subtitles that have been automatically transcribed with e.g. Whisper.

  • --postprocess: Post-process translated subtitles. Performs various actions like adding line breaks to long lines and normalising dialogue tags after a translation request.

  • --instruction: An additional instruction for the AI indicating how it should approach the translation.

  • --instructionfile: Name/path of a file to load AI system instructions from (otherwise the default instructions.txt is used).

  • --maxlines: Maximum number of batches to process. To end the translation after a certain number of lines, e.g. to check the results.

  • --temperature: A higher temperature increases the random variance of translations. Default 0.

  • --reload: Subtitles will be reloaded from the source file rather than using the subtitles saved in the project (note: this implies --project)

  • --retranslate: Existing translations will be ignored and all subtitles will be retranslated (note: this implies --project)

  • --reparse: Existing translations will not be sent to the translator again but the translator's response will be reprocessed to extract the translations. This is mainly useful after a bug fix release, but can also be used to reset translations that have been hand-edited (note: this implies --project)

  • --preview: Subtitles will be loaded and batched and the translation flow will run, but no calls to the translator will be made. Only useful for debug.

Provider-specific arguments

See the provider configuration guide for translation provider flags.

Proxy Support

LLM-Subtrans has support for proxies across most providers.

Configuration

You can configure a proxy using the following arguments:

  • --proxy <URL>: Specify the proxy URL. Supports both HTTP and SOCKS proxies. Example: --proxy http://127.0.0.1:8888 or --proxy socks5://127.0.0.1:1080

  • --proxycert <PATH>: Path to a custom CA certificate bundle (PEM format). This is required when using an intercepting proxy (like mitmproxy or Fiddler) that uses a self-signed certificate. Example: --proxycert C:\Users\name\.mitmproxy\mitmproxy-ca-cert.pem

Example Usage

# Use a SOCKS proxy for OpenRouter
llm-subtrans --auto -l Spanish input.srt --proxy socks5://127.0.0.1:1080

# Use mitmdump with a custom certificate
llm-subtrans --auto -l French input.srt --proxy http://127.0.0.1:8080 --proxycert ./mitmproxy-ca-cert.pem

batch process

You can process files with the following directory structure:

  #   -SRT
  #   --fold1
  #   ---1.srt
  #   ---2.srt
  #   ...
  #   --fold2
  #   ---1.srt
  #   ---2.srt
  #   ...

Use the batch_translate.py script to process multiple subtitle files:

You can modify the DEFAULT_OPTIONS values directly in the script file, or use a combination of script defaults and command line overrides.

# Preview mode to test settings without making API calls
python scripts/batch-translate.py --preview

# Basic usage with command line arguments
python scripts/batch-translate.py ./subtitles ./translated --provider openai --model gpt-5-mini --apikey sk-... --language Spanish

# Override output format
python scripts/batch-translate.py ./subtitles ./translated --provider openai --output-format srt

# Use additional options
python scripts/batch-translate.py ./subtitles ./translated --provider openai --option max_batch_size=150 --option postprocess_subtitles=true

Developers

It is recommended to use an IDE such as Visual Studio Code to run the program when installed from source, and set up a launch.json file to specify the arguments.

Note: Remember to activate the virtual environment every time you work on the project.

Contributing

Contributions from the community are welcome! To contribute, follow these steps:

Fork the repository onto your own GitHub account.

Clone the repository onto your local machine using the following command:

git clone https://github.com/your_username/llm-subtrans.git

Create a new branch for your changes using the following command:

git checkout -b feature/your-new-feature

Install pyright as a pre-commit hook (optional but encouraged):

# Install pyright for type checking
pip install pyright

# Install git hooks (runs type checking before commits)
# Windows:
hooks\install.bat

# Linux/Mac:
./hooks/install.sh

Make your changes to the code and commit them with a descriptive commit message.

Push your changes to your forked repository.

Submit a pull request to the main LLM-Subtrans repository.

Localization

LLM-Subtrans uses GNU gettext for UI localization.

  • Template (POT): locales/gui-subtrans.pot
  • Per‑language catalogs: locales/<lang>/LC_MESSAGES/gui-subtrans.po
  • Compiled catalogs: locales/<lang>/LC_MESSAGES/gui-subtrans.mo

Strings in the code are marked with helpers (see codebase):

  • _("text") for simple strings
  • tr("context", "text") for contextualized strings

Contributions are very welcome - you can add a new localization in minutes! See docs/localization_contributing.md for detailed instructions (tools, workflow, etc).

Acknowledgements

This project uses several useful libraries:

Translation providers:

For the GUI:

For bundled versions:

Version History

Version 1.3 added OpenRouter as the default translation service, opening up access to many more

Version 1.2 added localization for the GUI and support for the GPT-5 model line.

Version 1.1 added support for a more flexible translation format for use with custom instructions.

Version 1.0 is (ironically) a minor update, updating the major version to 1.0 because the project has been stable for some time.

Version 0.7 introduced optional post-processing of translated subtitles to try to fix some of the common issues with LLM-translated subtitles (e.g. adding line breaks), along with new default instructions that tend to produce fewer errors.

Version 0.6 changes the architecture to a provider-based system, allowing multiple AI services to be used as translators. Settings are compartmentalised for each provider. For the intial release the only supported provider is OpenAI.

Version 0.5 adds support for gpt-instruct models and a refactored code base to support different translation engines. For most users, the recommendation is still to use the gpt-3.5-turbo-16k model with batch sizes of between (10,100) lines, for the best combination of performance/cost and translation quality.

Version 0.4 features significant optimisations to the GUI making it more responsive and usable, along with numerous bug fixes.

Version 0.3 featured a major effort to bring the GUI up to full functionality and usability, including adding options dialogs and more, plus many bug fixes.

Version 0.2 employs a new prompting approach that greatly reduces desyncs caused by GPT merging together source lines in the translation. This can reduce the naturalness of the translation when the source and target languages have very different grammar, but it provides a better base for a human to polish the output.

The instructions have also been made more detailed, with multiple examples of correct output for GPT to reference, and the generation of summaries has been improved so that GPT is better able to understand the context of the batch it is translating. Additionally, double-clicking a scene or batch now allows the summary to be edited by hand, which can greatly improve the results of a retranslation and of subsequent batches or scenes. Individually lines can also be edited by double-clicking them.

License

LLM-Subtrans is licensed under the MIT License. The packaged GUI-Subtrans build includes THIRD-PARTY-NOTICES.txt with the licenses of the third-party libraries it bundles.