# subtrans ***使用 OpenAI API 翻译字幕文件(SRT / VTT / ASS / LRC / SBV)*** ![Go Version](https://img.shields.io/badge/go-1.25%2B-blue) [![Go Report Card](https://goreportcard.com/badge/github.com/heartleo/subtrans)](https://goreportcard.com/report/github.com/heartleo/subtrans) [![CI](https://img.shields.io/github/actions/workflow/status/heartleo/subtrans/release.yml)](https://github.com/heartleo/subtrans/actions) [![Release](https://img.shields.io/github/v/release/heartleo/subtrans)](https://github.com/heartleo/subtrans/releases) [![Downloads](https://img.shields.io/github/downloads/heartleo/subtrans/total)](https://github.com/heartleo/subtrans/releases) ![License](https://img.shields.io/badge/license-MIT-green) [中文](README.md) | [English](README_en.md) ## 特性 - 支持多种字幕格式:**SRT**、**WebVTT**、**ASS/SSA**、**LRC**、**SBV** - 支持 OpenAI 兼容 API - 支持按句子边界智能分批 - 支持翻译缺失/合并自动重试 - 支持自定义翻译指令和提示词 - 支持原文与译文双语输出 - 支持作为 **命令行工具**、**Go 库** 使用 - 支持 HTTP API 及 SSE 流式输出 ## 安装 **Homebrew** (macOS / Linux): ```bash brew install heartleo/tap/subtrans ``` **curl** (macOS / Linux): ```bash curl -fsSL https://raw.githubusercontent.com/heartleo/subtrans/main/install.sh | sh ``` **Go install** (需要 Go 1.25+): ```bash go install github.com/heartleo/subtrans/cmd/subtrans@latest ``` **从源码编译:** ```bash git clone https://github.com/heartleo/subtrans cd subtrans go build -o subtrans ./cmd/subtrans ``` ## 快速开始 ### 命令行 ```bash # 创建env文件或设置环境变量 cat > .env <.<语言>.<原后缀>` | | `--model` | `-m` | 模型 | - | | `--max-batch-size` | | 每批行数 | `30` | | `--batch-split-punct` | | 分批切分标点符号 | `.` | | `--instructions` | | 指令文本文件路径 | - | | `--prompt` | | 自定义用户提示词 | - | | `--temperature` | | 温度 | `0.0` | | `--max-retries` | | API 失败重试次数 | `3` | | `--include-original` | | 输出中包含原文 | `false` | | `--strip-punctuation` | | 去除译文及原文(`--include-original` 时)尾部标点 | `true` | ### subtrans serve | 参数 | 缩写 | 说明 | 默认值 | | -------- | ---- | -------- | ----------- | | `--host` | | 监听地址 | `localhost` | | `--port` | `-p` | 监听端口 | `8091` | ---
Made with ❤️ by [heartleo](https://github.com/heartleo)