✓ Verified ✍️ Content Creation ✓ Enhanced Data

Subtitle Translate Skill

Translate SRT subtitle files using LLM APIs with OpenAI-compatible format.

Rating
3.9 (385 reviews)
Downloads
967 downloads
Version
1.0.0

Overview

Translate SRT subtitle files using LLM APIs with OpenAI-compatible format.

Key Features

1

Format Support: SRT subtitles

2

API Compatibility: OpenAI-compatible endpoints

3

Output Modes: Single-language or bilingual (translation above original)

4

Batch Processing: 50 sentences per batch (configurable) with 1-second intervals

5

Progress Tracking: Detailed logging of task progress and execution

6

Validation: Ensures sentence count consistency and timestamp preservation

Complete Documentation

View Source →

Subtitle Translator

Overview

Translate SRT subtitle files using LLM APIs. Supports OpenAI-compatible API format with customizable URL, API key, and model selection. Outputs single-language or bilingual subtitles with original timestamps preserved.

Features

  • Format Support: SRT subtitles
  • API Compatibility: OpenAI-compatible endpoints
  • Output Modes: Single-language or bilingual (translation above original)
  • Batch Processing: 50 sentences per batch (configurable) with 1-second intervals
  • Progress Tracking: Detailed logging of task progress and execution
  • Validation: Ensures sentence count consistency and timestamp preservation

Quick Start

Basic Translation

bash
python3 scripts/translate_srt.py \
  --input video.srt \
  --output video_zh.srt \
  --source-lang en \
  --target-lang zh \
  --api-url https://api.openai.com/v1 \
  --api-key sk-... \
  --model gpt-4

Bilingual Output

bash
python3 scripts/translate_srt.py \
  --input video.srt \
  --output video_bilingual.srt \
  --source-lang en \
  --target-lang zh \
  --bilingual \
  --api-url https://api.openai.com/v1 \
  --api-key sk-...

Validate SRT File

bash
python3 scripts/validate_srt.py input.srt

List Available Models

bash
python3 scripts/list_models.py \
  --api-url https://api.openai.com/v1 \
  --api-key sk-...

Configuration

Option 1: Environment Variables (Recommended)

bash
export SUBTITLE_API_URL="https://api.openai.com/v1"
export SUBTITLE_API_KEY="sk-your-api-key"
export SUBTITLE_MODEL="gpt-4"

python3 scripts/translate_srt.py -i input.srt -o output.srt

Option 2: Command Line Arguments

bash
python3 scripts/translate_srt.py \
  -i input.srt \
  -o output.srt \
  -u https://api.openai.com/v1 \
  -k sk-your-api-key \
  -m gpt-4

Option 3: Config File (Less Secure)

Create ~/.openclaw/skills/subtitle-translator/config.json:

json
{
  "api_url": "https://api.openai.com/v1",
  "api_key": "sk-your-api-key",
  "model": "gpt-4",
  "batch_size": 50,
  "batch_interval_ms": 1000,
  "output_mode": "single",
  "log_level": "info"
}

⚠️ Security Warning: Storing API keys in plaintext config files increases risk. Prefer environment variables or command line arguments.

Security Considerations

  • API Key Storage: Use environment variables or secure secret managers instead of plaintext config files
  • API Endpoint: Ensure you trust the API URL you provide
  • Proxy Environment: The scripts honor http_proxy/https_proxy environment variables. If your environment uses untrusted proxies, API keys could be captured
  • Network Traffic: All subtitle content is sent to the API endpoint. Do not use with sensitive/confidential content unless you control the API

Workflow

  • Parse SRT: Extract index, timecodes, and text
  • Validate: Optional validation of input format
  • Batch Translation: Send 50 sentences per request (configurable)
  • Validate: Ensure output count matches input
  • Reconstruct: Combine original timecodes with translations
  • Output: Generate SRT file

Resources

scripts/

  • translate_srt.py - Main translation script
  • list_models.py - List available models from API
  • validate_srt.py - Validate SRT file format

references/

  • srt_format.md - SRT file format specification

Installation

Terminal bash

openclaw install subtitle-translate-skill
    
Copied!

💻Code Examples

--api-key sk-...

---api-key-sk-.txt
## Configuration

### Option 1: Environment Variables (Recommended)

-m gpt-4

--m-gpt-4.txt
### Option 3: Config File (Less Secure)

Create `~/.openclaw/skills/subtitle-translator/config.json`:
example.sh
python3 scripts/translate_srt.py \
  --input video.srt \
  --output video_zh.srt \
  --source-lang en \
  --target-lang zh \
  --api-url https://api.openai.com/v1 \
  --api-key sk-... \
  --model gpt-4
example.sh
python3 scripts/translate_srt.py \
  --input video.srt \
  --output video_bilingual.srt \
  --source-lang en \
  --target-lang zh \
  --bilingual \
  --api-url https://api.openai.com/v1 \
  --api-key sk-...
example.sh
python3 scripts/list_models.py \
  --api-url https://api.openai.com/v1 \
  --api-key sk-...
example.sh
export SUBTITLE_API_URL="https://api.openai.com/v1"
export SUBTITLE_API_KEY="sk-your-api-key"
export SUBTITLE_MODEL="gpt-4"

python3 scripts/translate_srt.py -i input.srt -o output.srt
example.sh
python3 scripts/translate_srt.py \
  -i input.srt \
  -o output.srt \
  -u https://api.openai.com/v1 \
  -k sk-your-api-key \
  -m gpt-4
example.json
{
  "api_url": "https://api.openai.com/v1",
  "api_key": "sk-your-api-key",
  "model": "gpt-4",
  "batch_size": 50,
  "batch_interval_ms": 1000,
  "output_mode": "single",
  "log_level": "info"
}

Tags

#image_and-video-generation #api

Quick Info

Category Content Creation
Model GPT-4
Complexity One-Click
Author thetail001
Last Updated 3/10/2026
🚀
Optimized for
GPT-4

Ready to Install?

Get started with this skill in seconds

openclaw install subtitle-translate-skill