---
title: Convert Text to Speech API
slug: convert-text-to-speech
url: https://apyhub.com/apyhub/service/convert-text-to-speech
provider: ApyHub
categories: [Audio Processing, File Conversion, Smart Generation]
auth: api_key
version: 1.0.0
service_type: sync
endpoints: 6
atoms: 750
mcp: true
alias: text-to-speech
---

# Convert Text to Speech API

Convert text, file uploads, or document URLs into MP3 audio. Returns a binary download or a signed link, with male or female voice selection.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/tts/file` | What it does Uploads a document file and a selected voice gender, then returns the generated MP3 au… | 750 |
| POST | `https://api.eu.apyhub.com/tts/file/url` | What it does Converts the text content from an uploaded document into speech and returns a signed M… | 750 |
| POST | `https://api.eu.apyhub.com/tts/text/file` | What it does Converts the provided text into an MP3 file download. You send the text and a voice ge… | 750 |
| POST | `https://api.eu.apyhub.com/tts/text/url` | What it does Converts the submitted JSON text into a speech audio file and returns a signed MP3 lin… | 750 |
| POST | `https://api.eu.apyhub.com/tts/url/file` | What it does Converts the text content of a document available at a URL into an MP3 audio file. The… | 750 |
| POST | `https://api.eu.apyhub.com/tts/url` | What it does Extracts text from a document URL and returns a signed MP3 link. You send a document u… | 750 |

## Endpoint reference

### Extract text from uploaded document and return MP3

`POST https://api.eu.apyhub.com/tts/file` · 750 atoms · accepts `multipart/form-data` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `file` | body | string (binary) | yes |  |
| `gender` | body | string | yes | One of: male, female. Example: `male`. |

#### Quickstart

Upload a text file and choose a voice gender to generate speech.

```bash
curl -X POST "https://api.eu.apyhub.com/tts/file" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/input.txt" \
  -F "gender=male"
```

#### What you'll get back

Returns a binary file response containing the generated audio.

### Extract text from uploaded document and return signed MP3 link

`POST https://api.eu.apyhub.com/tts/file/url` · 750 atoms · accepts `multipart/form-data` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `file` | body | string (binary) | yes |  |
| `gender` | body | string | yes | One of: male, female. |

#### Quickstart

Convert a file to speech by uploading the file and choosing a voice gender.

```bash
curl -X POST "https://api.eu.apyhub.com/tts/file/url" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/audio-or-text-file" \
  -F "gender=male"
```

#### What you'll get back

Returns a JSON object with a `data` string field.

```json
{
  "data": "https://example.com/generated-audio.mp3"
}
```

### Convert JSON text to MP3 download

`POST https://api.eu.apyhub.com/tts/text/file` · 750 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `text` | body | string | yes | Example: `Hello world, this is a sample speech synthesis request.`. |
| `gender` | body | string | yes | One of: male, female. Example: `female`. |

#### Quickstart

Send text and a gender to generate speech audio from the supplied text.

```bash
curl -X POST "https://api.eu.apyhub.com/tts/text/file" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text":"Hello world, this is a sample speech synthesis request.","gender":"female"}'
```

#### What you'll get back

Returns binary audio data (`string` with `binary` format), not a JSON object.

```text
(binary audio file)
```

### Convert JSON text to signed MP3 link

`POST https://api.eu.apyhub.com/tts/text/url` · 750 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `text` | body | string | yes | Example: `Hello world, this is a sample speech synthesis request.`. |
| `gender` | body | string | yes | One of: male, female. Example: `female`. |

#### Quickstart

Send the text and voice gender to generate a speech synthesis link.

```bash
curl -X POST "https://api.eu.apyhub.com/tts/text/url" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello world, this is a sample speech synthesis request.",
    "gender": "female"
  }'
```

#### What you'll get back

Returns a JSON object with a `data` string field containing the generated audio link.

```json
{
  "data": "https://..."
}
```

### Extract text from document URL and return MP3

`POST https://api.eu.apyhub.com/tts/url/file` · 750 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `url` | body | string (uri) | yes | Example: `https://assets.apyhub.com/samples/sample.pdf`. |
| `gender` | body | string | yes | One of: male, female. Example: `female`. |

#### Quickstart

Convert a file from a URL into speech by sending the file URL and voice gender.

```bash
curl -X POST "https://api.eu.apyhub.com/tts/url/file" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://assets.apyhub.com/samples/sample.pdf",
    "gender": "female"
  }'
```

#### What you'll get back

Returns a binary file (`string` with `format: binary`) containing the generated audio.

```text
(binary audio file)
```

### Extract text from document URL and return signed MP3 link

`POST https://api.eu.apyhub.com/tts/url` · 750 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `url` | body | string (uri) | yes | Example: `https://assets.apyhub.com/samples/sample.pdf`. |
| `gender` | body | string | yes | One of: male, female. Example: `female`. |

#### Quickstart

Convert a file URL to speech by sending the source URL and voice gender.

```bash
curl -X POST "https://api.eu.apyhub.com/tts/url" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://assets.apyhub.com/samples/sample.pdf",
    "gender": "female"
  }'
```

#### What you'll get back

Returns a JSON object with a `data` string field.

```json
{
  "data": "https://..."
}
```

## About

## What it does
Text to Speech converts plain text or document content into MP3 audio. Send a text string, a document file, or a document URL, and choose a voice gender of `male` or `female`. Depending on the endpoint, you either get the MP3 file directly or a JSON response with a signed download link.

Use Text to Speech when you need to turn reports, articles, training material, or support content into audio for listening on the go. If your content already lives in a document, send the uploaded file or its URL. If you already have the content in your app, send `text` directly. The service handles up to 75,000 characters for text input.

The response format is straightforward: binary MP3 for direct download endpoints, or `{ "data": "..." }` for link-based endpoints. That makes it easy to plug into workflows that need immediate file delivery or asynchronous download handling.

Text to Speech fits product features like read-aloud mode, content playback for accessibility, internal training libraries, and document narration without building speech synthesis logic yourself.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/apyhub/service/convert-text-to-speech
