# Dubbing Pipeline Throughput Simulator

## PURPOSE
The ad claims a creator gets "dubbed versions of all your videos in your voice in
just a few minutes" after choosing "all the languages you want." That is a capacity
claim. This project simulates the dubbing pipeline as a queueing system: video
uploads arrive, each must be transcribed, translated, voice-synthesised, and QA'd
per target language, and GPU/voice workers are limited. The simulator answers the
practical creator question — how many languages can one creator ship, and how does
the estimate change when a popular video gets 10,000 simultaneous uploads?

## WHY THIS MATTERS
The transcript implies a latency promise ("a few minutes"). Latency promises are
really throughput promises under load. Students learn to separate *service time*
(how long one dub takes) from *wait time* (how long it waits in queue) and to see
why "five retakes" collapse into one submit that still takes real compute.

## HOW TO BUILD
Framework: **SimPy** (discrete-event) + **NumPy** for stats. Steps:
1. Model each stage (`translate`, `tts`, `qa`) as a SimPy `Resource` with N servers.
2. A `dub_job` process requests each resource in turn and records timestamps.
3. Generate arrivals with an exponential/`np.random` inter-arrival process.
4. Run the sim and print p50/p95 end-to-end latency and per-stage utilisation.

```python
def dub_job(env, job, stages, stats):
    start = env.now
    for res in stages.values():
        with res.request() as req:
            yield req
            yield env.timeout(res.service_time)
    stats.append({"job": job, "latency": env.now - start})
```

## WHEN TO USE IN PRODUCTION
Use it for capacity planning before scaling a real dubbing service: sizing GPU
pools, deciding how many languages to offer at launch, and setting honest SLA
numbers. It is also useful for cost modelling per language. Do NOT use a pure
queueing model when quality-driven retries dominate or when jobs share a single
model endpoint with batching — those need a different model. It is not a substitute
for load-testing the real system.

## HOW IT HELPS STUDENTS
Students gain intuition for Little's Law, utilisation vs latency curves, and the
difference between average and p95 experience. They practise turning a product
promise into a measurable, tunable simulation.

## STARTER CODE
See `starter/main.py` for a SimPy model with per-stage worker pools, a NumPy-driven
arrival stream, deterministic seed, and `# TODO` markers for per-language routing
and retry logic.
