How to Convert PDF Text to Speech via API?

By Audiobook API editorial team · Updated 2026-11-18

This guide explains how indie authors and small publishing startups can convert PDF text into audiobooks using the Audiobook API. You will learn to extract clean text from PDFs, manage the 4096-character limit, and handle audio concatenation without building custom infrastructure. The process is designed for scale, allowing you to focus on content rather than engineering details.

We cover practical steps from choosing the right voice preset to optimizing costs during long-text conversion. By following these steps, you can generate consistent, high-quality audio files for your self-published titles. This page provides the specific technical workflows needed to integrate TTS into your publishing pipeline efficiently.

How to Convert PDF Text to Speech via API?

Frequently asked questions

Do I need to convert PDF to plain text first?

Yes. The API accepts raw text input, not PDF files. You must extract the text from your PDF using a tool of your choice before sending it to the endpoint. The service processes the string content directly, so formatting like bold or italics is ignored, as SSML is not supported.

How do I handle special characters in PDF text?

The API handles standard Unicode characters within the 4096-character limit. Special symbols are treated as part of the input string. Ensure your text is properly encoded in UTF-8 when sending the JSON body. The system does not parse complex typographic marks, so standard punctuation and alphanumeric characters are processed normally.

Can the API handle footnotes or references?

Yes, footnotes are treated as plain text. They will be spoken sequentially as part of the input string. Since there is no SSML support, you cannot tag them as footnotes. You must include them in the text payload exactly as you want them heard in the final audio file.

What is the best way to split chapters?

Split your text into chunks of up to 4096 characters. Process each chunk via separate requests and concatenate the resulting audio files. This ensures efficient processing and allows you to manage character limits. You can use any script to join the output files into a single chapter audio.

Does the API preserve punctuation for pacing?

Yes, punctuation marks influence the speech synthesis pacing. Commas, periods, and question marks create natural pauses. The engine uses these cues to determine rhythm. However, complex formatting like bold text does not change the audio, only the textual punctuation affects the spoken output timing.

How long does it take to process a 300-page book?

Processing takes roughly real-time, about 25 characters per second. A 300-page book may contain hundreds of thousands of characters. With a queue and 60 requests per minute limit, generation could take several hours. Short phrases may take a few seconds, but long texts require sequential processing.

Can I change the voice mid-book?

Yes, you can change the voice by sending a new request with a different voice parameter. Since the API returns separate audio files for each request, you can mix voices by concatenating the outputs. This allows for distinct narrators for different characters or sections within your book.

Is the audio quality consistent across chunks?

Yes, the quality is consistent because the same engine generates all files. Each chunk is processed independently but uses the same model parameters. Minor variations may occur at chunk boundaries due to separate synthesis runs, but the overall audio character remains uniform across the entire book.

How do I handle multiple languages in one book?

Set the language field to the ISO code for each segment. If omitted, the API guesses the language, defaulting to English for Latin script. For non-English Latin text, explicitly set the language to ensure correct pronunciation. All 23 supported languages can be mixed within a single project.

What happens if the text contains emojis?

Emojis are treated as characters in the input string. They may be spoken as descriptions or ignored depending on the voice model's training. They count toward the 4096-character limit. The API does not have special handling for emojis, so they are processed as standard Unicode input.

Can I use the same API key for multiple projects?

Yes, one active key per account can be used for multiple projects. The key authenticates all requests. You can generate a new key at any time, which invalidates the old one immediately. There is no limit on the number of projects using a single key.

Is there a limit on the number of voices I can use?

No, you can use all 8 available voices. You can switch voices between requests by specifying the voice parameter. There is no restriction on how many different voices you can utilize across your generated audio files or projects.

How do I verify the audio file format?

Specify the response_format in your request as mp3, wav, opus, flac, or pcm. The API returns the audio file in the requested format. You can verify the format by checking the file extension and content type in the response headers. The format is determined by your input parameter.

Can I download the audio files later?

No, generated audio is returned in the response and not stored by the API. You must download and save the audio files immediately after receiving the response. The service does not provide a library or storage for your generated audio files after the request completes.

