How to Convert Long Texts to Audiobooks via API?

By VoxLingua editorial team · Updated 2026-11-19

This guide details the technical workflow for converting extensive texts into audio using the VoxLingua API. It addresses the specific constraints of the 4096-character request limit and explains how to segment long novels or educational materials into manageable chunks. You will learn the logic for splitting text while preserving context and the methods for concatenating the resulting audio files.

Designed for indie developers building language learning platforms, this page covers rate limit management, error recovery, and cost estimation. We provide concrete strategies for handling queue waiting times and ensuring voice consistency across thousands of requests. The guide focuses on reliable infrastructure integration, helping you process volume efficiently without unnecessary complexity.

How to Convert Long Texts to Audiobooks via API?

Frequently asked questions

What is the hard limit for a single request?

Each API request accepts a maximum of 4096 characters in the input field. This limit applies to the entire text payload sent in one POST call. If your content exceeds this length, you must split the text into smaller segments. Each segment is processed independently, so ensuring your chunks stay within this boundary is essential for successful synthesis.

Do I need to pay for each chunk separately?

Yes, each chunk constitutes a separate API request and is billed individually. The rate is $0.01 per 1,000 characters, calculated per request. You are charged for the characters in each specific chunk submitted. Failed requests are free, but successful synthesis of each part incurs its own charge based on the character count used.

Can I split the text by paragraphs instead of characters?

The API does not enforce a specific split method; you determine how to divide the text. You may split by paragraphs, sentences, or fixed character counts. The only constraint is that each individual request must not exceed 4096 characters. Your implementation logic handles the segmentation before sending the data to the endpoint.

Does the speed setting apply to all chunks?

The speed parameter is defined per request, not globally for the entire book. You must include the desired speed value (0.25–4.0) in every chunk’s JSON body. If you send chunks with different speed values, the resulting audio segments will vary in tempo. Ensure consistent speed settings across all requests for uniform playback.

How do I handle punctuation in split points?

Punctuation counts as characters in the 4096-character limit. You should split at logical boundaries, such as after periods or commas, to ensure clean audio transitions. The API does not automatically adjust for punctuation; your client code must handle the segmentation logic. Proper splitting prevents truncating words mid-segment during synthesis.

Is there a delay between generating chunks?

Requests are processed sequentially, so under load, a request may wait in a queue. Typical speed is roughly real-time, taking a few seconds for short phrases. Longer texts generate audio at approximately 25 characters per second. Delays depend on server load and the number of concurrent requests you submit.

Can I change the voice mid-book?

Yes, you can change the voice for each individual request. Specify a different voice preset in the voice field for each chunk. This allows for varied narration styles within a single document. Each chunk is synthesized independently, so switching voices between requests is fully supported and does not affect previous segments.

What happens if one chunk fails?

If synthesis fails, the charge is returned in full for that specific request. The API does not automatically retry failed chunks; your application must handle retries. You can re-submit the failed text segment using the same parameters. Failed requests do not incur costs, ensuring you only pay for successfully generated audio.

Do I need to store all chunks before joining?

The API returns audio directly in the response; it does not store files. Your application must receive and store each audio segment. You can join the files locally after all requests complete. Since audio is not stored by the API, you are responsible for managing the temporary or permanent storage of these segments.

Is the audio quality consistent across chunks?

Quality remains consistent as the same engine and voice presets are used. Each chunk is synthesized independently but follows the same technical specifications. Variations may occur due to network latency or queue delays, but the audio characteristics remain uniform. Ensure consistent parameters like speed and format across all requests for optimal results.

Can I use the same voice for different languages?

Yes, every voice preset can speak any of the 23 supported languages. You can use the same voice, such as Aria or Felix, for English, Spanish, or Japanese text. Set the language field to the ISO code if needed. The API handles multilingual synthesis without requiring different voice models for each language.

How do I detect if the API is rate-limited?

The limit is 60 requests per minute per key. If you exceed this, subsequent requests may be queued or rejected. Monitor your request rate to stay within the 60 RPM threshold. The API does not provide a specific rate-limit header in the basic response, so you must track your request count client-side.

Character Limit Constraints

Sound wave illustration for: Character Limit Constraints

