# Text to Speech (`hgservices/text-to-speech`) Actor

Turn any text into natural-sounding speech with AI voices in seconds. Powered by world class AI models, with multilingual voices and MP3, WAV, FLAC, Opus & AAC output. No setup or coding required.

- **URL**: https://apify.com/hgservices/text-to-speech.md
- **Developed by:** [Harish Garg](https://apify.com/hgservices) (community)
- **Categories:** AI, MCP servers, Agents
- **Stats:** 1 total users, 1 monthly users, 0.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.06 / 1,000 characters converted to speeches

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Text to Speech (Deepgram Aura)

**Text to Speech** converts any text into **natural-sounding speech audio** in seconds using **Deepgram's Aura-2** AI voice models. Paste in a sentence or a paragraph, pick a **voice** and an **audio format**, and get back a ready-to-play audio file — **MP3, WAV, FLAC, Opus, or AAC** — that you can download, stream, or drop straight into your apps and automations.

No servers, no audio engineering, and no separate voice-API account to manage. Running on the Apify platform gives you **API access, scheduling, monitoring, automatic retries**, and one-click integration into automation tools like **Make, Zapier, and n8n**.

### Why use Text to Speech?

- **Accessibility** — turn articles, docs, and notifications into audio people can listen to on the go.
- **Voiceovers & narration** — create natural voice tracks for videos, product demos, and e-learning courses.
- **IVR & voice notifications** — generate spoken prompts for phone systems, alerts, and voice assistants.
- **Content at scale** — batch-convert blog posts, newsletters, or scripts into audio automatically.
- **Fast prototyping** — hear how your copy sounds across many voices before you commit.

### How to use Text to Speech

1. Click **Try for free** and open the **Input** tab.
2. Paste the **text** you want to convert (up to 2,000 characters per run).
3. Choose a **voice** (e.g. *Aura 2 · Thalia*) and an **audio format** (MP3 by default).
4. Click **Start** and wait a few seconds.
5. Open the **Output** tab to **play and download** your audio file.

That's it — no setup, no API keys, no coding required.

### Input

Configure your run from the **Input** tab or via the API.

| Field    | Type              | Description                                                                     |
| -------- | ----------------- | ------------------------------------------------------------------------------- |
| `text`   | string (required) | The text to convert to speech. Up to 2,000 characters.                          |
| `model`  | string            | Aura-2 voice model — featured voices across English, Spanish, Dutch, French, German, Italian, and Japanese. Default `aura-2-thalia-en`. |
| `format` | string            | Output audio format: `mp3`, `wav`, `flac`, `opus`, or `aac`. Default `mp3`.     |
| `speed`  | string            | Speaking-rate multiplier (`1` = normal). Optional; not supported by all voices. |

Example input:

```json
{
    "text": "Welcome to our podcast. In today's episode, we explore how AI voices are changing the way we create and consume content.",
    "model": "aura-2-thalia-en",
    "format": "mp3"
}
```

### Output

Your generated audio file is saved and made available for download, along with a data record describing the run. You can export the data in **JSON, HTML, CSV, or Excel**.

Example output record:

```json
{
    "audioUrl": "https://api.apify.com/v2/key-value-stores/XXXX/records/audio-1784257804976.mp3",
    "audioKey": "audio-1784257804976.mp3",
    "text": "Welcome to our podcast. In today's episode...",
    "model": "aura-2-thalia-en",
    "format": "mp3",
    "characterCount": 118
}
```

#### Data table

| Field            | Description                                          |
| ---------------- | ---------------------------------------------------- |
| `audioUrl`       | Direct link to download the generated audio file.    |
| `audioKey`       | The name of the stored audio file.                   |
| `text`           | The input text that was converted.                   |
| `model`          | The voice used.                                      |
| `format`         | The audio format of the output file.                 |
| `characterCount` | Number of characters converted (used for billing).   |

### Pricing

This Actor uses Apify's **pay-per-event** pricing — you pay a small, predictable amount per run with **no separate voice-API bill to manage**:

| Charge | When it applies | What it covers |
| --- | --- | --- |
| **Run start** | Once per run | Starting the run and spinning up the audio generation. |
| **Characters converted** | Per run | The text-to-speech generation itself, billed per character of text. |

Because each run converts up to 2,000 characters, the cost per run is small and easy to predict. The exact prices are shown on this Actor's page in Apify Store, and **all voice-generation costs are already included** — you never need your own voice-API account.

New Apify users get free monthly usage credits to try the Actor at no cost.

### Tips & advanced options

- Keep each run under **2,000 characters**; split longer content into multiple runs.
- Choose `wav` or `flac` for lossless quality, or `mp3`/`aac`/`opus` for smaller files.
- Use the `speed` field to slow down or speed up narration where supported.
- **Automate at scale** by calling the Actor via the [Apify API](https://docs.apify.com/api/v2) or by scheduling recurring runs.

### FAQ and support

**Which languages are supported?** Aura-2 offers featured voices in English, Spanish, Dutch, French, German, Italian, and Japanese, with more added over time. Choose the `model` that matches your language.

**Is there a character limit?** Yes — up to 2,000 characters per run.

**What audio formats can I get?** MP3, WAV, FLAC, Opus, and AAC.

**Can I use the audio commercially?** Audio is generated with Deepgram's Aura-2 models; review Deepgram's terms for your specific use case.

Found a bug or have a feature request? Open an issue on this Actor's **Issues** tab. Custom voice or workflow needs can be accommodated on request.

# Actor input Schema

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

The plain text to convert into spoken audio (no SSML markup). Limited to 2000 characters per run — roughly a couple of minutes of speech. Longer input is rejected, so split large text into several runs.

## `model` (type: `string`):

The Deepgram Aura-2 voice used to generate the speech. The voice you pick also determines the spoken language and accent. Each option is labelled as Language, Accent, Gender, Age · Name. Featured voices cover English, Spanish, Dutch, French, German, Italian, and Japanese.

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

The file format of the generated audio. MP3 is the smallest and most widely compatible; WAV and FLAC are lossless (larger, best for editing); Opus is efficient for streaming; AAC works well for Apple and mobile playback.

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

Speaking rate multiplier that adjusts the pace of the generated speech (1 = normal). Deepgram Aura supports 0.7–1.5. For Spanish voices, keep it at 0.9 or above; lower values may introduce disfluencies.

## Actor input object example

```json
{
  "text": "Hi there, and thanks for stopping by! This is a quick demo of natural-sounding text to speech. Paste in your own script — a podcast intro, a voiceover, an audiobook chapter, or an IVR message — pick a voice, and you'll have a polished audio file in seconds.",
  "model": "aura-2-thalia-en",
  "format": "mp3",
  "speed": "1"
}
```

# Actor output Schema

## `audio` (type: `string`):

Generated audio files in the key-value store

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

Generated speech metadata with audio URLs

# 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": "Hi there, and thanks for stopping by! This is a quick demo of natural-sounding text to speech. Paste in your own script — a podcast intro, a voiceover, an audiobook chapter, or an IVR message — pick a voice, and you'll have a polished audio file in seconds."
};

// Run the Actor and wait for it to finish
const run = await client.actor("hgservices/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": "Hi there, and thanks for stopping by! This is a quick demo of natural-sounding text to speech. Paste in your own script — a podcast intro, a voiceover, an audiobook chapter, or an IVR message — pick a voice, and you'll have a polished audio file in seconds." }

# Run the Actor and wait for it to finish
run = client.actor("hgservices/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": "Hi there, and thanks for stopping by! This is a quick demo of natural-sounding text to speech. Paste in your own script — a podcast intro, a voiceover, an audiobook chapter, or an IVR message — pick a voice, and you'\''ll have a polished audio file in seconds."
}' |
apify call hgservices/text-to-speech --silent --output-dataset

```

## MCP server setup

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