Understanding PDF Text Extraction

Sound wave illustration for: Understanding PDF Text Extraction

Converting PDFs to audiobooks begins with accurate text extraction. Automated tools often introduce artifacts that disrupt TTS engines, so manual review is recommended before sending data to the API.

Clean input ensures natural pacing. Removing stray symbols and standardizing punctuation prevents the AI from misreading chapter numbers or special characters during synthesis.

Extracting Text from PDFs

Use dedicated libraries like PyPDF2 or pdfplumber to parse raw text. Avoid simple copy-paste methods, which often preserve hidden formatting codes that confuse the speech engine.

Ensure the extracted text preserves paragraph breaks. The API processes text sequentially, so maintaining logical structure helps maintain narrative flow in the final audio file.

  • Use PyPDF2 for standard PDFs
  • Try pdfplumber for complex layouts
  • Avoid simple copy-paste methods

Handling Formatting Artifacts

Remove line breaks within sentences and extra spaces. These artifacts cause unnatural pauses in the generated audio, breaking immersion for listeners.

Strip out page numbers, headers, and footers. These elements are not part of the narrative and will be read aloud unless cleaned beforehand.

  • Remove intra-sentence line breaks
  • Strip page numbers and headers
  • Clean extra whitespace

Preparing Clean Input

Validate text character counts before API submission. Each request supports up to 4096 characters, so pre-splitting text ensures efficient processing and avoids truncation errors.

Standardize punctuation for consistent pronunciation. Replace abbreviations like 'Mr.' or 'e.g.' with full forms to prevent the TTS engine from stumbling over acronyms.

  • Pre-split text to 4096 chars
  • Standardize abbreviations
  • Validate character counts

Character Limit Management

Sound wave illustration for: Character Limit Management

The API enforces a strict 4096-character limit per request, counting spaces and punctuation. For long manuscripts, your client must split the source text into smaller chunks before sending each segment individually.

Each chunk generates a separate audio file. The API does not automatically concatenate these segments; your integration code must handle the sequencing and merging of the resulting files into a single audiobook track.

Splitting Text into 4096-Character Chunks

Break the input text into segments of exactly 4096 characters or fewer. Ensure the split occurs at logical boundaries, such as sentence ends or paragraph breaks, to avoid cutting mid-word.

Count every character, including spaces and punctuation marks, against the 4096 limit. If a single paragraph exceeds this length, you must artificially split it before submission.

  • Calculate character count including all whitespace.
  • Split at sentence boundaries where possible.
  • Ensure no segment exceeds 4096 characters.

Joining Audio Files

Since the API returns one audio file per request, your backend must download each response and concatenate them in order. Use standard audio libraries to merge the files seamlessly.

This process applies regardless of the chosen format (mp3, wav, opus, flac, or pcm). The concatenation logic remains the same, though file sizes will vary by format.

Maintaining Narrative Flow

To preserve narrative continuity, split text at natural pause points. Avoid breaking mid-sentence to prevent awkward audio transitions between chunks.

Test the join point by listening to the end of one chunk and the start of the next. Adjust your splitting algorithm if the voice tone or pacing feels disrupted by the cut.

Choosing the Right Voice

Sound wave illustration for: Choosing the Right Voice

Selecting the correct voice preset is critical for maintaining listener engagement in long-form audiobooks. The eight available presets range from warm narrators to neutral news readers, each suited to different genres. For instance, 'aria' offers a clear, warm tone ideal for fiction, while 'atlas' provides a neutral, news-style delivery better suited for non-fiction or instructional content. Matching the voice to the book’s tone ensures a professional result without requiring complex audio engineering.

Before committing to a voice, test short samples across your target genres. The API supports eight distinct voices, including female options like 'nova' and 'luna', and male options like 'felix' and 'orion'. Each voice is based on licensed recordings from LibriTTS-R, ensuring consistent quality. Use the GET /v1/voices endpoint to review available options and select the one that best fits your narrative style.

Matching Voice to Genre

