← 返回
数据分析 Key 中文

Subtitle Translator

Translate SRT subtitle files using LLM APIs with OpenAI-compatible format. Supports both single-language and bilingual output. Use when you need to translate...
利用兼容 OpenAI 格式的 LLM API 翻译 SRT 字幕文件,支持单语及双语输出。需翻译...时使用。
thetail001
数据分析 clawhub v0.1.1 1 版本 99917.3 Key: 需要
★ 0
Stars
📥 1,208
下载
💾 34
安装
1
版本
#latest

概述

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

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

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

python3 scripts/validate_srt.py input.srt

List Available Models

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

Configuration

Option 1: Environment Variables (Recommended)

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

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:

{
  "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

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

Workflow

  1. Parse SRT: Extract index, timecodes, and text
  2. Validate: Optional validation of input format
  3. Batch Translation: Send 50 sentences per request (configurable)
  4. Validate: Ensure output count matches input
  5. Reconstruct: Combine original timecodes with translations
  6. 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

版本历史

共 1 个版本

  • v0.1.1 当前
    2026-03-29 12:40 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Stock Analysis

udiedrichsen
{"answer":"基于雅虎财经数据,分析股票与加密货币。支持投资组合管理、自选股预警、股息分析、8维评分、热门趋势扫描及传闻/早期信号探测。适用于股票分析、持仓追踪、财报异动、加密监控、热门股追踪或提前发掘非主流传闻。"}
★ 270 📥 57,034
data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 166 📥 60,261
data-analysis

Data Analysis

ivangdavila
{"answer":"数据分析与可视化。查询数据库、生成报告、自动化电子表格,将原始数据转化为清晰可行的见解。适用于:(1) 您……"}
★ 199 📥 65,266