# subtrans ***Translate subtitle files (SRT / VTT / ASS / LRC / SBV) using OpenAI API*** ![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) ## Features - Multiple subtitle formats: **SRT**, **WebVTT**, **ASS/SSA**, **LRC**, **SBV** - Works with any OpenAI-compatible API - Smart batch splitting by sentence boundaries - Automatic retry for missing or merged translations - Customizable translation instructions and prompts - Bilingual output (original + translated text) - Use as a **CLI tool** or **Go library** - HTTP API with SSE streaming support ## Installation **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** (requires Go 1.25+): ```bash go install github.com/heartleo/subtrans/cmd/subtrans@latest ``` **Build from source:** ```bash git clone https://github.com/heartleo/subtrans cd subtrans go build -o subtrans ./cmd/subtrans ``` ## Quick Start ### CLI ```bash # Create env file or set environment variables cat > .env <..` | | `--model` | `-m` | Model | - | | `--max-batch-size` | | Lines per batch | `30` | | `--batch-split-punct` | | Punctuation for splitting | `.` | | `--instructions` | | Path to instructions file | - | | `--prompt` | | Custom user prompt | - | | `--temperature` | | Temperature | `0.0` | | `--max-retries` | | API retry count | `3` | | `--include-original` | | Include original text in output | `false` | | `--strip-punctuation` | | Strip trailing punctuation from translation and original text | `true` | ### subtrans serve | Flag | Short | Description | Default | | -------- | ----- | ----------- | ----------- | | `--host` | | Listen host | `localhost` | | `--port` | `-p` | Listen port | `8091` | ---
Made with ❤️ by [heartleo](https://github.com/heartleo)