# Text to Speech API — Batch, 30+ Languages, Pay per Character (`sherwood/text-to-speech-batch`) Actor

Text-to-speech (TTS) API: turn one or many texts into MP3 or WAV voiceover files and get, for each text, a dataset item with the audio URL, duration and character count. English, French, Spanish, German and 30+ languages, auto-detected. No API key, pay per character.

- **URL**: https://apify.com/sherwood/text-to-speech-batch.md
- **Developed by:** [Sherwood](https://apify.com/sherwood) (community)
- **Categories:** AI, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 100 characters, standard voices

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

## Text to Speech API — batch, 30+ languages, pay per character

Give it one text or a thousand, get one voice-over file per text (MP3 or WAV), one dataset item per text: the audio URL, its duration, the character count, or a clear error. English runs on Kokoro (fast, cheap); French, Spanish, German, Japanese and 30+ other languages run on MiniMax Speech 2.8 with natural voices. Language is detected automatically. No API key, no subscription. **From $0.05 per 1,000 characters**, failures are free.

Built for automation and AI agents: every input alias is accepted (`texts`, `text`, `prompts`, `prompt`, `sentences`), nothing is required, and the default input runs on its own so you can see the output shape before sending your own texts.

### What you get

One item per text, in your dataset:

```json
{
  "index": 1,
  "text": "Bienvenue dans notre boutique. Votre commande a été expédiée.",
  "characters": 61,
  "outputUrl": "https://api.apify.com/v2/key-value-stores/abc123/records/speech-0001.mp3",
  "durationMs": 4310,
  "format": "mp3",
  "language": "French",
  "voice": "Calm_Woman",
  "model": "fal-ai/minimax/speech-2.8-turbo",
  "processingMs": 3800,
  "status": "ok",
  "error": null
}
```

A text that fails (empty, over 5,000 characters, model error) comes back with `"status": "error"` and the reason in `error`. It is never charged.

### Use cases

- Voice product descriptions, notifications or order updates in the customer's language.
- Turn articles, scripts or lessons into audio versions in bulk.
- Generate voice-overs for short videos from a content calendar.
- Give an AI agent a single call that turns a list of lines into a list of audio files.

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `texts` | array | two sample sentences | Up to 5,000 characters each. For a single text, use `text`. |
| `text`, `prompts`, `prompt`, `sentences` | aliases | — | Merged with `texts`. |
| `language` | `auto` or a language name | `auto` | Detected per text when auto. English uses the standard model; other languages always use premium. |
| `voice` | `female`, `male`, or a model voice id | `female` | Kokoro ids (`af_heart`, `am_michael`…) for English standard; MiniMax ids (`Wise_Woman`, `Deep_Voice_Man`, `Friendly_Person`…) for premium. |
| `quality` | `standard`, `premium` | `standard` | premium forces MiniMax for every text, with pauses `<#1.5#>` and tags like `(laughs)`. |
| `speed` | 0.5 to 2.0 | `1.0` | |
| `outputFormat` | `mp3`, `wav` | `mp3` | Standard (Kokoro) always returns WAV; premium returns MP3. |
| `maxTexts` | integer | `200` | Stop after this many texts. |

Minimal call:

```json
{ "texts": ["Your package has been delivered.", "Votre colis a été livré."] }
```

### Languages

36 languages: English, French, Spanish, German, Italian, Portuguese, Dutch, Polish, Russian, Turkish, Arabic, Hindi, Japanese, Korean, Chinese (Mandarin), Cantonese, Indonesian, Malay, Vietnamese, Thai, Swedish, Danish, Norwegian, Finnish, Greek, Czech, Slovak, Romanian, Hungarian, Ukrainian, Bulgarian, Croatian, Slovenian, Catalan, Hebrew, Afrikaans. Each text is detected on its own when `language` is `auto`; Malay and Cantonese must be forced, because detection cannot tell them apart from Indonesian and Mandarin. A language detected outside this list is still voiced by the premium model, which then detects it itself. Close languages can be confused (Croatian is often detected as Slovenian): force `language` when you know it.

### Pricing

Charged per started 100 characters of text actually voiced:

- **Standard (English, Kokoro)** — $0.005 per 100 characters, i.e. $0.05 per 1,000.
- **Premium (any language, MiniMax)** — $0.012 per 100 characters, i.e. $0.12 per 1,000.
- Failed texts: free.

Set a maximum cost per run in Apify and the Actor stops cleanly when it is reached; remaining texts are reported, not processed.

### Via API, n8n, Make or MCP

Call it like any Apify Actor: `POST https://api.apify.com/v2/actors/sherwood~text-to-speech-batch/run-sync-get-dataset-items` with the JSON input above, or add it as a tool through the Apify MCP server. Results are plain dataset items, so `get-dataset-items` returns the URLs directly.

### Limits

- 5,000 characters per text; split longer scripts into paragraphs (one item each).
- Generation is typically 3 to 8 seconds per text; the standard model can take longer on its first call of a run while it warms up. 4 texts are processed in parallel.
- Output files live in the run's key-value store and follow your account's data retention.

# Actor input Schema

## `texts` (type: `array`):

Texts to turn into speech, as a list, up to 5,000 characters each. One dataset item is returned per text, with an index matching the input order. For a single text, use text instead. Aliases merged into this list: text, prompts, prompt, sentences.

## `text` (type: `string`):

A single text, voiced as one audio file. Merged with texts.

## `prompts` (type: `array`):

Alias of texts.

## `sentences` (type: `array`):

Alias of texts.

## `language` (type: `string`):

Language of the texts: auto detects it per text (recommended for mixed batches), or force one of 36 languages. English uses the fast model by default; every other language uses the premium multilingual model. Malay and Cantonese must be forced; a detected language outside the list is voiced by the premium model with its own detection.

## `voice` (type: `string`):

female or male picks a natural default voice for the model in use. You can also pass an explicit voice id: Kokoro ids (af_heart, af_bella, am_michael, am_adam…) for English standard quality, MiniMax ids (Wise_Woman, Calm_Woman, Friendly_Person, Deep_Voice_Man, Patient_Man, Casual_Guy, Lively_Girl, Elegant_Man…) for premium.

## `quality` (type: `string`):

standard: Kokoro, fast and cheap, English only (other languages are automatically switched to premium). premium: MiniMax Speech 2.8, natural voices in 30+ languages, supports pauses like <#1.5#> and tags like (laughs).

## `speed` (type: `string`):

Speech speed multiplier, 0.5 to 2.0. 1.0 is natural.

## `outputFormat` (type: `string`):

mp3 is the default for premium. The standard model always returns WAV.

## `maxTexts` (type: `integer`):

Stop after this many texts. Protects against oversized lists. Default 200.

## Actor input object example

```json
{
  "texts": [
    "Welcome to our store. Your order has shipped and should arrive within three business days.",
    "Bienvenue dans notre boutique. Votre commande a été expédiée et arrivera sous trois jours ouvrés."
  ],
  "language": "auto",
  "voice": "female",
  "quality": "standard",
  "speed": "1.0",
  "outputFormat": "mp3",
  "maxTexts": 200
}
```

# Actor output Schema

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

One item per text: text, characters, outputUrl (the audio file), durationMs, format, language, voice, status and error. Sort by index to match the input order.

## `files` (type: `string`):

The audio files (MP3 or WAV) referenced by outputUrl.

# 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 = {
    "texts": [
        "Welcome to our store. Your order has shipped and should arrive within three business days.",
        "Bienvenue dans notre boutique. Votre commande a été expédiée et arrivera sous trois jours ouvrés."
    ],
    "language": "auto",
    "voice": "female",
    "quality": "standard",
    "speed": "1.0",
    "outputFormat": "mp3",
    "maxTexts": 200
};

// Run the Actor and wait for it to finish
const run = await client.actor("sherwood/text-to-speech-batch").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 = {
    "texts": [
        "Welcome to our store. Your order has shipped and should arrive within three business days.",
        "Bienvenue dans notre boutique. Votre commande a été expédiée et arrivera sous trois jours ouvrés.",
    ],
    "language": "auto",
    "voice": "female",
    "quality": "standard",
    "speed": "1.0",
    "outputFormat": "mp3",
    "maxTexts": 200,
}

# Run the Actor and wait for it to finish
run = client.actor("sherwood/text-to-speech-batch").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 '{
  "texts": [
    "Welcome to our store. Your order has shipped and should arrive within three business days.",
    "Bienvenue dans notre boutique. Votre commande a été expédiée et arrivera sous trois jours ouvrés."
  ],
  "language": "auto",
  "voice": "female",
  "quality": "standard",
  "speed": "1.0",
  "outputFormat": "mp3",
  "maxTexts": 200
}' |
apify call sherwood/text-to-speech-batch --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,sherwood/text-to-speech-batch"
        }
    }
}
```

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/QWmUEeCGEuPop04Rb/builds/a2eYBiwrN76edqjvt/openapi.json
