# Dub Transcript QA CLI

## PURPOSE
Sarvam Content Studio promises "you can review and edit every word that goes out."
This project is the command-line tool a content team runs *after* a dub is
generated: it loads the original and dubbed subtitle transcripts (SRT/CSV),
aligns them segment by segment, and flags problems — untranslated lines, timing
drift, missing segments, and segments where the dubbed word count diverges sharply
from the source. It solves the review bottleneck the ad highlights: reviewing work
"you have already finished" across five languages by hand.

## WHY THIS MATTERS
The transcript's key claim is that the dub is "still your video, your voice, and
your explanation." That guarantee only holds if someone can verify each word.
Automated QA turns a subjective spot-check into a repeatable, per-segment report.

## HOW TO BUILD
Framework: **Click** + **Pandas**. Steps:
1. `qa check --source en.srt --target hi.srt` loads both into DataFrames.
2. Align by segment index and join.
3. Compute flags: empty target, ratio of word counts, and start-time drift.
4. Print a summary table and return a non-zero exit code if issues exceed a
   threshold (so CI can gate a release).

```python
@click.command()
@click.option("--source", required=True)
@click.option("--target", required=True)
@click.option("--ratio-tol", default=0.4)
def check(source, target, ratio_tol):
    df = align(load_srt(source), load_srt(target))
    df["flag"] = (df["target_text"].str.len() == 0) | (
        (df["word_ratio"] - 1).abs() > ratio_tol)
    click.echo(df[df["flag"]])
```

## WHEN TO USE IN PRODUCTION
Use in a dubbing pipeline's QA gate, in localization review tools, and as a
pre-publish CI check for video platforms. Ideal when creators ship many languages
at once. Do NOT use it as the *only* quality check — semantic accuracy and emotion
need human or model judgement; word counts cannot catch a fluent mistranslation.
Skip it for single-language videos where no translation stage exists.

## HOW IT HELPS STUDENTS
Students learn SRT/CSV parsing, Pandas joins and vectorised flagging, and Click's
option/exit-code patterns. They also learn to design checks that map to a real
business guarantee instead of arbitrary rules.

## STARTER CODE
See `starter/main.py` for a Click CLI with SRT parsing, an alignment join, and
deterministic QA flags; replace the simple heuristic scorer with a `# TODO` model
call for semantic checks.