The API enforces a strict 4096-character limit per request, counting spaces and punctuation. This constraint dictates how extensive texts, such as educational materials or novels, must be segmented before synthesis. Each segment requires a separate API call, directly influencing processing time and cost.

For long-form content, this limit necessitates a multi-step workflow. Developers must manually split text into manageable chunks, ensuring no single request exceeds the boundary. Understanding this constraint is fundamental to designing efficient audio generation pipelines.

4096 character limit per request

Every POST request to /v1/audio/speech accepts a maximum of 4096 characters in the input field. This includes all whitespace and punctuation marks. Requests exceeding this limit will fail, requiring the caller to implement precise character counting before submission.

  • Limit is hard-coded at 4096 characters.
  • Spaces and punctuation count toward the total.
  • Exceeding the limit results in a request failure.

Impact on long novels

A typical novel chapter may contain 2,000 to 5,000 characters. Content exceeding 4096 characters must be divided into multiple requests. For a 50,000-character text, approximately 13 separate API calls are required. This increases the total request volume and associated latency compared to shorter texts.

  • 50,000 characters require ~13 requests.
  • Processing time increases linearly with segment count.
  • Queue waiting times may apply under load.

Splitting logic strategies

Effective splitting preserves semantic integrity. Sentence-based splitting is preferred to avoid cutting words mid-stream. Word-based splitting is simpler but risks breaking hyphenated terms. The client application must handle the concatenation of resulting audio files into a single coherent output.

  • Prioritize sentence boundaries over character counts.
  • Preserve context across chunks.
  • Ensure format consistency during merging.

Text Splitting Methods

Sound wave illustration for: Text Splitting Methods

For language learning platforms, accurate segmentation is critical to preserve semantic integrity. The API accepts up to 4096 characters per request, requiring careful chunking strategies for longer texts.

Sentence-based splitting

Splitting at sentence boundaries ensures that each chunk is a complete grammatical unit. This prevents voices from cutting off mid-thought, which disrupts the listening experience for educational content.

  • Use punctuation marks (. ! ?) as delimiters.
  • Preserve paragraph structure for context.

Word-based splitting

Splitting by character count alone may truncate words. Word-based splitting ensures that each chunk ends cleanly, avoiding partial words that sound unnatural in TTS synthesis.

  • Respect whitespace boundaries.
  • Ensure chunks do not exceed 4096 characters.

Maintaining context across chunks

Each chunk is synthesized independently. Using the same voice and speed parameters ensures consistent audio quality. Language codes must be explicitly set for non-English texts to avoid incorrect default detection.

  • Standardize voice ID across all chunks.
  • Set the language parameter explicitly.

Audio Concatenation

Sound wave illustration for: Audio Concatenation

Audio concatenation requires precise handling of the output files returned by the API. Since each request generates a discrete audio file, the client application must manage the assembly of these segments into a single coherent stream. This process is critical for maintaining the integrity of the final audiobook or language learning material.

Joining MP3 files

The API supports MP3, WAV, OPUS, FLAC, and PCM formats. When using MP3, ensure the joining library preserves the frame boundaries to avoid artifacts. Concatenating WAV or FLAC files is often more reliable for lossless integrity, though the file sizes will be significantly larger.

  • Use libraries that handle container headers correctly.
  • Verify that the joined file plays without skips.

Handling silence gaps

Each API call introduces a natural pause between segments. For language learning, these pauses can disrupt flow. You may need to trim the tail of the previous segment and the head of the next one to create a seamless transition.

  • Trim trailing silence from the previous chunk.
  • Trim leading silence from the next chunk.

Format consistency checks

Ensure all chunks share the same response_format and speed settings. Mixing formats or speeds creates jarring audio transitions. Validate that all segments use the same sample rate and bit depth before finalizing the file.

  • Check sample rates match across all segments.
  • Verify bit depth consistency.

Rate Limit Management

Sound wave illustration for: Rate Limit Management

Managing the 60 requests-per-minute limit is critical when processing lengthy texts. Since each 4096-character chunk requires a separate API call, large documents generate significant volume. Developers must calculate the total request count upfront to ensure their processing pipeline respects these constraints without blocking other operations or triggering throttling errors.

The initial rate limit is 10 requests per minute for new accounts until the first top-up is processed. Understanding this baseline helps in sizing the infrastructure correctly before scaling up to the standard 60 requests per minute allowed for active accounts.

