# AiSrt by Digital3d.com

A command-line tool to **translate**, **extract**, and **transcribe** subtitles using AI.

AiSrt is a .NET 8.0 console application that translates `.srt` subtitle files via the OpenAI API, extracts subtitle tracks from video files using ffmpeg, and transcribes audio to `.srt` using whisper.cpp.

## Features

- **Translate** — Translate `.srt` subtitle files between 29 languages using the OpenAI API with context-aware, idiomatic translations
- **Extract** — Extract embedded subtitle tracks from video files (MKV, MP4, etc.) using ffmpeg
- **Transcribe** — Transcribe audio from video files to `.srt` subtitles using whisper.cpp with automatic GPU detection

## Supported Languages (29)

Arabic, Chinese, Czech, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Romanian, Russian, Spanish, Swedish, Thai, Turkish, Ukrainian, Vietnamese

## Prerequisites

- **For translation:** An OpenAI API key
- **For extraction:** ffmpeg (auto-downloaded if missing)
- **For transcription:** whisper.cpp (auto-downloaded if missing), ffmpeg

## Installation

Download the latest release for your platform:

| Platform | File |
|----------|------|
| Windows x64 | `AiSrt-v{version}-win-x64.zip` |
| Linux x64 | `AiSrt-v{version}-linux-x64.zip` |
| macOS x64 (Intel) | `AiSrt-v{version}-osx-x64.zip` |
| macOS ARM64 (Apple Silicon) | `AiSrt-v{version}-osx-arm64.zip` |

### Windows

Extract the ZIP and run the installer:

```powershell
.\install.ps1
```

This copies `aisrt.exe` and `appsettings.json` to `%LOCALAPPDATA%\AiSrt` and adds it to your PATH.

### Linux / macOS

Extract the ZIP and run the installer:

```bash
chmod +x install.sh
sudo ./install.sh
```

This copies `aisrt` to `/usr/local/bin/` and `appsettings.json` to `~/.config/aisrt/`.

## Usage

```bash
# Translate subtitles (English to French by default)
aisrt "movie.srt"

# Translate English to Spanish
aisrt "movie.srt" -s en -t es

# Show all supported languages
aisrt --languages

# List subtitle streams in a video file
aisrt --streams "movie.mkv"

# Extract subtitles from a video file (interactive selection)
aisrt --extract "movie.mkv"

# Transcribe audio to .srt using whisper.cpp
aisrt --transcribe "movie.mkv"
```

## Configuration

Edit `appsettings.json` to configure:

- **OpenAI API key** — Set your key in `OpenAI:ApiKey` or use a `.env` file
- **Model** — Change the OpenAI model (default: `gpt-5-mini`)
- **Batch size** — Number of subtitle blocks per API call (default: 40)
- **Translation prompts** — Customize the system and user prompts for translation
- **Default languages** — Set default source/target languages

## CLI Reference

```
aisrt <file> [options]

Arguments:
  <file>    Path to .srt file or video file

Options:
  -t, --target <code>    Target language code [default: fr]
  -s, --source <code>    Source language code [default: en]
  --languages            Show all supported languages
  --streams              List subtitle streams in a video file
  --extract              Extract subtitle tracks from a video file
  --transcribe           Transcribe audio to .srt using whisper.cpp
  --version              Show version
  -h, --help             Show help
```

## License

MIT
Digital3d.com