Choose voices that align with your book’s tone. Fiction benefits from warm, storytelling voices like 'luna' or 'aria'. Non-fiction and business books often work best with neutral, instructional voices like 'sage' or 'atlas'.

Consistency is key. Stick to one voice per book to avoid jarring transitions for listeners. The API allows you to specify the voice for each request, ensuring uniform delivery across all chapters.

  • Fiction: aria, luna
  • Non-fiction: sage, atlas
  • Promo/Promo: felix
  • Documentary: orion

Testing Voice Samples

Generate short audio clips for each candidate voice using the same text snippet. Compare the output for clarity, pacing, and emotional resonance. The POST https://api.999rbd.com/v1/audio/speech endpoint allows you to quickly generate samples with different voice parameters.

Review the generated audio for artifacts or unnatural pauses. The API processes requests in a queue, so allow sufficient time for generation, especially under load. Use the returned audio file to make your final decision.

  • Use consistent text for fair comparison
  • Check pacing and clarity
  • Listen for natural intonation

Consistency Across Chapters

Ensure the same voice is used for all chapters of a book. This maintains listener immersion and avoids confusion. The API allows you to specify the voice for each request, so store your chosen voice ID in your workflow configuration.

If you need to switch voices for a new book, update your configuration accordingly. The API supports 23 languages, so you can maintain consistency across different language editions of the same book by selecting the appropriate voice for each language.

  • Store voice ID in config
  • Use same voice per book
  • Check language support

API Request Structure

Sound wave illustration for: API Request Structure

The API endpoint POST https://api.999rbd.com/v1/audio/speech accepts a JSON body. This structure mirrors the OpenAI speech endpoint, allowing you to use existing OpenAI SDKs by simply updating the base_url. This compatibility simplifies integration for indie authors and small publishing startups already familiar with standard TTS workflows.

You must include specific parameters to define the audio output. The request body requires a model, the text input, and a voice selection. Optional fields allow you to fine-tune the speed and specify the output format, ensuring the generated audio meets your technical requirements for audiobook production.

JSON Body Format

Send your text payload as a JSON object to the speech endpoint. The structure is straightforward, ensuring that your publishing pipeline can easily serialize text chunks before submission. This standard format reduces parsing errors when automating chapter generation.

Required Fields

You must provide model ("tts-1" or "tts-1-hd"), input (your text), and voice (one of the 8 presets). The input field supports up to 4096 characters. Ensure your PDF extraction script respects this limit before sending the request.

Authentication is handled via the Authorization: Bearer header using your API key. Without this header, the request will fail immediately, preventing unnecessary character consumption from your balance.

Optional Parameters

You can specify response_format (mp3, wav, opus, flac, pcm) to control file size and quality. The speed parameter accepts values between 0.25 and 4.0, allowing you to adjust narration pace. Finally, language accepts an ISO code to override automatic detection, ensuring accuracy for non-English texts.

Handling Errors and Retries

Sound wave illustration for: Handling Errors and Retries

When converting long manuscripts, synthesis failures can interrupt your audiobook production pipeline. Understanding why a request fails is the first step to maintaining data integrity and avoiding wasted credits on invalid inputs.

Identifying Failed Requests

Failed requests are free, but you must distinguish them from successful ones. Check the HTTP status code and response body for specific error messages indicating invalid text, unsupported voices, or temporary server issues.

  • HTTP 400 for invalid JSON or missing fields
  • HTTP 429 for rate limit exceeded (60 req/min, or 10 req/min before top-up)
  • HTTP 500 for internal synthesis errors

Implementing Retry Logic

Implement exponential backoff for transient errors. Since requests are processed sequentially, a simple retry with a short delay often resolves temporary congestion. Ensure your code handles the 60 requests per minute limit per key gracefully.

  • Retry on 5xx errors with increasing delays
  • Respect Retry-After headers if provided
  • Do not retry on 4xx client errors unless correcting input

Monitoring Queue Times

Under load, requests may wait in a queue. Monitor your response latency to adjust batch sizes. If queue times increase, consider spacing out requests or using a secondary API key to parallelize processing without hitting the rate limit.