Calculating total requests

Divide the total character count by 4096 to estimate the number of API calls needed. Remember that spaces and punctuation count toward the limit. For a 100,000-character text, you will need approximately 25 requests. This calculation should include a buffer for any failed requests that require re-synthesis.

  • Total characters / 4096 = base request count
  • Add 10-20% buffer for error recovery
  • Account for retry logic in volume estimates

Staggering requests to avoid limits

Implement a delay between requests to stay within the 60 requests per minute limit. For new accounts, this means a maximum of 10 requests per minute. Use exponential backoff or fixed intervals to distribute load evenly. This prevents sudden spikes that could exceed the per-key limit and trigger temporary blocks.

  • Use fixed delays (e.g., 1 second per request)
  • Implement exponential backoff for retries
  • Monitor rate limit headers in responses

Queue waiting times

Requests are processed sequentially under load. During high demand, a request may wait in a queue, increasing total processing time. While typical speed is roughly real-time, queue delays can extend the duration for large batches. Plan for additional time in your project timelines if processing time is critical.

  • Requests processed sequentially
  • Queue delays increase total time
  • Factor queue wait time into project timelines

Error Recovery

Sound wave illustration for: Error Recovery

The API returns full credit for failed synthesis requests, ensuring no financial loss for errors. However, failed chunks in a long-text pipeline disrupt the final audio file's integrity. Developers must track which segments succeeded and which failed to maintain a complete record of the generation process.

Handling failed chunks

When a request fails, the system refunds the character count. The client application should log the error status and retry the specific chunk. This ensures that only problematic segments are reprocessed, leaving successful audio files intact.

  • Check the HTTP status code for each chunk response.
  • Log the error timestamp and character offset for debugging.

Re-synthesis strategies

Implement exponential backoff for transient network errors. For persistent failures, retry the same text chunk up to three times before marking it as permanently failed. This approach balances reliability with API rate limits, preventing excessive queue waits during high load.

  • Retry logic should respect the 60 requests per minute limit.
  • Use the same voice and speed parameters for retries.

Partial file recovery

Store each successful audio file temporarily with a unique identifier. After all chunks are processed, verify that no segments are missing before concatenation. If a chunk remains failed, exclude it or flag the final audio as incomplete for manual review.

  • Maintain a local index of generated audio files.
  • Verify file integrity before merging into the final audiobook.

Voice Consistency

Sound wave illustration for: Voice Consistency

To maintain a coherent listening experience, your application must consistently select the same voice ID across all synthesis requests for a single audiobook. Since each API call is independent, the client is responsible for persisting the chosen voice (e.g., "aria" or "atlas") in the request payload to ensure tonal uniformity throughout the generated audio segments.

Using the same voice ID

The voice preset determines the timbre and pacing style of the output. If your splitting logic sends requests to multiple workers, ensure they all reference the identical voice parameter. Switching voices mid-chapter creates an audible discontinuity that breaks the narrative flow for language learners.

  • Persist the voice string in your local configuration.

Speed parameter uniformity

The speed parameter (0.25–4.0) must remain constant across all requests. Variations in speed alter the duration and pitch of adjacent audio segments, making the final concatenated file sound uneven. Set a fixed speed value and apply it to every chunk synthesis to maintain consistent playback velocity.

Language code enforcement

Although the API guesses language from the script, long texts often contain mixed scripts or proper nouns that may confuse the detector. Explicitly providing the language ISO code (e.g., "en", "de", "ja") ensures the model applies the correct pronunciation rules consistently, preventing accents from shifting between chunks.

Language Detection

Sound wave illustration for: Language Detection

The API guesses the language from the script when the language field is omitted, defaulting to English for Latin script. This automatic detection simplifies basic integration but may misinterpret texts with mixed scripts or ambiguous phrasing. For precise control, explicitly set the language parameter using an ISO code to ensure consistent synthesis across diverse content libraries.

Accurate language specification is critical for language learning platforms to maintain pedagogical integrity. Relying solely on detection can lead to incorrect pronunciation in multilingual educational materials. Developers should verify the detected language against their expected input to avoid subtle errors in voice output.

Automatic detection limits

Detection relies on script analysis rather than semantic context. Latin text defaults to English, which may cause errors for other Latin-script languages. Non-English texts in Latin script should explicitly set the language field to prevent incorrect voice synthesis.

