Offline Audio Moderation Pipeline: End-to-End Architecture
System DesignModel answerLast updated
Design a batch pipeline that screens stored audio files for policy violations, labels each as safe, unsafe or uncertain, and routes uncertain ones to human reviewers.
Problem
A platform lets users upload audio files (voice clips, music, sound effects). You must design a system that inspects each stored file, not a live stream, and decides whether it is acceptable to publish.
Choosing or training the individual ML models is out of scope. Show instead how the building blocks fit together: speech-to-text, spectral/loudness analysis, keyword detection, noise reduction, and a rule-based post-processor that combines their outputs.
What to cover
- Requirements. Functional and non-functional, with explicit scale assumptions (uploads per day, file length, latency target).
- Entities and data model. Key records, what lives in a database versus an object store, and how you guarantee idempotency.
- Architecture. Storage, compute, and orchestration.
- Discovery. How newly saved files are found and started: scheduled batch versus event-driven, and what you do about missed events.
- Processing flow. From ingestion through to a final result, including where each component sits.
- Outcome classification. How a file ends up as
clean,problematic, orneeds human review. - Manual review workflow. Task assignment, labeling, multi-reviewer agreement, requeueing, and audit trail.
- Operations. Scalability, throughput and latency targets, data retention, fault tolerance, backfilling after policy or model changes, and cost controls.
- Measurement. Success metrics plus monitoring and alerting for both product quality and system health.
State your assumptions and explain the trade-offs behind your choices.
Hints
Hint 1
Start with numbers: estimate files per day, average and peak rate, total audio-hours, and the GPU capacity needed for transcription. These drive the batch-vs-event and autoscaling choices.
Hint 2
Treat the three-way outcome as two thresholds per category: a high one for confident blocking and a low one for confident approval. Everything between, plus low-confidence or unprocessable inputs, goes to humans. Never default a failed decode to clean.
Hint 3
Make every stage idempotent (unique key on asset plus pipeline version), keep large artifacts in object storage with pointers in the database, and pair event-driven triggers with a periodic reconciliation sweep so nothing is silently skipped.
Hint 4
For the review loop, think leases with expiry, per-language queues, required votes with escalation on disagreement, and feeding final labels back to tune thresholds and retrain.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Requirements and scale
Functional
- Every uploaded file gets a verdict:
clean,problematic, orneeds_review, with reason codes and time ranges. - Targets: profanity, slurs, harassment and personal data in speech (multilingual); harmful sounds such as extreme loudness or screaming; known-bad or copyrighted audio.
- Files stay unpublished until cleared.
- Human review with audit trail and appeals.
- Ability to re-run history when policy or models change (backfill).
Non-functional (assumptions)
- ~2M uploads/day, average 30 s, max ~7 min. That is ~23 files/s on average and ~70/s at peak.
- Audio volume is ~17k hours/day. With batched GPU speech-to-text at roughly 100x real time, that is ~170 GPU-hours/day: about 8 GPUs on average, autoscaling to ~25.
- Raw storage ~1 TB/day.
- Latency: p95 time-to-verdict under 2 minutes for files under 60 s. Backfill is throughput-bound.
- Reliability: at-least-once processing, idempotent results, no silent skips.
- Quality: favor recall on severe categories, but keep auto-block precision high (e.g. at least 95%) so creators are not wrongly punished.
2. Entities and data model
- AudioAsset: id, uploader, storage URI, content hash, perceptual fingerprint, duration, format, status, timestamps.
- AnalysisJob: id, asset id, pipeline version, state, attempts, current stage, priority (realtime or backfill). Unique on (asset, pipeline version).
- StageResult: job, stage, model version, output pointer, scores, latency. Transcripts and spectral features live in object storage; the DB holds pointers.
- Verdict: asset, decision, reason codes, flagged segments, rule version, source (auto or human), confidence.
- ReviewTask and ReviewLabel: queue, priority, required votes, assignee, lease expiry; reviewer, label, policy codes, notes, time spent.
- AuditLog: append-only record of every state change with actor, time and versions.
Metadata goes in a relational DB, audio and artifacts in an object store, and the audit log in a write-once bucket or an event log sunk to the warehouse.
3. Architecture and discovery
Upload service writes to object storage, which emits an object-created event to a queue. A workflow orchestrator (Temporal or Step Functions style) runs the stages, each with its own task queue and autoscaled worker pool (GPU for transcription, CPU for the rest).
Discovery: use events as the primary path for low latency and natural backpressure. Add a reconciliation cron (every ~10 min) that finds assets still pending with no active job older than a threshold and re-enqueues them, because notifications can be lost. Pure cron batching is simpler but adds minutes of latency and bursty load; use it for backfills only.
4. Processing flow
- Ingest: validate, hash, create job (deduplicated by asset and pipeline version).
- Decode/normalize: convert to 16 kHz mono PCM. A corrupt file becomes a terminal failure routed to review, never clean.
- Dedupe: exact or perceptual fingerprint match reuses a prior verdict and catches re-uploads of banned or copyrighted audio cheaply.
- Noise reduction: applied only to the speech branch. Spectral analysis uses the raw signal so denoising cannot mask loud or harmful content.
- Voice activity detection and chunking: drop silence, cut into chunks of up to ~30 s for batched inference.
- Speech-to-text: transcript with word timestamps, confidence and language ID.
- Keyword detection: multilingual lexicon with obfuscation handling, optionally a text toxicity classifier; acoustic keyword spotting for words the recognizer mangles.
- Spectral analysis: loudness, peak/clipping, abnormal frequency energy, scream-type sound classifiers.
- Rule post-processor (versioned, config-driven):
- problematic: any hard rule (high-confidence slur, known-bad fingerprint, loudness beyond limit) or a score above the category's high threshold.
- clean: all scores under low thresholds and the pipeline is confident (speech transcribed well in a supported language).
- needs_review: everything else: mid-range scores, low recognizer confidence, unsupported language, decode failure, long files with sparse hits. Set the high threshold for target block precision and the low threshold for target recall, per category, from labeled data.
- Emit verdict: write verdict and audit event, update status, notify the asset service.
5. Manual review workflow
- Queues: separate by language and policy area; priority from severity, uploader reach/history and SLA age.
- Assignment: reviewers pull tasks under a lease (~10 min). Expired leases requeue automatically. Avoid assigning a reviewer their own content or the same reviewer twice.
- Labeling: structured label, policy code, and the offending time range, with the UI showing waveform, transcript and highlighted hits.
- Consensus: one vote for low-risk tasks, two or three for severe ones. Disagreement escalates to a senior reviewer. Seed hidden gold-standard tasks to measure reviewer accuracy.
- Requeue/appeals: appeals go to a different reviewer pool. Unresolved tasks past SLA are escalated.
- Audit: every assignment, label and decision is logged immutably. Final labels feed threshold tuning and retraining.
6. Scalability, reliability, cost
- Separate realtime and backfill priority lanes so backfills never starve fresh uploads.
- Autoscale GPU pools on queue depth; batch chunks to maximize GPU utilization; use spot capacity for backfill.
- Retries with exponential backoff, a dead-letter queue, and idempotent stages. Checkpoint per stage so a failure does not redo transcription.
- Cost controls: dedupe first, skip silence, run cheap checks (fingerprint, loudness) before expensive ones, and only transcribe when speech is present. Short-circuit on a hard-rule hit.
- Retention: keep raw audio for the policy window, intermediate artifacts for a shorter period (e.g. 30 days), and verdicts, labels and audit logs long term. Honor deletion requests, and apply legal holds for violations.
- Backfill: new pipeline version creates new jobs (unique key allows this), runs at low priority, can be limited to a sample or high-risk segment first, and compares old versus new verdicts before changing any live status.
7. Metrics and monitoring
Quality: precision and recall per category (measured via review samples and audits of auto-clean files), share of files sent to review, reviewer agreement, appeal overturn rate, and escaped-violation reports from users.
System health: time-to-verdict p50/p95/p99, queue depth and age, per-stage error and retry rates, GPU utilization, dead-letter count, reconciliation catches (a rising number signals lost events), and cost per file.
Alerts: SLA breach, growing backlog, spike in failed decodes, sudden shift in verdict mix (often a bad model or rule release), and review queue aging.
Common mistakes
- Treating decode failures or low-confidence transcripts as clean.
- Relying only on events with no reconciliation.
- Running spectral checks on denoised audio.
- One threshold instead of two, leaving no principled review band.
- No idempotency, so retries and backfills create duplicate verdicts.
- Letting backfill traffic compete with new uploads.