Optimizing for Long Texts

Sound wave illustration for: Optimizing for Long Texts

Converting long-form manuscripts requires managing the 4096-character limit per request while maintaining narrative coherence. The API handles the splitting and audio concatenation, but your workflow determines efficiency. Batching allows you to process chapters sequentially without overwhelming the queue, ensuring consistent pacing during generation.

For faster turnaround, parallel processing splits text into independent chunks sent simultaneously. Since requests are processed one after another under load, parallel batches queue efficiently. This approach minimizes idle time between chapters, keeping your production pipeline moving smoothly without manual intervention.

Batching Strategies

Group text by natural breaks like chapters or scenes. This ensures each API request produces a complete, coherent audio segment. Batching reduces overhead from multiple small requests and simplifies error handling if one segment fails.

Limit batch sizes to fit within the 60 requests-per-minute rate limit. For a 50,000-character novel, split into ~12 chunks. Send these in controlled bursts to avoid hitting the 10 requests/minute baseline or the 60 requests/minute ceiling.

  • Split text at sentence boundaries, not mid-word.
  • Group chunks by chapter for easier debugging.
  • Stay under 60 requests per minute per key.
  • Use 4096-character max for each input.

Parallel Processing

Send multiple chunk requests concurrently from your application. The API queues them sequentially but processes them in order. Parallel submission reduces the waiting time between requests, speeding up total generation time significantly.

Monitor queue times during high load. If requests wait, reduce parallelism. The system processes one request after another, so excessive parallelism may just increase queue depth without improving speed.

  • Send requests concurrently from your app.
  • API queues them sequentially.
  • Reduces idle waiting time.
  • Monitor queue depth under load.

Cost Estimation

Calculate cost based on total characters. At $10 per 1 million characters, a 100,000-character novel costs $1.00. Spaces and punctuation count as characters, so include them in your estimate.

Failed requests are free, so retrying errors does not increase costs. However, successful requests are charged immediately. Use the GET /v1/models endpoint to confirm pricing remains consistent for tts-1 and tts-1-hd.

  • $0.01 per 1,000 characters.
  • Spaces and punctuation count.
  • Failed requests are free.
  • Balance does not expire.

Audio Format Selection

Sound wave illustration for: Audio Format Selection

Selecting the correct audio format is critical for audiobook distribution and storage efficiency. The API supports MP3, WAV, Opus, FLAC, and PCM, allowing you to balance file size against quality based on your specific publishing needs.

Each format serves a distinct purpose in the production pipeline, from final distribution to archival quality assurance.

MP3 for Compression

MP3 is the standard for most audiobook platforms due to its small file size and broad compatibility. It offers sufficient audio quality for voice narration while minimizing bandwidth costs during delivery to end-users.

This format is ideal for streaming platforms and mobile apps where storage constraints are a priority.

  • Widely supported by major audiobook distributors
  • Significant space savings compared to uncompressed formats

WAV for Quality

WAV provides uncompressed, high-fidelity audio, preserving every detail of the synthesized voice. It is the preferred choice for master files before distribution, ensuring no generational loss occurs during further processing or editing.

Use WAV when you need the highest possible quality for archival purposes or professional mastering.

  • Lossless quality
  • Ideal for master files

Opus for Efficiency

Opus delivers excellent audio quality at very low bitrates, making it highly efficient for modern web delivery. It is particularly suitable for interactive applications or scenarios where bandwidth efficiency is paramount without sacrificing clarity.

This format offers a strong balance between quality and data usage for digital-first audiobooks.

  • High efficiency at low bitrates
  • Modern web standard

Language Detection and Specification

Sound wave illustration for: Language Detection and Specification

Accurate language handling is critical for indie authors converting long-form texts. The API supports 23 languages, including English, Spanish, and Japanese, with robust detection for Latin-script inputs defaulting to English.

For non-English Latin text or specific dialects, explicitly setting the language parameter ensures correct pronunciation and intonation, preventing the engine from guessing incorrectly.

