Prompt
I'm building a batch job that turns documents into audio
Latest observation
Oct 11, 2026
OpenAI APIWeb search: off
Great use case. A document-to-audio batch job usually has a pretty clean pipeline:
-
Ingest documents
- PDF, DOCX, TXT, HTML, etc.
- Normalize them into plain text.
-
Clean and segment text
- Remove headers/footers, page numbers, weird spacing.
- Split into chunks that are suitable for TTS, often by paragraph or sentence.
- Keep chunk sizes within your TTS model/API limits.
-
Generate speech
- Send each chunk to a text-to-speech engine.
- Capture audio per chunk.
- Preserve metadata like document ID, chapter, and chunk order.
-
Post-process audio
- Concatenate chunks into a single file per document.
- Add pauses between sections if needed.
- Normalize loudness and encode to your desired format, e.g. MP3 or M4A.
-
Store and track
- Save output audio files to object storage.
- Store job status, retries, failures, and lineage in a database or queue.
-
Operational concerns
- Retry failed chunks.
- Make processing idempotent.
- Handle long documents with progress reporting.
- Add rate limiting if you’re using an external TTS API.
A simple architecture might be:
- Queue: SQS / RabbitMQ / Kafka
- Worker: pulls doc jobs and processes chunk-by-chunk
- Storage: S3/GCS/Azure Blob for audio
- DB: job state, chunk offsets, output links
- TTS: cloud TTS API or local model
- Composer: ffmpeg to merge audio segments
A practical data model could be:
document_jobsjob_idsource_uristatuscreated_atupdated_atoutput_uri
document_chunkschunk_idjob_idchunk_indextextaudio_uristatusretry_count
If you want, I can help with any of these next:
- a system design
- a Python batch-worker example
- a database schema
- a chunking strategy
- or TTS provider recommendations