Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Transcribe?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/opencairn-transcribe)
---
name: transcribe
description: Transcribe audio files or YouTube videos locally with Parakeet GGUF by default for English, WhisperX fallback, and optional speaker diarisation
---
# Transcribe — Audio to Text
Transcribe audio files locally. Handy Parakeet V3 GGUF is the default for English; WhisperX is available for retries, other languages, or when Handy/GPU support is unavailable. Both paths use WhisperX alignment and optional pyannote diarisation.
## When to use
When the user wants to transcribe an audio recording (voice memo, meeting, interview, lecture) or a YouTube video. Use when the user asks for a transcript, not merely because a message contains a media path or YouTube URL. For a digest request, use `$podcast-digest`.
## Codex execution
Read supporting files relative to this skill directory, not the shell working directory. For vault work resolve `VAULT_PATH` with `"${VAULT_PATH:?VAULT_PATH not set}/.claude/scripts/resolve-vault.sh"`; stop if resolution fails. All vault writes, including headers and verbatim bodies, use `locked-edit.sh`.
Use tracked Codex exec sessions for long local runs; if execution returns a session ID, poll that session to completion and inspect its exit code. Do not detach local transcription with shell `&`. Keep stderr in a scratch file for diagnostics and provide progress while waiting. Shell variables do not persist between exec calls: carry literal scratch paths forward or reload a saved job config.
Honour output, speaker names and save/discuss choices already supplied by the user. Ask only for missing decisions; optional speaker renaming need not block an explicitly requested save with generic labels. Choosing paid cloud transcription requires the user's authorisation; use the installed `../transcribecloud/SKILL.md` after reading it.
## Prerequisites
- Python venv with `whisperx` installed at `~/venvs/whisperx/`
- `ffmpeg` installed (for audio decoding; `ffprobe`, bundled with it, is used for duration probing)
- For YouTube URLs: `yt-dlp` installed
- For diarisation: HuggingFace token (via `HF_TOKEN` env var or `huggingface-cli login`). The user must have accepted the pyannote model licences at huggingface.co/pyannote/speaker-diarization-3.1, huggingface.co/pyannote/speaker-diarization-community-1, and huggingface.co/pyannote/segmentation-3.0. (The Phase 2 script pins `speaker-diarization-3.1`, which pulls `segmentation-3.0`; `community-1` is WhisperX ≥3.8's default and covers the fallback if the pin is ever removed.)
If any prerequisite is missing, tell the user what to install and stop. **Exception — venv exists but the import fails:** check for Python-version drift before concluding whisperx is missing. Compare `rg version ~/venvs/whisperx/pyvenv.cfg` against `~/venvs/whisperx/bin/python3 --version`: a mismatch means an OS Python upgrade broke the venv (packages sit stranded under the old `lib/pythonX.Y/site-packages`) — the fix is to recreate the venv and reinstall whisperx (compiled wheels are Python-version-specific), not to install anything new.
## Arguments
The free-text arguments following the skill invocation — path to the audio file or a YouTube URL, optionally followed by flags. If no path is provided, ask the user.
Flags (parsed from arguments):
- `--diarize` or `--diarise` — enable speaker diarisation
- `--speakers N` — exact number of speakers (implicitly enables diarisation)
- `--min-speakers N` / `--max-speakers N` — speaker count range (implicitly enables diarisation)
- `--engine whisperx|handy-gguf` — default `handy-gguf` for English; `whisperx` explicitly selects the fallback. The Handy adapter requires English audio and the installed GGUF model; it does not detect the source language.
- `--raw` — skip LLM cleanup pass (save the selected engine's output)
- `--no-timestamps` — omit timestamps from output
- `--no-published` — skip the published-transcript check (Phase 0); use the selected local engine
## Workflow
### Phase 0: Check for a published transcript
A published transcript (podcast show site, Substack, official transcript page) is usually higher text-fidelity than any machine transcription, and free. Check for one *before* committing to a download + WhisperX run. "Published" does not entail "human-edited" — many are the publisher's own ASR output, which changes what you may claim in the header and how you resolve names and speakers (§15 "Names and speakers"), though it stays worth preferring over spending a WhisperX run. Skip this phase entirely if `--no-published` was passed, or if the source is a local audio file with no obvious online origin, or if the user explicitly said to transcribe the audio, or if diarisation was requested via flags (a published transcript cannot satisfy a diarisation request — a user-supplied transcript URL still wins per step 1).
1. **User-supplied transcript wins.** If the user provided a transcript URL or pointed at one ("the transcript is at X"), use it directly — go to step 4.
2. **Discover a candidate** (best-effort, for YouTube / named-podcast sources only):
- YouTube, *if `yt-dlp` is installed* (it isn't verified until Phase 1 — check `command -v yt-dlp` first): scan the description for a transcript link — `yt-dlp --print "%(description)s" "URL"` — for links whose text or target contains "transcript" or points to the show's own site. (Description only — fetching pinned/top comments needs `--write-comments` and isn't worth it; treat comments as out of scope.)
- Run **one** web search (if a web-search tool is available): `"<video/episode title>" transcript`. Prefer the official show/publisher page; treat third-party aggregator sites (usually auto-generated, not human-edited) as no better than WhisperX.
- If neither `yt-dlp` nor a web-search/fetch tool is available, skip discovery and fall through to Phase 1 — rely only on a user-supplied URL (step 1).
3. If no credible candidate is found, say so in one line and fall through to Phase 1. Don't over-search — this is a quick best-effort check, not a research task.
4. **Fetch and validate the candidate.** Read §15 of `../_shared-rules-content.md` (relative to this SKILL.md) first — this skill doesn't load that file wholesale, so the extractor isn't in context until you read it. Extract the body to a file with the **§15 extractor**, which needs `curl`/`pandoc`/`python3`+`bs4`/`lxml` (its prereq check is the gate — if those are missing, skip the published path and fall through to Phase 1's WhisperX run after telling the user). The body lands at `<BODY_FILE>` — §15's printed `BODY=` path, a **deterministic function of the URL**, so you can reuse that exact path in step 6 (or re-derive it from the URL); there is no random temp name to carry across tool calls. Judge it on structure with **shell probes, not by reading the whole body into context** — `wc -w "<BODY_FILE>"`, `rg -n` for speaker labels / transcript markers, and `head`/`tail` for a bounded look. Accept as a genuine transcript if it has sustained episode-specific prose AND either (a) speaker turn-taking, (b) continuous single-speaker prose (lectures/monologues have no turns), or (c) the page explicitly labels itself a transcript. Reject show notes, a summary, an excerpt, or a paywalled stub. As a sanity floor, *if you can cheaply get duration* (`yt-dlp --print "%(duration)s" "URL"` for YouTube), expect ≳80–100 words per minute of audio — but don't reject a labelled transcript just for running light, and skip the floor when duration is unknown. If it's a summary or partial, discard it and fall through to Phase 1.
5. **Present the choice** (numbered list) and wait — don't auto-pick:
1. **Use the published transcript** — higher text fidelity; but typically **no timestamps**, and speaker turns only where the source marks them (no diarisation). May be lightly cleaned of filler. **Don't assume human editing** — check for the auto-generated disclaimer (§15 "Names and speakers") and say which kind it is when presenting the choice: an auto-generated one carries WhisperX-grade name-garbling and speaker-mislabelling.
2. **Run local transcription** — the selected engine with timestamps and optional diarisation; follow engine selection below.
6. **If the user picks the published transcript:** the body is already at `<BODY_FILE>` from step 4 (§15's printed `BODY=` path, reconstructable from the URL). Skip Phases 1–2 and the WhisperX-specific parts of Phase 3 (no download, no WhisperX, no diarisation, and **no** LLM cleanup pass — the body is saved verbatim per §14, whoever produced it). Use the agreed destination, or ask where to save if missing. Phase 3 step 2 never runs on this path, so create the header's staging directory here with `STAGE=$(mktemp -d)` and carry its literal path. Stage only the metadata header there; assemble it with the existing `<BODY_FILE>` (the §15 `BODY=` path, not `$STAGE/clean.md`) directly from disk using Phase 3 step 7's locked save procedure. The published body must not pass through model context or LLM cleanup. Adjust the header:
- **Source:** the transcript URL; put the original audio / YouTube URL on a second `**Original media:**` line.
- **Date acquired:** use this run’s acquisition date instead of **Date transcribed**.
- **Model:** default `published transcript (provenance unverified)`; upgrade to `(source-provided, auto-generated)` on a disclaimer match, or to `(human-edited)` only where the page positively claims editing (§15's three-value ladder — the unverified value is the default precisely so a null cannot select the stronger claim). Either way the body is saved verbatim (`_shared-rules-content.md` §14); never clean it.
- **Names and speaker labels** in the header, filename or report follow §15 "Names and speakers" — already in context from step 4.
- Drop the **Diarisation** and **Cleanup** lines (or mark `n/a`); keep **Duration** only if known.
Otherwise (user picks local transcription, or no transcript was found/accepted), continue to Phase 1.
### Phase 1: Validate
1. **Determine source type.** If the argument is a YouTube URL (contains `youtube.com/watch` or `youtu.be/`), this is a YouTube source. Otherwise, confirm the audio file exists at the given path.
2. Check prerequisites are installed:
```bash
~/venvs/whisperx/bin/python3 -c "import whisperx" && command -v ffmpeg && command -v ffprobe
```
If YouTube source, also check: `command -v yt-dlp`
3. If checks fail, report what's missing and stop.
4. **If YouTube source** (steps a-c are independent — run in parallel):
a. Get the video title: `yt-dlp --print title "URL"`
b. Download audio as WAV: `yt-dlp -f "bestaudio[abr<=64]/worstaudio" -x --audio-format wav -o "/tmp/yt_transcribe_%(id)s.%(ext)s" "URL"`
- Whisper resamples to 16kHz mono internally, so a ≤64kbps source (typically YouTube format 249 @ 49kbps Opus) is plenty for transcription. Unconstrained `bestaudio` pulls format 401 (~100-250MB for typical videos, GB-scale for long ones) and is painfully slow on a slow link.
c. Download auto-generated English captions (if available) for cross-referencing during cleanup:
```bash
yt-dlp --write-auto-sub --sub-lang en --sub-format srt --skip-download -o "/tmp/yt_subs_%(id)s" "URL"
```
The file lands at `/tmp/yt_subs_<id>.<lang>.srt` — glob `/tmp/yt_subs_<id>*` to locate the exact name for the Phase 3 cross-reference. If no English auto-captions are available (e.g. non-English video), retry with `--sub-lang` matching the video's language if known, or omit `--sub-lang` to get whatever is available. If still nothing, proceed without — this is a best-effort enhancement.
d. Set `INPUT_FILE_PATH` to the downloaded WAV path.
e. Store the YouTube URL and video title for use in the output metadata.
5. Get the audio duration:
```bash
ffprobe -v quiet -show_entries format=duration -of csv=p=0 "INPUT_FILE_PATH"
```
6. Check for CUDA support in the WhisperX environment:
```bash
~/venvs/whisperx/bin/python3 -c "import torch; print(torch.cuda.is_available())"
```
`False` means this WhisperX/PyTorch path cannot use CUDA; it does not mean the machine has no usable GPU. Parakeet GGUF uses a separate Vulkan/Metal backend. Verify its actual bound backend and device in the model-load log before claiming acceleration; a selected Auto setting or enumerated GPU alone is insufficient.
7. Determine if diarisation was requested (check for `--diarize`, `--diarise`, `--speakers`, `--min-speakers`, or `--max-speakers` in arguments — any of these enables diarisation).
8. If diarisation requested, verify HF token is available:
```bash
~/venvs/whisperx/bin/python3 -c "from huggingface_hub import HfApi; HfApi().whoami()" 2>/dev/null && echo "ok" || echo "no_token"
```
If no token, tell the user to run `huggingface-cli login` or set `HF_TOKEN` and stop. Note `whoami()` only proves the token is valid — it does not prove the pyannote licence gates were accepted; a 403 later, inside diarisation, means a licence page from the Prerequisites list still needs accepting.
9. **Background decision:** If diarisation is enabled, or the selected engine is WhisperX without CUDA and duration > 120s, tell the user the estimated wait and run as a **tracked Codex exec session**. Diarisation on CPU is slow (~2-3x audio length on top of transcription time).
- **Cloud escape hatch:** when the selected engine is WhisperX without CUDA and the job is heavy — audio > ~30 min, or a batch of files — surface `$transcribecloud` (RunPod GPU; same WhisperX) as a faster **paid** alternative *before* committing to a long local grind, and let the user choose. It costs money and needs `runpodctl` + credits, so don't auto-switch: if those are absent, say so and fall back to the local exec session. (This is the reciprocal of `$transcribecloud`'s own "use instead of `$transcribe` when the selected local engine lacks usable acceleration and audio > 30 min" trigger.)
### Engine selection and Handy GGUF input
Use Handy GGUF for English unless the user selects WhisperX. Establish the source language from reliable source information or a short language probe if unknown. For non-English or mixed-language material, select WhisperX with multilingual `large-v3` before inference; export `TRANSCRIBE_ENGINE=whisperx` and `TRANSCRIBE_WHISPER_MODEL=large-v3`. For an English WhisperX retry/fallback, use `distil-large-v3.5`.
If the default Handy route is unavailable or fails its GPU-binding check, retry locally with WhisperX and report the effective engine. Honour an explicit engine request by reporting its failure rather than silently switching. Do not change to paid cloud processing without authorisation.
For the Handy route, first verify `handy --help` advertises `--transcribe-file` and `--json`, and the requested GGUF model is already installed. Do not change live dictation settings or download/install software implicitly. Keep the normal WhisperX prerequisites: this route still uses its alignment and diarisation environment.
Convert the complete input with ffmpeg to **16kHz mono signed 16-bit PCM WAV**, using a unique scratch directory outside the vault. Run `scripts/handy_gguf.py` with `~/venvs/whisperx/bin/python3`, passing the WAV and a fresh scratch JSON path as positional arguments. The helper keeps all audio, divides it at quiet points near 30 seconds, transcribes through Handy, and returns timed chunk text. Set `TRANSCRIBE_INPUT` to that same converted WAV, `TRANSCRIBE_GGUF_JSON` to that JSON path, and `TRANSCRIBE_ENGINE=handy-gguf` in the Phase 2 exec call. Resolve the helper relative to this skill/command file, not the working directory.
The helper records the actual backend, durations and logs, and fails if a GPU binding is not verified. Use `--allow-cpu` only for an intentional CPU run; do not label that accelerated. Its text includes Handy's configured custom-word corrections, so record vocabulary/configuration when comparing engines. Chunk bounds are approximate: run the alignment below before presenting timestamps. Empty chunks may represent silence; inspect the source if they contain speech. Keep the existing output formatting, cleanup and locked-save rules, and use the actual `model` field in the transcript header.
### Phase 2: Transcribe
Run via a tracked Codex exec session, polling until completion. **Redirect stderr to a temp file** (not /dev/null). On success, discard it. On failure, read it for diagnostics.
Set these variables before substituting into the script:
- `TRANSCRIBE_ENGINE` — export the effective engine when overriding the English GGUF default; for multilingual WhisperX also export `TRANSCRIBE_WHISPER_MODEL=large-v3`
- `TRANSCRIBE_OUTPUT` — export a fresh JSON path in a unique scratch directory outside the vault in the same exec call; existing files are rejected
- `TRANSCRIBE_INPUT` — export the audio file path in the same exec call; for Handy, use the converted WAV passed to the helper
- `DIARIZE` — `True` or `False`
- `NUM_SPEAKERS` — integer or `None`
- `MIN_SPEAKERS` — integer or `None`
- `MAX_SPEAKERS` — integer or `None`
```bash
STDERR_TMP=$(mktemp)
~/venvs/whisperx/bin/python3 << 'PYEOF' 2>"$STDERR_TMP"
import os, json, hashlib
os.environ["TQDM_DISABLE"] = "1"
import torch
import whisperx
device = "cuda" if torch.cuda.is_available() else "cpu"
compute_type = "float16" if device == "cuda" else "int8"
batch_size = 16 if device == "cuda" else 4
audio_file = os.environ["TRANSCRIBE_INPUT"]
diarize = DIARIZE
num_speakers = NUM_SPEAKERS
min_speakers = MIN_SPEAKERS
max_speakers = MAX_SPEAKERS
# 1. Transcribe
engine = os.environ.get("TRANSCRIBE_ENGINE", "handy-gguf")
audio = whisperx.load_audio(audio_file)
engine_metadata = {}
if engine == "handy-gguf":
with open(os.environ["TRANSCRIBE_GGUF_JSON"]) as f:
result = json.load(f)
engine_metadata = result["engine_metadata"]
pcm_hash = hashlib.sha256((audio * 32768).astype("<i2").tobytes()).hexdigest()
if (abs(engine_metadata["duration_seconds"] - len(audio) / 16000) > 0.1
or engine_metadata["audio_sha256"] != pcm_hash):
raise ValueError("GGUF transcript/audio mismatch")
model_label = "handy / " + result["model"]
elif engine == "whisperx":
whisper_model = os.environ.get("TRANSCRIBE_WHISPER_MODEL", "distil-large-v3.5")
model = whisperx.load_model(whisper_model, device, compute_type=compute_type)
result = model.transcribe(audio, batch_size=batch_size)
model_label = "whisperx / " + whisper_model
else:
raise ValueError("Unknown transcription engine: " + engine)
language = result["language"]
# distil-large-v3.5 is English-only — its output on other languages is unreliable.
if engine == "whisperx" and whisper_model.startswith("distil-") and language != "en":
raise SystemExit(
f"Detected language '{language}', but distil-large-v3.5 is English-only. "
"Re-run with a multilingual model (large-v3) or use $transcribecloud."
)
# 2. Align (word-level timestamps)
model_a, metadata = whisperx.load_align_model(language_code=language, device=device)
result = whisperx.align(result["segments"], model_a, metadata, audio, device)
# 3. Diarize (optional)
if diarize:
from whisperx.diarize import DiarizationPipeline
try:
diarize_model = DiarizationPipeline(
model_name="pyannote/speaker-diarization-3.1",
device=device,
token=os.environ.get("HF_TOKEN"), # whisperx 3.8.x param is `token` (NOT use_auth_token, which is the older pod-pinned API in $transcribecloud); None → falls back to the cached huggingface-cli login
)
except Exception as e:
# Pipeline.from_pretrained returns None on auth/licence failure, so the
# constructor blows up inside itself (typically AttributeError on .to()).
raise RuntimeError(
"Diarisation pipeline failed to load — token rejected or licence gates not accepted "
"(see Prerequisites)"
) from e
diarize_segments = diarize_model(
audio,
num_speakers=num_speakers,
min_speakers=min_speakers,
max_speakers=max_speakers,
)
result = whisperx.assign_word_speakers(diarize_segments, result)
out_path = os.environ["TRANSCRIBE_OUTPUT"] # fresh JSON path inside this run's unique scratch directory
with open(out_path, "x") as f:
json.dump({"segments": result["segments"], "language": language, "model": model_label, "engine_metadata": engine_metadata}, f)
print(out_path)
PYEOF
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then cat "$STDERR_TMP"; fi
rm -f "$STDERR_TMP"
exit $EXIT_CODE
```
Replace the boolean/integer placeholders with validated values. Export `TRANSCRIBE_INPUT` in the same exec call using proper shell quoting of the supplied path; never interpolate a path into Python source. Give concurrent runs distinct scratch/output paths instead of reusing a basename-derived JSON from an earlier run.
### Phase 3: Post-process and output
1. **Parse the segments JSON** from the file whose path Phase 2 printed (word-level JSON for a long recording is far too large for tool stdout — read it from the file, in chunks if needed).
2. **Format the transcript:**
Determine the timestamp format from the audio duration: `[MM:SS]` for recordings under 1 hour, `[H:MM:SS]` for recordings 1 hour or longer. If `--no-timestamps` was passed, omit timestamps entirely.
**Without diarisation:** Insert a paragraph break wherever the gap between one segment's end and the next segment's start exceeds 1.5 seconds. Concatenate segment text within each paragraph.
**Monologue fallback.** For recordings longer than 5 minutes, after the initial split, check: is the paragraph count at least `duration_seconds / 120` (roughly one per two minutes)? If not, the source is a dense monologue without natural 1.5s pauses — recompute:
1. Sort all segment-to-segment gaps in descending order.
2. Let `N = min(floor(duration_seconds / 90), len(gaps_desc))` — target paragraph-break count (one break per ~90s), clamped to the number of available gaps.
3. Use `gaps_desc[N-1]` as the new threshold and re-split. If there are no gaps at all (`len(gaps_desc) == 0`, e.g. a single segment), skip the fallback and keep the initial split.
In your user-facing response, state the threshold actually used — either `(1.5s default)` or `(0.Xs — monologue fallback)` — so the choice is observable.
Prefix each paragraph with a timestamp derived from the first segment's `start` field:
```
[00:00] First paragraph of speech here.
[01:23] Next paragraph after a gap.
```
**Alignment-failure fallback:** if a segment has nonempty `text` but an empty/missing `words` array, preserve its text as a paragraph using its existing segment start and mark the timestamp approximate and alignment unavailable. Use its segment speaker if present, otherwise `Speaker unknown`; never drop the text or invent word times/speaker identity. This fallback also applies when formatting a non-diarised transcript.
**With diarisation:** Iterate over the **words** array (not segments), since a single segment often contains multiple speakers. Before grouping, forward/back-fill any words with a missing or `None` speaker from their nearest non-None neighbour (pyannote occasionally leaves words unassigned; treating `None` as its own speaker produces a spurious extra speaker). Then group consecutive words by speaker. Start a new paragraph when the speaker label changes OR when the gap between consecutive words exceeds 1.5 seconds. Prefix each paragraph with a timestamp and speaker label in bold:
```
[00:00] **Speaker 1:** First speaker's text here spanning one or more words.
[00:45] **Speaker 2:** Second speaker responds with their text.
[01:12] **Speaker 1:** First speaker continues after the other.
```
The timestamp is derived from the `start` field of the first word in each paragraph group.
Map raw labels (`SPEAKER_00`, `SPEAKER_01`, ...) to `Speaker 1`, `Speaker 2`, etc. in order of first appearance. The words array is found at `segments[].words[]`. Only `word` is guaranteed — `start`, `end`, `score` and `speaker` are all optional: alignment omits timing for tokens it can't align (numerals, symbols, out-of-vocabulary fragments), and speaker assignment skips any word without a `start`. Never index these keys directly. A word missing `start`/`end` keeps its text but contributes no timestamp and no gap: attach it to the paragraph in progress and take timing from the nearest neighbour that has it.
**Write the formatted body to a file, not into context.** Format with a script that writes `$STAGE/body.md`, creating `STAGE=$(mktemp -d)` once here; `echo "$STAGE"` and carry the literal path into steps 3–7, since shell state does not persist between calls. Under `--raw` this file is the body that gets saved.
3. **LLM cleanup pass** (skip if `--raw` was passed):
Review the assembled transcript text and fix transcription errors. Rules:
- Fix non-words to their most likely intended word (e.g. "seduptresses" → "seductresses")
- Fix obvious grammar/punctuation errors introduced by the transcription model (not the speaker's actual grammar — ESL patterns, filler words, etc. stay)
- Mark genuinely unclear sections as `[inaudible]` rather than guessing
- Preserve the speaker's actual words and meaning — don't rewrite, paraphrase, or "improve"
- Preserve timestamps exactly
- Preserve speaker labels exactly
- Do NOT fix the speaker's actual speech patterns (um, uh, repeated words, broken sentences) — these are features, not bugs. A model hallucination loop (a short token or phrase repeated many times, unlike the surrounding speech) is not speech: use the caption reading for that span (cross-reference below), else mark it `[inaudible]`
**YouTube caption cross-reference** (if YouTube auto-captions were downloaded in Phase 1 step 4c):
Before starting the cleanup pass, extract a focused comparison from the SRT captions. Parse the SRT to plain text, then identify words/phrases where the WhisperX and YouTube outputs diverge — especially proper nouns (names, institutions, products, technical terms), and hallucination loops, where the WhisperX output repeats a short token many times but the captions carry different content. Build a short divergence list (e.g. "WhisperX: 'Mercore' / YouTube: 'Mercor'") and use it as a reference during cleanup. Do not load the entire SRT into context — the useful signal is in the divergences, not the full text.
Neither source is authoritative — both are machine-generated and make different errors. Where one system produces a recognisable proper noun and the other produces a garbled version, prefer the recognisable one. Where both agree on a spelling that looks wrong (e.g. both say "Tyler Cowan" when context suggests "Tyler Cowen"), apply your own judgement. Where they disagree and neither is clearly right, flag with `[?]` or choose the more plausible option based on context.
**A third source outranks both, and it is usually already to hand:** human-written page text about the episode — the video description, the show notes, a chapter list, a linked resource list. Those are typed by a person; both machine transcripts are not. So for any name in the divergence list, grep that text for a distinctive fragment (match a stem — the garbling is phonetic) and **take the spelling it gives over either transcript's**, rather than adjudicating between two guesses or flagging `[?]`.
**Run the pass outside this session's context** with `transcript-clean.py`. It sends ~3,000-word chunks of the formatted body to a hermetic `claude -p` (no tools, MCP servers, settings, hooks or project instructions) carrying the rules above, and checks every chunk before writing anything: at least 90% of its words kept, its non-whitespace character count within 85–115% of the original, its first line and ending present, and its sequence of timestamps and speaker labels unchanged. The script's `RULES` mirror the bullets above; change both together. Put the divergence list and the human-written page text in a context file rather than applying them in-session, **divergence list first**: the script keeps only the context's first 6,000 characters and notes on stderr when it cuts, so page text past that point is dropped before the list would be.
```bash
STAGE=<literal path from step 2>
# optional: divergence list, then page text -> "$STAGE/page.txt"
python3 "${VAULT_PATH:?VAULT_PATH not set}/.claude/scripts/transcript-clean.py" --in "$STAGE/body.md" --out "$STAGE/clean.md" --context "$STAGE/page.txt" > "$STAGE/clean-report.json"; echo "exit=$?"
```
Drop `--context` when there is no page text.
- **exit=0** → `$STAGE/clean.md` is the body for steps 4–7; header `Cleanup: yes`.
- **exit=2** → a chunk failed a check and nothing was written. Read only that chunk's entry in `clean-report.json` and rerun once; if it fails again, keep `$STAGE/body.md` with `Cleanup: no (checks failed: <check>)`.
- **Any other exit** (1 the model call failed, 3 the `claude` CLI is not on PATH, or the script could not start) → clean in-session instead: read `$STAGE/body.md`, apply the rules above in a single pass (above ~50KB of text, work in ~20KB chunks with 2-paragraph overlap at boundaries), and write the result to `$STAGE/clean.md` through a shell heredoc with an improbable quoted delimiter, never an editor or patch tool; header `Cleanup: yes`.
A caller that needs the text in context (`$podcast-digest`) reads this step's body once it is done: `$STAGE/clean.md` when cleanup succeeded (exit 0, or the in-session fallback), otherwise `$STAGE/body.md` (`--raw`, or checks failed on the rerun). That caller also removes `$STAGE` when finished with it.
4. **Deliver** the formatted transcript as requested. For a long transcript requested as a file, save it and link the file rather than duplicating the full body in chat.
5. **If diarisation was used**, ask the user if they want to rename any speakers (e.g. "Speaker 1 is actually Dr Smith"). Apply renames to the staged body file before saving, with a scripted replace of the exact `**Speaker N:**` label rather than a rewrite through context.
6. **Ask what the user wants to do next.** Present the options:
1. Save the transcript — ask where (suggest a default: for local audio files, same directory with `.md` extension; for YouTube, suggest a logical location if one is apparent from context, otherwise ask). Also ask if the user wants a specific filename or is happy with the default (video title / audio filename).
2. Discuss the transcript — e.g. summarise it, extract key points, ask questions about the content, pull out action items.
3. Both — save first, then discuss.
If the request already specifies save/discuss and destination, proceed with that choice. Otherwise wait for the missing decision.
7. **Save** the transcript as a markdown file (if the user chose to save). Use the path and filename agreed in step 6.
Stage the metadata header in `$STAGE`, outside the vault: step 2's scratch directory on a WhisperX run, or the one Phase 0 step 6 created on the published-transcript route. On a WhisperX run `<BODY_FILE>` is `$STAGE/clean.md` from step 3, or `$STAGE/body.md` under `--raw` or after failed checks; on the published-transcript route it stays Phase 0's §15 `BODY=` path. Preserve the body verbatim; do not run a spelling normaliser or rewrite the completed note through an editor. Read `../_shared-rules.md` §5 and `../_shared-rules-content.md` §14 before saving.
For a new note, assemble header + blank line + body into a staging file, then create the destination with one atomic locked compare-and-swap. `MISSING` asserts that the destination does not exist yet; the wrapper checks that under the lock and installs the whole note in one rename, so no separate existence check precedes the write and nothing is ever appended to an existing file. The assembly refuses a missing or empty body, so a header-only note is never installed:
```bash
if [ -s "<BODY_FILE>" ] && { cat "<HEADER_FILE>"; printf '\n'; cat "<BODY_FILE>"; } > "<STAGED_NOTE>"; then
"${VAULT_PATH:?VAULT_PATH not set}/.claude/scripts/locked-edit.sh" "<DESTINATION>" --replace-whole MISSING < "<STAGED_NOTE>"; echo "exit=$?"
cmp "<STAGED_NOTE>" "<DESTINATION>"; echo "cmp=$?"
else
echo "assemble=refused: body missing or empty; nothing installed"
fi
```
`assemble=refused` means nothing was written; locate the body (re-derive §15's `BODY=` path from the URL, or rerun the step that writes it) before retrying. Wrapper exit 0 followed by `cmp` exit 0 is the only success condition; report success only after that byte comparison passes. Wrapper exit 2 means the destination already existed and nothing was written; §14's exit-2 rule applies. Run the same `cmp`. Identical bytes mean this transcript is already saved; report that and do not write again. Differing bytes are a filename collision to resolve with the user unless the request already specifies replacement. Never append to, or `mv` over, the existing note. For an authorised replacement, hash the existing destination with `sha256sum` and repeat the call with that hash in place of `MISSING`, re-reading and rebuilding on a further exit 2. Any other exit (a held lock or an invalid hash both exit 1) means report the message and stop rather than bypassing the lock. The same command serves a destination outside the vault (`--replace-whole` does not require the target to lie inside the vault; only `--move` does). The header's transcription date comes from `date +%F` for this run; a published transcript's acquisition date is not its original transcription date.
```markdown
# Transcript: {video title or filename}
**Source:** `{YouTube URL or filename/path to audio file}`
**Date transcribed:** {YYYY-MM-DD}
**Duration:** {MM:SS or H:MM:SS}
**Model:** {actual Phase 2 model field}
**Diarisation:** {yes (N speakers) | no}
**Cleanup:** {yes | no (--raw) | no (checks failed: <check>)}
---
```
8. **If the user chose to discuss**, proceed with whatever they asked for (summary, Q&A, extraction, etc.).
## Missing-speech diagnosis
If audible speech is absent from the transcript, compare the source audio with the audio retained after VAD before changing recognition models. If filtering discarded it, test a representative section with adjusted/bypassed VAD; do not disable VAD globally based on a different application's failure. If the model received the speech, compare the identical audio and preprocessing using another precision/export/backend, changing one variable at a time. Retain the failing sample and raw outputs; process success and plausible text do not establish completeness.
A demonstrated omission defect in a legacy Parakeet V3 ONNX INT8 encoder does not establish a defect in WhisperX/CTranslate2 INT8, GGUF Q8_0, or all quantized models. Preserve existing defaults unless the affected path reproduces the failure.
## Notes
- WhisperX uses faster-whisper (CTranslate2 backend) which is faster than HF Transformers for inference.
- distil-large-v3.5 is **English-only**. For a known non-English source, choose multilingual `large-v3` before inference; do not rely on the English-only model to detect unsupported speech. Phase 2 also aborts if it returns a non-English language code. For other languages, run the multilingual `large-v3` or `$transcribecloud`. This is why the auto-caption step is best-effort rather than a non-English pathway.
- GPU (CUDA) is used automatically if available; falls back to CPU with int8 quantisation.
- Models are cached after first download.
- On GPU: transcription is near-instant; diarisation is also fast — an earlier ~20–30 min/hr claim was empirically disproven (a 46-min recording diarised in ~20s on a cloud RTX 4090; see `../transcribecloud/references/voice-references.md` for the historical source test).
- Diarisation accuracy is best with 2-3 speakers in clear audio. Specify `--speakers N` when you know the count.
## Skill Monitor
As you execute this skill, follow `../_skill-monitor.md` (relative to this SKILL.md): watch for gaps, and log observations at the end per that file.