Automatic Detection

If the language field is omitted, the API infers the language from the text script. Latin characters default to English, while Cyrillic or CJK scripts trigger their respective languages. This works well for homogeneous texts but may fail for mixed-language passages.

Forcing Language Codes

To ensure precision, pass the ISO 639-1 code in the language field. For example, set language: "es" for Spanish or language: "fr" for French. This overrides automatic detection, ensuring consistent voice behavior across chapters.

  • Supported codes include en, de, zh, ja, ko, ru, ar, hi, and 15 others.

Handling Mixed Languages

The API does not dynamically switch languages within a single request. For texts containing multiple languages (e.g., English with French quotes), split the text into separate requests. Each chunk must specify its own language code to maintain audio quality and narrative flow.

Validation and Quality Check

Sound wave illustration for: Validation and Quality Check

Quality assurance is essential before distributing audiobooks. After generating audio files, validate the output to ensure narrative integrity and technical compliance. This process confirms that the synthetic speech matches the source text and meets professional standards.

Since the API returns concatenated audio files, a final review prevents minor glitches from reaching your audience. Automated checks verify the file structure, while manual listening ensures the voice remains consistent and natural throughout the chapter.

Listening to Generated Audio

Play back the generated audio file to verify that the voice articulates the text correctly. Check for unnatural pauses or rushed speech, especially when the speed parameter is adjusted. Listen for consistency in tone across different segments, ensuring the voice does not drift in character or volume.

Focus on how the API handles punctuation and paragraph breaks. The synthetic speech should naturally reflect these breaks, providing clear transitions between sentences and chapters without awkward artifacts.

  • Verify speech matches the input text exactly.
  • Check for natural pacing and intonation.
  • Ensure consistent voice tone across segments.

Checking for Artifacts

Listen for digital glitches, such as clicking sounds or abrupt cuts, which may indicate processing errors or queue delays during concatenation. These artifacts are rare but can occur if a request fails silently or if the text contains unusual characters.

Review the audio for any unexpected silence or repeated phrases. If the input text contained formatting errors or non-standard characters, these might manifest as strange sounds in the final file. Test with edge cases, such as numbers or special symbols, to ensure clean output.

  • Detect clicking sounds or abrupt cuts.
  • Identify unexpected silence or repetitions.
  • Test with numbers and special symbols.

Watermark Verification

Every generated audio file contains an inaudible watermark that marks it as synthetic speech. This watermark is embedded by default and cannot be removed. It serves as a proof of origin, indicating that the audio was generated by the Audiobook API.

You can verify the presence of the watermark using specialized detection tools if needed. This feature helps distinguish your API-generated audiobooks from human-recorded ones, which is useful for transparency and copyright purposes.

  • Watermark is inaudible and permanent.
  • Cannot be removed from the file.
  • Proves synthetic origin of the audio.

Integration with Publishing Workflows

Sound wave illustration for: Integration with Publishing Workflows

Once audio files are generated, integrating them into your publishing pipeline requires systematic organization. Automating chapter generation ensures that each segment aligns precisely with the source text, maintaining narrative continuity without manual file management.

Automating Chapter Generation

Scripts should split your manuscript into chunks under 4096 characters, sending each to the API endpoint. The system returns individual audio files that your workflow can concatenate seamlessly.

  • Split text by chapter or section boundaries
  • Queue requests with consistent voice parameters
  • Concatenate outputs into final chapter files

Uploading to Distributors

Most platforms accept standard audio formats. After generation, verify file integrity before uploading to your preferred aggregator or direct distribution channel.

Version Control

Store generated audio alongside your source text versions. If text changes, re-generate only affected chapters to save credits and maintain consistency across the book.

Troubleshooting Common Issues

Sound wave illustration for: Troubleshooting Common Issues

Even with robust extraction, PDF-to-speech pipelines encounter specific hurdles. Silent outputs usually stem from empty chunks or truncated API responses, while incorrect language flags occur when Latin-script text lacks explicit language codes. Rate limits further complicate batch processing for long manuscripts.