The system does not support Vietnamese, Indonesian, Thai, Ukrainian, Romanian, Czech, Bengali, or other languages outside the 23 supported list. Using an unsupported language may result in default English pronunciation or errors.

  • Latin script defaults to English
  • No semantic language identification
  • Unsupported languages excluded from list

Forcing language codes

Explicitly setting the language parameter ensures the engine applies correct phonetic rules. This is essential for multilingual educational content where accurate pronunciation is required for learning objectives.

Use ISO 639-1 codes (e.g., de for German, ja for Japanese). This overrides automatic detection and guarantees consistent voice behavior across different text inputs.

  • Use ISO 639-1 codes
  • Overrides automatic detection
  • Ensures phonetic accuracy

Mixed-language texts

For texts containing multiple languages, ensure the language code matches the dominant language or the specific voice's capability. The API does not automatically switch voices for language changes within a single request.

Split long mixed-language texts into chunks where each chunk has a consistent language. Set the language field for each chunk to ensure accurate pronunciation across language boundaries.

Note that all 8 voices can speak all 23 supported languages, but explicit language codes improve accuracy in mixed contexts.

  • Split by language boundary
  • Set explicit language per chunk
  • All voices support all 23 languages

Storage Considerations

Sound wave illustration for: Storage Considerations

Audio synthesis returns binary data directly in the HTTP response. For long texts processed in chunks, your application must temporarily store each audio segment before concatenation. Since generated audio is not stored by the API, you are responsible for managing these files during the build phase.

Temporary file storage

Store raw audio bytes in memory or local disk buffers while processing. Keep file names unique per request ID to prevent overwrites during concurrent operations. Ensure your storage layer can handle concurrent writes if multiple texts are being synthesized simultaneously.

Cleanup after concatenation

Once segments are merged into the final audio file, delete the temporary chunk files immediately. This prevents disk space exhaustion, especially during batch processing of large novels or extensive course materials. Do not rely on automatic cleanup mechanisms unless explicitly configured.

Bandwidth usage for large files

Each chunk transfer consumes bandwidth proportional to its duration and format. MP3 files are significantly smaller than WAV or FLAC, reducing transfer costs and latency. Plan your egress bandwidth based on the total character count, noting that longer texts generate more API calls and thus more data transfers.

  • MP3 is recommended for efficient bandwidth usage
  • WAV files are significantly larger than MP3
  • FLAC offers lossless quality

Testing Strategies

Sound wave illustration for: Testing Strategies

Testing ensures your integration handles volume and quality correctly before production. Start by verifying the API responds to standard requests with expected latency and format consistency. This baseline confirms your network configuration and key permissions are correct.

For larger projects, validate the entire workflow from text input to final audio file. This includes checking character counting accuracy and ensuring the concatenation logic preserves timing between segments. Regular testing prevents costly errors when processing extensive libraries.

Small sample testing

Begin with short texts under 100 characters to verify basic connectivity and authentication. Use the free trial credit to test different voices and formats without risking your balance. Confirm that the response time aligns with the documented ~25 characters per second speed for short phrases.

  • Verify JSON response structure
  • Test all 8 voice presets
  • Confirm format output (mp3, wav, etc.)

End-to-end pipeline test

Process a 3,000-character text through your splitting logic and API calls. Ensure the client correctly divides the text into valid chunks and reassembles the resulting audio files. Check that the total duration matches the expected length based on the input character count and speed parameter.

  • Validate chunk boundary logic
  • Check audio file continuity
  • Verify total duration accuracy

Audio quality verification

Listen to the concatenated output for abrupt cuts or silence gaps between segments. Ensure the voice remains consistent across all chunks, as the API does not guarantee perfect cross-chunk continuity. Verify that the watermark is present and the audio format matches your specification.

Cost Estimation

Sound wave illustration for: Cost Estimation

Understanding the cost structure is essential for budgeting large-scale audiobook projects. The pricing model is straightforward: $10 per 1 million characters, which equals $0.01 per 1,000 characters. Spaces and punctuation are counted as characters, so accurate text measurement is critical for precise cost prediction.

Failed requests incur no charge, providing a safety net against processing errors. This means you only pay for successfully generated audio files, simplifying financial forecasting for development teams managing extensive text libraries.

