# Text to Speech API - Neural Voices, No API Key (`stas_k/text-to-speech-api`) Actor

Most text to speech actors cannot run without your own API key, and they bill every character they read. This one speaks inside the run: neural voices are baked into the image, no key is asked, and you pay only for a clip you can download.

- **URL**: https://apify.com/stas_k/text-to-speech-api.md
- **Developed by:** [Stas K](https://apify.com/stas_k) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 synthesized clips

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 - neural voices, no API key

Most text to speech actors on the store are wrappers over a paid cloud service: you
paste your own API key, you pay per character whether or not the file ever arrives,
and a rate limit on the other side decides how big your batch can be.

This actor speaks inside the run. A small neural voice set is baked into the image,
so there is no key to bring, no quota to hit and no third party that sees the text.
You pay only for a clip that really exists in the run store and can be downloaded.

### What you get

- One row per line of `texts`, with the text, the voice, the length in seconds and the
  key of the audio file.
- The audio itself in the default key-value store, plus one `clips.zip` with every
  clip of the run.
- Four voices in the image: `en-us-lessac`, `en-us-amy`, `ru-ru-irina`,
  `uk-ua-ukrainian`.
- `wav` or `mp3`, and a speed between 0.5 and 2.0.

### What you pay for

One event `clip-synthesized` per delivered clip. Everything else is free:

| Status | Meaning |
| --- | --- |
| `OK` | The clip was made and saved. This is the only billable status. |
| `NOT_CHECKED_BLANK` | The line is empty. |
| `NOT_CHECKED_DUPLICATE` | The same text with the same voice came earlier in the list. |
| `NOT_CHECKED_TOO_LONG` | The line is longer than `maxCharactersPerLine`. Nothing was synthesised. |
| `NOT_CHECKED_LIMIT` | The line is past `maxClips`. |
| `NOT_CHECKED_TIME` | The run was close to the platform deadline. |
| `NOT_CHECKED_CAP` | The spending cap was reached. |
| `NOT_CHECKED_BILLING` | The price could not be read, so nothing was made. |
| `NOT_CHECKED_STORE_ERROR` | The audio could not be saved, so the clip is not delivered. |
| `NOT_CHECKED_SYNTH_ERROR` | The engine could not speak this text. |
| `NOT_CHECKED_ERROR` | The run stopped on an unexpected error before this line. |

### What this actor does not do

- No voice cloning and no custom voice upload: the image carries four fixed voices.
- No language switching inside one clip: one voice speaks the whole line, so pass
  Russian text to a Russian voice.
- No sound effects, no music, no timestamps per word.
- The text is not translated. If the text does not match the voice, the audio is
  still produced and still billed, exactly like any other clip.

### Limits of the size

`maxCharactersPerLine` defaults to 5000 characters, and a longer line is refused
before anything is synthesised. A medium voice makes roughly ten seconds of audio
from 25 words, and the engine runs several times faster than real time on one core,
so a batch of ten short clips finishes in well under a minute.

# Actor input Schema

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

One piece of text per line. Each line becomes one audio clip.

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

Used only when the texts list is empty.

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

Neural voice baked into the image.

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

wav is uncompressed, mp3 is smaller. Both are made inside the image.

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

1.0 is the voice's natural speed, 0.5 is twice as slow, 2.0 twice as fast.

## `maxClips` (type: `integer`):

Lines past this limit are refused and free.

## `maxCharactersPerLine` (type: `integer`):

A longer line is refused before anything is synthesised, and it is free.

## Actor input object example

```json
{
  "texts": [
    "Welcome to the text to speech actor. Every line of this list becomes one audio clip.",
    "The second line is a separate clip, made by the same voice in the same run."
  ],
  "voice": "en-us-lessac",
  "format": "wav",
  "speed": 1,
  "maxClips": 10,
  "maxCharactersPerLine": 5000
}
```

# Actor output Schema

## `dataset` (type: `string`):

One row per line: the text, the voice, the length and the store key of the audio.

## `summary` (type: `string`):

Counters of the run, stored as RUN_SUMMARY-<runId> in the named store text-to-speech-api-summary.

# 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 text to speech actor. Every line of this list becomes one audio clip.",
        "The second line is a separate clip, made by the same voice in the same run."
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("stas_k/text-to-speech-api").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 text to speech actor. Every line of this list becomes one audio clip.",
        "The second line is a separate clip, made by the same voice in the same run.",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("stas_k/text-to-speech-api").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 text to speech actor. Every line of this list becomes one audio clip.",
    "The second line is a separate clip, made by the same voice in the same run."
  ]
}' |
apify call stas_k/text-to-speech-api --silent --output-dataset

```

## MCP server setup

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

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/dSr9Kfdl61eQLcqLG/builds/KxVssWnAB21HMbUg2/openapi.json