Silent Audio Output

Silent audio typically results from sending empty strings or whitespace-only chunks after aggressive regex cleaning. Verify that the input field contains actual characters before submission. If the API returns a 200 OK status but the file is silent, check that the text exceeds zero characters and is under 4096 characters.

  • Ensure no hidden Unicode characters break the JSON payload.
  • Verify the API response includes a valid audio URL or base64 data.

Incorrect Language Output

The system guesses language from script, defaulting to English for Latin text. If your source is French or German, the voice may mispronounce words. Always set the language parameter explicitly to avoid incorrect synthesis, especially with mixed-language paragraphs common in translations.

  • Set language: 'fr' for French text, even if Latin script is used.
  • Use GET /v1/voices to confirm supported languages for your target voice.

Rate Limit Errors

The API allows 60 requests per minute per key (10 before top-up). Exceeding this returns a 429 error. Implement exponential backoff in your retry logic. For large books, split your script into smaller batches to stay within limits without losing narrative continuity.

  • Monitor the X-RateLimit-Remaining header in responses.
  • Use parallel processing only if you have multiple keys or higher limits after top-up.

Cost Management During Conversion

Sound wave illustration for: Cost Management During Conversion

Understanding the pricing model is critical for indie authors converting long-form manuscripts. With a flat rate of $0.01 per 1,000 characters, costs scale linearly with word count, making budgeting predictable for novels or short story collections. Failed requests incur no charge, protecting your balance from unexpected API hiccups.

Managing character limits effectively ensures you avoid unnecessary overhead. By splitting text into 4,096-character chunks and joining the resulting audio files, you maintain precise control over the conversion process without paying for redundant data transmission or storage.

Estimating Total Cost

Calculate your total expense by dividing the character count of your manuscript by 100,000 and multiplying by $10. Remember that spaces and punctuation count toward the total. For a typical 60,000-word novel, expect a base cost around $120, assuming no extra speed adjustments.

Use the /v1/voices endpoint to check available formats, as this does not affect pricing but helps in planning storage needs. Since each request is limited to 4,096 characters, estimate the number of API calls required to process your entire book.

  • Rate: $10 per 1 million characters
  • Spaces and punctuation count as characters
  • Failed requests are free

Minimizing Waste

Avoid sending duplicate requests by implementing retry logic only for failures. Since the API processes requests sequentially under load, queueing delays do not incur extra charges. However, excessive retries for non-failure issues may waste your limited free trial credit or paid balance.

Pre-process your PDF text to remove artifacts before sending it to the API. Clean input reduces the character count slightly and ensures higher quality audio, preventing the need for re-generation due to artifacts caused by poor formatting.

Bulk Processing Discounts

The API does not offer volume-based discounts or tiered pricing. Each character is billed at the same flat rate regardless of volume. However, using a single API key for all conversions allows you to monitor your balance in real-time.

Top-ups via USDT on TRON are processed automatically. There are no monthly plans or seats, so you only pay for what you convert. This pay-as-you-go model is ideal for startups with variable publishing schedules.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Indie publishers benefit from paying only for what they produce, avoiding minimum monthly commitments common in traditional TTS services.

Avatar of the voice aria
ariafemale
Avatar of the voice nova
novafemale
Avatar of the voice luna
lunafemale
Avatar of the voice sage
sagefemale
Avatar of the voice felix
felixmale
Avatar of the voice milo
milomale
Avatar of the voice atlas
atlasmale
Avatar of the voice orion
orionmale

23 languages

Any voice speaks any of these languages.

Sources and further reading

  1. Wikipedia
  2. LibriTTS-R paper (arXiv 2305.18802)
  3. curl documentation
  4. W3C WAI: making audio and video accessible
  5. MDN: Web Speech API
  6. ISO 639 language codes
  7. Node.js documentation
  8. Creative Commons Attribution 4.0
  9. Python documentation
  10. LibriVox public-domain audiobooks
  11. IETF RFC 7845: Ogg Opus
  12. Tether (USDT)

More on this site