# Text to Speech / Voiceover (Piper) (`gramsesh/text-to-speech`) Actor

Turn text into an MP3 or WAV voiceover with a small open Piper voice, running on this Actor's CPU. Stock voices only, no cloning. Rejected texts (hate, minors, impersonation, automaker/EV/energy/robotics themes) are free. Up to 3,000 characters per text and per run.

- **URL**: https://apify.com/gramsesh/text-to-speech.md
- **Developed by:** [Gramsesh](https://apify.com/gramsesh) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.80 / 1,000 1,000 characters spoken

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/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 / Voiceover (Piper)

This Actor turns text into an MP3 or WAV voiceover with a small open Piper ONNX voice (`en_US-joe-medium`) running on this Actor's CPU. The voice is baked into the image from a public Hugging Face snapshot at build time.

**Limit: 3,000 characters per run** (and per text). Split longer scripts into separate runs.

This is not a like-for-like match for ElevenLabs or a cloud neural voice.

### Isolation

Synthesis runs entirely inside your Actor run. Output is written only to this run's default key-value store and default dataset. The Actor does not send your text or audio to Gramsesh, Cloudflare, or any other account of ours. It does not call Cloudflare, Workers AI, or a hosted TTS API at runtime. Logs record lengths and counts, never the source text.

### Input

- `text` — one script, up to 3,000 characters.
- `texts` — a batch of scripts. The whole run may speak at most 3,000 characters. Split longer jobs into another run.
- `voice` — a stock Piper voice (default `en_US-joe-medium`, American English, CC0 training chain). `en_US-lessac-*` is not offered: those recordings are research-only.
- `format` — `mp3` (default) or `wav`.
- `speed` — 0.5 to 2.0, default 1.0.

Rejected texts are free: sexual content, anything involving minors, impersonation of a real person (including "say this as X" or a named celebrity/politician voice), hate, graphic violence, self-harm, and automaker / EV / battery / energy / autonomy / robotics / AI-chip themes.

### Output

Each successful item is a file in the run's default key-value store and a dataset row with the URL, character count, duration, voice, and file size. Finished audio is appended on disk and uploaded as it is produced, so a timeout can still leave a usable partial file and is charged only for the characters that were stored.

### Pricing

$0.0038 per started 1,000 input characters, rounded up, charged only after a non-empty audio file is stored, plus a $0.00005 start fee per GB of memory (one event at the 512 MB default). A 1,000-character success lists at $0.00385; a 3,000-character success lists at $0.01145. Failures and rejected texts are free. A timeout that still stores a usable file is charged only for the characters actually spoken.

### Licence

Inference uses onnxruntime and espeak-ng via phonemizer / espeakng-loader. The Actor does **not** bundle or import `piper-tts` (GPL-3.0-or-later). The `en_US-joe-medium` voice is on Piper's commercial-use list: the voice dataset is CC0 and it was retrained from the rdh base (also CC0). See `licenses/`.

### Support

Questions or issues: <chris@gramsesh.com>.

# Actor input Schema

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

One script to narrate, up to 3,000 characters. Use texts for a batch (up to 3,000 characters in the whole run). Sexual content, minors, impersonation of real people, hate, graphic violence, and automaker/EV/energy/robotics themes are refused, with no charge.

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

Optional list of scripts. Each item should be an object with a text field and optional voice, format, and speed. A JSON list of strings is also accepted. The run cap is 3,000 characters in total.

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

A stock Piper voice. Default is en_US-joe-medium (American English, CC0 training chain). Custom or cloned voices are not supported. en_US-lessac voices are not offered because their recordings are research-only.

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

Audio file written to the key-value store.

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

Speaking speed from 0.5 (slower) to 2.0 (faster). Default 1.0.

## Actor input object example

```json
{
  "text": "Welcome to the weekly bakery newsletter. This morning we baked sourdough, citrus glaze, and a simple apple tart.",
  "voice": "en_US-joe-medium",
  "format": "mp3",
  "speed": 1
}
```

# Actor output Schema

## `audio` (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 = {
    "text": "Welcome to the weekly bakery newsletter. This morning we baked sourdough, citrus glaze, and a simple apple tart.",
    "voice": "en_US-joe-medium",
    "format": "mp3"
};

// Run the Actor and wait for it to finish
const run = await client.actor("gramsesh/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 = {
    "text": "Welcome to the weekly bakery newsletter. This morning we baked sourdough, citrus glaze, and a simple apple tart.",
    "voice": "en_US-joe-medium",
    "format": "mp3",
}

# Run the Actor and wait for it to finish
run = client.actor("gramsesh/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 '{
  "text": "Welcome to the weekly bakery newsletter. This morning we baked sourdough, citrus glaze, and a simple apple tart.",
  "voice": "en_US-joe-medium",
  "format": "mp3"
}' |
apify call gramsesh/text-to-speech --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gramsesh/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/YV5AjikITpMYH3345/builds/xAwhHTp9oZNMxP8Sl/openapi.json