Calculating total characters

Begin by measuring the total character count of your source text, including all spaces and punctuation marks. This baseline figure determines the base cost before accounting for any additional processing overhead.

Ensure your text processing pipeline accurately counts characters before sending them to the API. This prevents unexpected charges due to miscalculated volumes during large batch operations.

  • Include spaces and punctuation in your character count.
  • Measure total input text length before splitting.
  • Verify character count accuracy in your preprocessing step.

Predicting API call volume

Since each request is limited to 4,096 characters, divide your total character count by this limit to estimate the minimum number of API calls required. This calculation helps you anticipate rate limit impacts and queue times.

For a 100,000-character novel, you will need approximately 25 requests. Multiply this by the per-character rate to estimate the total processing cost for the project.

  • Divide total characters by 4,096 for minimum request count.
  • Account for partial chunks requiring an additional request.
  • Consider queue times for budgeting duration, not just cost.

Budgeting for large projects

With a free trial credit of $0.50 (approx. 50,000 characters), you can validate your splitting logic before committing funds. For larger projects, plan for USDT top-ups on the TRON network, as no other payment methods are available.

Set aside a buffer for edge cases where text length calculations might be slightly off. Since there are no monthly plans or minimum spends, you only pay for what you process, allowing for flexible budget allocation.

  • Use trial credit for initial validation.
  • Plan USDT top-ups for larger volumes.
  • No minimum spend or monthly fees.

Common Pitfalls

Sound wave illustration for: Common Pitfalls

Developers often overlook the mechanical constraints of the API, leading to fragmented audio or unexpected billing surprises. The 4096-character hard limit and 60 requests-per-minute cap are strict boundaries that require careful client-side management rather than relying on backend retries alone.

Truncating mid-sentence

Splitting text at arbitrary byte counts frequently cuts words in half, producing unnatural pauses. Always split at whitespace boundaries and verify that the last chunk does not exceed 4096 characters, including spaces and punctuation.

  • Check character count before every API call.
  • Ensure splits occur after complete words.
  • Validate that no single request exceeds the limit.

Inconsistent speed settings

Applying different speed multipliers to separate chunks creates jarring audio transitions. If processing a long novel, enforce a uniform speed value (e.g., 1.0) across all requests to maintain consistent pacing and listener experience.

  • Set speed explicitly in every request object.
  • Avoid defaulting to different values per chunk.
  • Verify audio tempo consistency in final concatenation.

Ignoring rate limits

Exceeding the 60 requests per minute limit triggers immediate throttling. Without staggered sending or queue management, long texts will stall, increasing total processing time significantly. Monitor the Retry-After header if available, though the API processes requests sequentially under load.

  • Cap concurrent requests at 60 per minute.
  • Implement exponential backoff for failures.
  • Account for queue wait times in long texts.

Best Practices for Developers

Sound wave illustration for: Best Practices for Developers

Streamline integration by using the official OpenAI SDK, modifying the base URL to https://api.rm9.info/v1. This approach leverages existing client libraries for authentication and request serialization, reducing boilerplate code for indie developers building language learning platforms.

Using the OpenAI SDK

Configure the SDK’s base URL to point to our API endpoint. This allows you to use standard tts-1 or tts-1-hd model parameters without writing custom HTTP handlers, ensuring compatibility with established development workflows.

Implementing retry logic

Requests process sequentially; under load, a request may wait in a queue. Implement exponential backoff to handle transient 5xx errors or rate limit responses (429). Failed requests incur no charge, so retrying failed chunks is safe and cost-effective.

Logging request metadata

Store request time, character count, and status for billing reconciliation. Since we retain this metadata, you can accurately audit usage against your balance without relying on external tracking tools.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. Selecting the appropriate voice preset ensures that the audio remains engaging without demanding excessive cognitive effort from the audience.

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. LibriVox public-domain audiobooks
  3. TRON developer hub: TRC-20
  4. Node.js documentation
  5. Python documentation
  6. OpenAI API reference: create speech
  7. IETF RFC 7845: Ogg Opus
  8. openai-node on GitHub
  9. W3C WAI: making audio and video accessible
  10. Tether (USDT)
  11. openai-python on GitHub
  12. MDN: Web Speech API

More on this site