# PDF & EPUB to Audiobook – MP3 Chapters, Natural AI Voices (`gazidev/pdf-to-audiobook`) Actor

Turn PDF, EPUB, DOCX, TXT or article URLs into an audiobook: one MP3 per chapter or an M4B with chapter marks, plus SRT. Natural open-source AI voices (Kokoro, Apache-2.0), no API key. Chapters from the table of contents, OCR for scans.

- **URL**: https://apify.com/gazidev/pdf-to-audiobook.md
- **Developed by:** [Cemal Atakli](https://apify.com/gazidev) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $40.00 / 1,000 audio minutes

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

## PDF & EPUB to Audiobook – MP3 Chapters, M4B, Natural AI Voices

Turn **PDF, EPUB, DOCX, TXT files or web articles into an audiobook**. The Actor finds the chapters, reads them aloud with a natural AI voice and gives you **one MP3 per chapter**, or a **single M4B audiobook with chapter marks**, plus **SRT subtitles** with sentence timestamps.

The voices come from the open-source **Kokoro-82M** text-to-speech model (Apache-2.0), which runs inside the Actor. You don't need an ElevenLabs, OpenAI or Google key. You pay per minute of audio, and you may use the audio commercially.

> Only convert documents you have the right to use: your own writing, public-domain books, openly licensed texts, or files you hold the rights to.

### What it does

- **Input formats:** PDF (text or scanned), EPUB (DRM-free), DOCX, TXT/Markdown, web article URLs (HTML), or pasted text. You can also upload files directly.
- **Chapter detection:**
  - EPUB table of contents, or PDF bookmarks/outline.
  - Falls back to headings, then to fixed page ranges.
  - Short title pages are merged into the next chapter.
  - "Contents", "Index" and "Copyright" sections are skipped, and so are reference lists.
- **Clean reading:**
  - Removes running headers, footers and page numbers.
  - Fixes broken words at line ends.
  - Removes URLs, citation marks like \[12], and line numbers in poems.
- **OCR for scanned PDFs:** pages without a text layer are read with Tesseract OCR.
- **49 voices** in US/UK English, Spanish, French, Italian, Brazilian Portuguese, Hindi and Mandarin (beta). Speed runs from 0.5× to 2×.
- **Output options:**

  - `mp3-per-chapter`
  - `m4b`: an audiobook file with chapter marks for Apple Books, BookPlayer, Smart AudioBook Player and VLC
  - `single-mp3`

  The chapter MP3s are always saved too.
- **Long books:**
  - `maxMinutes` caps the length of each run, and `startChapter` continues the book in the next run.
  - Progress is saved after every chapter, so a platform restart resumes where it stopped.
  - Your maximum cost per run is respected.

### Use cases

- Listen to **your own manuscripts, reports, lecture notes and research papers** on the go.
- Make **public-domain classics** into audiobooks, for example from Project Gutenberg or Standard Ebooks EPUBs.
- Get **accessibility versions** of documentation, handbooks, policies and course material.
- Produce **e-learning narration** and audio editions of newsletters and long-form articles.
- Draft narration for **self-published authors**, to proof-listen before hiring a narrator.
- **AI agents and automations:** "turn this PDF into an MP3" from an agent, Make, Zapier or n8n.

### Input example

```json
{
  "fileUrls": ["https://github.com/IDPF/epub3-samples/releases/download/20230704/wasteland.epub"],
  "voice": "af_heart",
  "speed": 1.0,
  "splitBy": "toc",
  "output": "m4b",
  "subtitles": true,
  "maxMinutes": 60
}
```

| Field | Default | Description |
|---|---|---|
| `fileUrls` / `uploadedFiles` / `text` | demo EPUB | Documents to convert (PDF, EPUB, DOCX, TXT, HTML URL). Drive/Dropbox/GitHub share links work |
| `voice`, `language`, `speed` | `af_heart`, auto, 1.0 | Voice, pronunciation language (auto = the voice's language) and speed |
| `splitBy` | `toc` | `toc` (table of contents/bookmarks → headings → pages), `heading`, `pages`, `none` |
| `pagesPerChapter` | 10 | For `pages` (non-PDF: 1 page ≈ 2,500 characters) |
| `skipPages` | 0 | Skip the first N PDF pages (cover, copyright, contents) |
| `skipChapterTitles` | Contents, Table of Contents, Index, Copyright | Chapters with these titles are not read |
| `skipReferences` | true | Stop a chapter at a "References" / "Bibliography" heading |
| `startChapter`, `maxChapters` | 1, 0 (all) | Convert a range of chapters |
| `removeHeadersFooters` | true | Drop running headers/footers and page numbers (PDF) |
| `ocr`, `ocrLanguage` | true, voice language | OCR scanned PDF pages (charged per page) |
| `output` | `mp3-per-chapter` | `mp3-per-chapter`, `m4b`, `single-mp3` |
| `bitrate` | 64 | kbps (64 is plenty for speech) |
| `subtitles` | true | SRT per chapter (and for the whole book with M4B / single MP3) |
| `maxMinutes` | 60 | Maximum minutes of audio per run |

### Output example

The dataset has one row per chapter and one `audiobook` row per document. Audio and SRT files are in the run's key-value store, with public links.

```json
{
  "type": "chapter",
  "documentTitle": "The Waste Land",
  "author": "T.S. Eliot",
  "chapterIndex": 1,
  "chapterCount": 6,
  "title": "I. THE BURIAL OF THE DEAD",
  "status": "ok",
  "fileUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/01-The-Waste-Land-001-I-THE-BURIAL-OF-THE-DEAD.mp3",
  "srtUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/01-The-Waste-Land-001-I-THE-BURIAL-OF-THE-DEAD.srt",
  "durationSec": 171.72,
  "chars": 2577,
  "voice": "af_heart",
  "billedMinutes": 3
}
```

```json
{
  "type": "audiobook",
  "documentTitle": "Test Book",
  "format": "m4b",
  "sourceType": "docx",
  "splitMethod": "heading",
  "chaptersInDocument": 3,
  "chaptersConverted": 3,
  "totalMinutes": 1.89,
  "fileUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/01-Test-Book.m4b",
  "srtUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/01-Test-Book.srt",
  "chapterMarks": [{"title": "Chapter 1: The Beginning", "startSec": 0.0}, {"title": "Chapter 2: The Middle", "startSec": 39.79}]
}
```

If a run stops at `maxMinutes`, the `audiobook` row has a `resumeHint`, for example "run again with startChapter=4". The `OUTPUT` record in the key-value store has the run totals.

### Pricing

Pay per use: **$0.05 per minute of audio**, rounded up once per run, not per chapter. OCR costs **$0.003 per scanned page**. There is no start fee and no subscription, and compute is included. Error rows, M4B/MP3 assembly and subtitles are free.

| | This Actor | marielise.dev/pdf-to-mp3 | offerastudio/document-to-audiobook | ElevenLabs-based Actors |
|---|---|---|---|---|
| Price | $0.05 / audio minute | $0.04 / audio minute + $0.05 per run | $0.01 / minute | Actor fee + your paid ElevenLabs plan |
| OCR (scanned PDFs) | $0.003 / page | $0.03 / page | $0.005 / page | – |
| Formats in | PDF, EPUB, DOCX, TXT, HTML URL | PDF | documents | text |
| Chapters | TOC / bookmarks / headings / pages | – | – | – |
| Output | MP3 per chapter, M4B with chapter marks, single MP3, SRT | MP3 | MP3 | MP3 |
| API key needed | No | No | No | Yes |

Example costs:

- A 30-page report (≈ 25 minutes of audio) costs about $1.25.
- A 300-page novel (≈ 9 hours of audio) costs about $27.

At speed 1.0, one minute of audio is about 950 characters, or 150–170 words.

### FAQ

**How long does it take?**
The model runs on CPU. At the default 8 GB of memory, it makes about 2 minutes of audio per minute of run time. A one-hour audiobook takes roughly 30 minutes. The price per audio minute is the same at any memory size. For a whole book, raise `maxMinutes` and the run timeout, or convert it in parts with `startChapter`.

**Can I use the audio commercially?**
The Kokoro-82M weights are licensed under Apache-2.0, which allows commercial use of the generated audio. Rights to the text itself are your responsibility. Only convert documents you are allowed to use. The voices are synthetic and must not be used to impersonate real people.

**Do DRM-protected EPUBs or Kindle files work?**
No. DRM-free EPUB only: an encrypted EPUB is reported as `drm-protected` and is not charged. Kindle formats (AZW/MOBI) are not supported.

**My PDF has no bookmarks. How are chapters found?**
The Actor falls back to headings detected from font size and boldness, and then to `pagesPerChapter`. You can also choose `splitBy: heading` or `pages` yourself.

**What about tables, footnotes and math?**
Tables are skipped, and footnote and citation markers are removed. Formulas are read as text, so heavy math does not make good audio.

**Which voices sound best?**
`af_heart`, `af_bella` (US English) and `bf_emma` / `bm_george` (British English) sound best. Non-English voices are good. Mandarin is in beta.

### Use with AI agents (Apify MCP)

The Actor works as a tool in the [Apify MCP server](https://mcp.apify.com). An agent can call `gazidev/pdf-to-audiobook` with `{"fileUrls": ["https://.../report.pdf"], "output": "m4b"}` and get back the `fileUrl` of the audiobook. You can also call it through the Apify API, or from Make, Zapier or n8n.

# Actor input Schema

## `fileUrls` (type: `array`):

Public links to PDF, EPUB, DOCX, TXT/Markdown files or web articles (HTML). Google Drive, Dropbox and GitHub share links are converted to direct downloads. Each document becomes one audiobook. Only convert documents you have the right to.

## `uploadedFiles` (type: `array`):

Upload PDF, EPUB, DOCX or TXT files directly.

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

Optional plain text or Markdown. Lines like 'Chapter 1' or '# Heading' start new chapters.

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

54 natural neural voices. The voice's language is used automatically unless you set Language.

## `language` (type: `string`):

How the text is read. Usually leave on Auto and pick a voice in your language. You can mix them, e.g. an American voice reading Spanish gives an accent.

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

0.5 = slow, 1.0 = normal, 2.0 = fast. The billed minutes are the minutes of audio produced.

## `splitBy` (type: `string`):

How chapters are found. 'toc' uses the EPUB table of contents or PDF bookmarks, then headings, then pages.

## `pagesPerChapter` (type: `integer`):

Used by 'Fixed number of pages' and as the PDF fallback. For non-PDF files one 'page' is about 2,500 characters.

## `skipPages` (type: `integer`):

Cover, copyright and contents pages you do not want read aloud.

## `skipChapterTitles` (type: `array`):

Chapters whose title is or starts with one of these words are not converted (case-insensitive).

## `skipReferences` (type: `boolean`):

Stop a chapter at a 'References' / 'Bibliography' heading (academic papers, non-fiction).

## `startChapter` (type: `integer`):

Continue a long book in a later run: start at this chapter number (shown in each row as chapterIndex).

## `maxChapters` (type: `integer`):

0 = all.

## `removeHeadersFooters` (type: `boolean`):

Drops lines repeated at the top/bottom of most pages (book title, chapter name) and bare page numbers.

## `ocr` (type: `boolean`):

Pages without a text layer are read with Tesseract OCR (charged per page). Text pages are never OCR'd.

## `ocrLanguage` (type: `string`):

Tesseract language code(s), e.g. 'eng', 'deu', 'eng+fra'. Empty = the voice language.

## `pdfPassword` (type: `string`):

Only for password-protected PDFs.

## `output` (type: `string`):

Output

## `bitrate` (type: `string`):

Bitrate

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

An SRT file with sentence timestamps for each chapter (and for the whole book with M4B / single MP3).

## `maxMinutes` (type: `integer`):

Hard cap on the audio produced (and billed) in one run; 60 minutes take about 30 minutes at 8 GB memory. The run stops at a sentence boundary; continue with 'Start at chapter'. Your maximum cost per run is respected too.

## `maxFileSizeMb` (type: `integer`):

Larger downloads are rejected.

## Actor input object example

```json
{
  "fileUrls": [
    "https://github.com/IDPF/epub3-samples/releases/download/20230704/wasteland.epub"
  ],
  "voice": "af_heart",
  "language": "auto",
  "speed": 1,
  "splitBy": "toc",
  "pagesPerChapter": 10,
  "skipPages": 0,
  "skipChapterTitles": [
    "Contents",
    "Table of Contents",
    "Index",
    "Copyright"
  ],
  "skipReferences": true,
  "startChapter": 1,
  "maxChapters": 0,
  "removeHeadersFooters": true,
  "ocr": true,
  "output": "mp3-per-chapter",
  "bitrate": "64",
  "subtitles": true,
  "maxMinutes": 3,
  "maxFileSizeMb": 100
}
```

# Actor output Schema

## `chapters` (type: `string`):

No description

## `audiobooks` (type: `string`):

No description

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

No description

## `summary` (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 = {
    "fileUrls": [
        "https://github.com/IDPF/epub3-samples/releases/download/20230704/wasteland.epub"
    ],
    "voice": "af_heart",
    "maxMinutes": 3
};

// Run the Actor and wait for it to finish
const run = await client.actor("gazidev/pdf-to-audiobook").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 = {
    "fileUrls": ["https://github.com/IDPF/epub3-samples/releases/download/20230704/wasteland.epub"],
    "voice": "af_heart",
    "maxMinutes": 3,
}

# Run the Actor and wait for it to finish
run = client.actor("gazidev/pdf-to-audiobook").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 '{
  "fileUrls": [
    "https://github.com/IDPF/epub3-samples/releases/download/20230704/wasteland.epub"
  ],
  "voice": "af_heart",
  "maxMinutes": 3
}' |
apify call gazidev/pdf-to-audiobook --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,gazidev/pdf-to-audiobook"
        }
    }
}
```

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/NRiolQDgLsFXaPib8/builds/RVcAFiuqpcmFTaSpO/openapi.json
