# Text to Speech: bulk MP3 and WAV with subtitles (`examsens.ai/text-to-speech`) Actor

Turns lists of text or plain text files into natural sounding MP3 or WAV files in 41 voices and 7 languages, with optional SRT and VTT subtitles. The Kokoro voice model runs inside the actor; no outside service is called.

- **URL**: https://apify.com/examsens.ai/text-to-speech.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** AI, For creators
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $60.00 / 1,000 1,000 characters synthesizeds

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: bulk MP3 and WAV with subtitles

Give it a list of texts, or links to plain text files, and it returns one audio file per text, with SRT and VTT subtitles timed to the speech.

The voice model is Kokoro-82M, released under the Apache 2.0 license \[1]. It runs inside the actor on the CPU. No outside speech service is called and no API key is needed.

### Voices and languages

41 voices in 7 languages: American English (20 voices), British English (8), Spanish (3), French (1), Hindi (4), Italian (2) and Brazilian Portuguese (3). The voice you pick sets the language the text is read in, so write the text in that language. A French text read by an English voice comes out with English pronunciation. Japanese and Mandarin voices are left out, since they misread written Japanese and Chinese characters.

### Input

- Texts: one audio file per text, up to 100,000 characters each
- Plain text file URLs: `.txt` links up to 5 MB, one audio file per link
- Voice (default `af_heart`, American English)
- Speed from 0.5 to 2.0 (default 1.0)
- Audio format: MP3 (default) or WAV (16 bit, 24 kHz)
- SRT and VTT subtitles (default on): one cue per sentence, or per group of short sentences
- Pause between sentences in milliseconds (default 250)
- Also join all texts into one file (default off)

Long texts are split into sentences, short sentences are grouped, and each group is voiced on its own.

### Output

Dataset: one item per text with `index`, `source` (`input` or the file link), `ok`, `voice`, `speed`, `format`, `characters`, `textPreview`, `durationSeconds`, `fileSizeBytes`, `audioUrl`, and with subtitles on, `subtitles` (each cue with `start`, `end` and `text`), `srtUrl` and `vttUrl`. The files are saved in the run's key-value store as `speech-0001.mp3`, `speech-0001.srt` and so on. With joining on, one more item with `source: combined` links to `combined.mp3` and its subtitles. A text that cannot be voiced gets `ok: false` and an `error`, and the run carries on with the next one.

### Speed

Apify gives a run one CPU core for every 4 GB of memory \[2], so speed follows the memory you choose. With 2 GB, a run that voiced 3,348 characters (3 minutes 23 seconds of audio) took 8 minutes 21 seconds.

### Pricing

Pay per event: one event per started 1,000 characters of each text. A 1,200 character text is two events. A text that fails is not charged. A text is left unprocessed, with an error saying so, when the maximum charge you set does not cover it.

### Scope and conduct

The actor reads only the texts and links you supply. Use text you have the right to turn into audio.

### Support

Questions and problems: the Issues tab on this page.

### References

1. hexgrad/Kokoro-82M · Hugging Face | Kokoro-82M | huggingface.co. https://huggingface.co/hexgrad/Kokoro-82M
2. Actor usage and resources | Apify documentation | docs.apify.com. https://docs.apify.com/platform/actors/running/usage-and-resources

# Actor input Schema

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

One audio file per text, up to 100,000 characters each.

## `textFileUrls` (type: `array`):

Links to plain text (.txt) files, up to 5 MB each. Each file becomes one audio file.

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

The voice also sets the language the text is read in. Write the text in that language.

## `speed` (type: `number`):

1.0 is normal speed. From 0.5 (slow) to 2.0 (fast).

## `format` (type: `string`):

Format of the audio files.

## `subtitles` (type: `boolean`):

Save a subtitle file in both formats next to each audio file, one cue per sentence or group of short sentences.

## `pauseMs` (type: `integer`):

Silence added between sentences.

## `combineAudio` (type: `boolean`):

Save one extra audio file (and subtitles) with every text in order, half a second apart or more.

## Actor input object example

```json
{
  "texts": [
    "Welcome to the show. This voice was generated from plain text in a few seconds.",
    "Here is a second clip. Every text in the list becomes its own audio file."
  ],
  "voice": "af_heart",
  "speed": 1,
  "format": "mp3",
  "subtitles": true,
  "pauseMs": 250,
  "combineAudio": false
}
```

# Actor output Schema

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

No description

# 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 the show. This voice was generated from plain text in a few seconds.",
        "Here is a second clip. Every text in the list becomes its own audio file."
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/text-to-speech").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 the show. This voice was generated from plain text in a few seconds.",
        "Here is a second clip. Every text in the list becomes its own audio file.",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/text-to-speech").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 the show. This voice was generated from plain text in a few seconds.",
    "Here is a second clip. Every text in the list becomes its own audio file."
  ]
}' |
apify call examsens.ai/text-to-speech --silent --output-dataset

```

## MCP server setup

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

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/htS3DnLZxuios0njd/builds/2k8phLkA7bAbUeHcg/openapi.json
