# Subtitle Translate (`eloquent_mountain/subtitle-translate`) Actor

Translate an SRT or WebVTT file so every cue meets your CPS and line-length spec, with a review list.

- **URL**: https://apify.com/eloquent_mountain/subtitle-translate.md
- **Developed by:** [Paco](https://apify.com/eloquent_mountain) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Subtitle Translate

Translate an SRT or WebVTT file so every cue meets your CPS and line-length spec, with a review list.

### Who it's for

Video producers, e-learning teams and agencies localising a 10-60 minute video into several languages, who today fix over-speed subtitle cues by hand.

### What you get

Your SRT or WebVTT file translated into one language and returned in the same format, with every cue inside your spec for characters per second, characters per line and lines per cue (defaults 17 cps, 42 per line, 2 lines); cues shorter than the minimum duration (default 833 ms) are flagged or, on request, lengthened. Cue count, ids, timings, markup tags and WebVTT notes and settings are kept; line breaks are set for you.

Cues that overflowed after translation are shortened and listed as condensed, with their speed before and after. Cues that could only be cut are listed as lossy for review. The returned file is re-parsed and measured, so the report describes the file you receive, with a metrics line for every cue. A file that needs more than 10 percent of its cues cut is an error and is not charged. A second tool measures any subtitle file against a spec without translating it.

### Example

"Translate this English SRT of our 24-minute training video into German, French and Dutch at max 17 characters per second and 42 characters per line, and tell me which cues you had to condense."

### Limits

- SRT or WebVTT text, up to 1000 cues and 200000 characters; one target language per call, so three languages are three calls.
- Cue start and end times are never changed unless you ask for short cues to be lengthened. Source cues below the minimum duration are flagged.
- Subtitle text is processed in memory by Google Gemini; nothing is stored.

### How to use

- **Run it** in Apify Console or through the API: choose what to do, fill in the fields for that tool and start. The result is one item in the run's dataset.
- **From an AI assistant** through Apify's MCP server (mcp.apify.com), which finds and runs this Actor with the same fields. What each choice does:
  - `translate_subtitles`: Translate one SRT or WebVTT file into one target language and return a file in the same format in which every cue meets the spec for characters per second, characters per line and lines per cue; source cues shorter than the minimum duration are flagged (or lengthened on request), never silently moved.
  - `check_subtitle_spec`: Measure an SRT or WebVTT file against a reading-speed and layout spec without translating it.

### Pricing

- Translate subtitles to fit a spec: $0.24
- Block of 50 subtitle cues: $0.24
- Check subtitles against a spec: $0.059

Failed calls are never charged.

# Actor input Schema

## `tool` (type: `string`):

translate_subtitles: Translate one SRT or WebVTT file into one target language and return a file in the same format in which every cue meets the spec for characters per second, characters per line and lines per cue; source cues shorter than the minimum duration are flagged (or lengthened on request), never silently moved. check_subtitle_spec: Measure an SRT or WebVTT file against a reading-speed and layout spec without translating it.

## `file_text` (type: `string`):

The whole SRT or WebVTT file as text, up to 1000 cues. Used by: translate_subtitles, check_subtitle_spec.

## `source_language` (type: `string`):

Language of the file, e.g. Used by: translate_subtitles.

## `target_language` (type: `string`):

One language to translate into, e.g. Used by: translate_subtitles.

## `max_cps` (type: `number`):

Most characters per second per cue. Used by: translate_subtitles, check_subtitle_spec.

## `max_chars_per_line` (type: `integer`):

Most visible characters on one line. Used by: translate_subtitles, check_subtitle_spec.

## `max_lines` (type: `integer`):

Most lines per cue. Used by: translate_subtitles, check_subtitle_spec.

## `min_duration_ms` (type: `integer`):

Shortest allowed cue, in milliseconds. Used by: translate_subtitles, check_subtitle_spec.

## `extend_short_cues` (type: `boolean`):

Lengthen cues shorter than the minimum when the gap allows it. Used by: translate_subtitles.

## Actor input object example

```json
{
  "tool": "check_subtitle_spec",
  "file_text": "1\n00:00:01,500 --> 00:00:02,500\n<i>Tonight's the night.</i>\n\n2\n00:00:03,000 --> 00:00:15,000\n<i>And it's going to happen\nagain and again --</i>\n",
  "max_cps": 17,
  "max_chars_per_line": 42,
  "max_lines": 2,
  "min_duration_ms": 833,
  "extend_short_cues": false
}
```

# Actor output Schema

## `results` (type: `string`):

The tool result as a dataset item, shown in the overview view.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "file_text": `1
00:00:01,500 --> 00:00:02,500
<i>Tonight's the night.</i>

2
00:00:03,000 --> 00:00:15,000
<i>And it's going to happen
again and again --</i>`
};

// Run the Actor and wait for it to finish
const run = await client.actor("eloquent_mountain/subtitle-translate").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "file_text": """1
00:00:01,500 --> 00:00:02,500
<i>Tonight's the night.</i>

2
00:00:03,000 --> 00:00:15,000
<i>And it's going to happen
again and again --</i>
""" }

# Run the Actor and wait for it to finish
run = client.actor("eloquent_mountain/subtitle-translate").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "file_text": "1\\n00:00:01,500 --> 00:00:02,500\\n<i>Tonight'\''s the night.</i>\\n\\n2\\n00:00:03,000 --> 00:00:15,000\\n<i>And it'\''s going to happen\\nagain and again --</i>\\n"
}' |
apify call eloquent_mountain/subtitle-translate --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eloquent_mountain/subtitle-translate"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/GNxRkCLOIhEuXK0Zt/builds/HsvSy5QFKzEBXrAHh/openapi.json
