Design a Text-to-Speech Platform: Scope It, Stress It, Extend It
System DesignModel answerLast updated
Prototype a scalable TTS service using a hosted synthesis API, then justify its trade-offs, find its first bottleneck, and plan bulk-document narration support.
A product team on an AI platform org wants to ship a text-to-speech (TTS) capability as a service. You have a take-home budget of roughly 8–12 hours to produce a working prototype, a short design write-up, and session logs from whatever AI coding assistants you use. Synthesis itself is supplied: you may call an existing TTS model or a hosted TTS API, and you should state that assumption up front (and confirm it if interviewing). The interesting work is everything around the model — the API, the request pipeline, storage, retries, progress reporting, and the developer experience.
Assume during the review that your submission is a prototype and that every shortcut will be found and interrogated.
Part 1 — Scope and build. Decide what the prototype does inside the time box and what it explicitly defers (with reasons). Specify the public API, the request flow for both short and long inputs, the data model (so repeated requests, retries and progress are possible), and how you keep the API responsive while synthesis runs. Also describe how you direct AI coding agents so that the submitted logs demonstrate a disciplined workflow rather than paste-and-pray.
Part 2 — Trade-off review. Present a rough throughput and cost estimate that identifies where the system saturates first. Defend your choices on chunk size, streaming audio versus delivering finished files, and self-hosted versus hosted synthesis. Name customer needs the prototype does not yet meet (voice consistency across chunks, pronunciation control, quota enforcement, etc.) and UX gaps around failures, duplicates and progress.
Part 3 — New requirement. A customer wants to submit many long documents in one API interaction, be notified when each narration completes, and hear a single consistent voice throughout each document. Explain the API and system changes, how voice identity survives chunking and model upgrades, how you protect against retries creating duplicate work, and give a task-level estimate plus a roadmap order with success metrics.
Hints
Hint 1
Separate the synchronous control plane (submit, poll, fetch) from the asynchronous data plane (chunk, synth, stitch) — most answers collapse them and then have no story for long inputs.
Hint 2
Pick concrete numbers (characters per chunk, requests per second, seconds of audio per character) and let the estimate tell you the bottleneck instead of asserting it.
Hint 3
For Part 3, think about what an idempotency key protects, what a webhook needs in order to be safely retried, and what actually makes a voice 'the same' across chunks and across provider model versions.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Part 1 — Scope and shape of the prototype
I'd open by locking the assumption: synthesis is delegated to a hosted TTS API; I own orchestration, storage, and the API surface. Then I'd cut scope to one end-to-end path that actually works: submit text → job created → audio produced → signed URL returned, plus polling for status. Deferred and documented with reasons: voice cloning, SSML/pronunciation overrides, multi-region deployment, billing, and a real web UI (a thin CLI or curl examples substitute).
API. Three endpoints: POST /v1/syntheses with {text, voice_id, format}, returning 202 and {job_id, status_url}; GET /v1/syntheses/{job_id} returning status (queued|running|succeeded|failed), progress as characters completed, and a signed audio_url when done; DELETE to cancel. Callers optionally pass an Idempotency-Key header.
Request flow. The API handler validates input and size, writes a job row, and enqueues a message — it never synthesizes inline. A worker pulls the job, normalizes text, sentences the text down to chunks of roughly 300–800 characters at sentence boundaries (bigger chunks amortize API round-trips; smaller chunks bound the blast radius of a failure and keep time-to-first-audio low), calls the provider per chunk, writes each audio segment to object storage, then concatenates segments into one file and records the duration and a content hash.
Data model. jobs(id, idempotency_key UNIQUE, text_hash, voice_id, status, chars_total, chars_done, error_code, audio_key, created_at, updated_at); segments(job_id, idx, audio_key, status, attempt). Progress is just chars_done / chars_total, updated per segment, so polling needs no extra machinery and a crashed worker's job can be resumed from the first segment not marked done. Idempotency keys map to the existing job so a retried POST returns the same job_id instead of re-billing characters.
Working with agents. I'd write a short spec file first (API contract, data model, failure semantics) and feed it to the assistant as standing context, then work in small task slices — "migration + model", "POST handler + idempotency test", "worker chunker with unit tests". Every generated diff gets read before merge; I keep tests as the acceptance gate, and I deliberately ask the agent to enumerate edge cases (empty text, oversized input, provider 429, worker restart mid-document) so the log shows review and correction, not just generation.
Part 2 — Trade-offs and the first wall
Estimate. Suppose the provider synthesizes about 1,000 characters per second of compute (roughly one minute of audio per thousand characters) and I run 20 concurrent worker slots. That's ~20k characters/sec sustained ≈ 1.7B characters/day ceiling. Each job also costs a few object-storage writes and a concatenation; concatenation of a 50k-character document means ~70 segments, so stitching is cheap but not free. Cost per million characters depends on the provider (order $10–$100); storage is negligible at 1 MB/minute of audio.
The first bottleneck is almost never the API tier — it's provider concurrency and rate limits. The queue absorbs bursts and grows unbounded, so backpressure and per-tenant fairness matter more than adding web instances. Second limit is worker slot count on the paid TTS tier; third is concatenation and cold-start latency on very long documents.
Trade-offs. Chunk size trades latency and fault isolation against per-call overhead and seam quality. Streaming audio to the client as the first chunks complete dramatically improves perceived latency for long text, but complicates retries (you can't unsend bytes), so I'd stream only for interactive playback and keep finished-file semantics for batch. Hosted synthesis wins on time-to-market, quality and ops burden; self-hosting only makes sense past very large volume, where GPU utilization and voice-model control justify the ops cost — and it's the only option if the customer needs custom voices or data residency.
Gaps. No voice consistency guarantee when chunks are synthesized independently (prosody can drift at seams), no pronunciation lexicon/SSML, no per-tenant quotas or abuse protection, no webhook notifications, and weak UX for failures: a failed job surfaces a raw error and the caller must resubmit manually.
Part 3 — Bulk documents, notifications, one voice
API changes. Add a batch endpoint accepting a list of documents, each with a client-supplied document_id (the idempotency handle), returning a batch id and per-document job ids. Make idempotency per-document so retried submissions don't duplicate work — dedupe on (tenant, document_id) with a unique index and return the existing job. Add webhooks: register a callback URL and secret, sign payloads (HMAC + timestamp), and deliver completion events with exponential-backoff retries and a dead-letter queue; also add GET /batches/{id} for reconciliation so the customer never depends on webhooks alone. Webhook receivers must tolerate duplicates, so events carry an event_id and are at-least-once.
Voice consistency. Within a document, pin a single provider voice ID and a fixed synthesis config (speaker embedding, style parameters) recorded on the job; pass a stable speaker reference and synthesize on sentence boundaries so seams fall at natural pauses. Across a provider model upgrade, that voice ID may map to a materially different embedding, so I'd version the voice config and pin model versions per document — narrations started under version N finish under version N, and the roadmap includes an audition/compatibility check before rotating versions.
Estimate and roadmap. Roughly: batch API + idempotency (1–2 days), notifications with retries and DLQ (2–3 days), voice pinning/versioning (2–3 days), load test and quota enforcement (2 days), plus a week of hardening — call it three to four engineering weeks with the main risks being webhook reliability and provider rate ceilings under bulk load. Roadmap order: (1) idempotency + batch submission, measured by duplicate-job rate and batch throughput; (2) webhooks, measured by notification delivery latency and p99; (3) voice versioning, measured by seam-difference/QA pass rate across documents; (4) quotas and fair scheduling, measured by p95 queue wait per tenant. I'd close by noting the honest weakness of the prototype: it has no seam-quality measurement, so "one consistent voice" is a claim I'd validate with a listening test before promising it to a customer.