# Phase 2 - Transcribe New Audio

INPUT: the manifest from Phase 1. OUTPUT: one verbatim transcript per AUDIO item whose decision is `new`, `retry`, or `reprocess`. TEXT, INLINE, and `reuse` items are carried forward unchanged.

## SEQUENCING - call, read, THEN write (hard rule)

The transcription tool call MUST fully complete and its returned text MUST be read by you BEFORE you write anything to disk for that item.

- You MUST NOT write, create, or pre-fill the resource `.md` (or any file holding the transcript body) in the same turn as the transcription call, and you MUST NOT issue that write in parallel with - or before - the call returns. Call and read happen first, on their own; the write happens later, in Phase 3.
- The `.md` body MUST be copied only from the actual text the transcription tool returned for that exact audio file. You MUST NOT type, predict, paraphrase, or pre-fill the body from the filename, from earlier turns, or from any expectation of what the audio "probably says."
- If the tool returns no usable result (error, empty output, timeout, or you have not yet read a real return value), the item is `TRANSCRIPTION_FAILED` and stays `failed` with `md: null`. No `.md` is written for it. Never substitute invented text for a missing result.

Violating the letter of this rule - e.g. writing the `.md` "to save a round-trip" while the call is still pending - is violating its spirit. When in doubt: call, read, THEN write.

Run the following:

```text
For each AUDIO item in manifest order:

1. If `Decision` is `reuse`, do not call free-whisper. Carry forward the existing `md` path from the index.

2. If `Decision` is `new`, `retry`, or `reprocess`:
   - Call the transcription tool exposed by the free-whisper MCP server (tool name prefix
     `mcp__plugin_machine-discovery_free-whisper__...`; if the exact tool name differs, use the
     transcription tool that server provides). Pass the audio file path.
   - Wait for the call to return, then READ the returned text. Only after you have read a real return
     value does that text exist; nothing may be written for this item before that point.
   - Capture the returned text VERBATIM. Do not edit, trim, summarize, re-punctuate, translate, or
     "fix" it.
   - On error (server unreachable, tool error, unsupported/corrupt file, timeout): record the item as
     `TRANSCRIPTION_FAILED: <error message>`. Do NOT retry more than twice. Do NOT fabricate or guess
     the content.

For TEXT items:
- Carry forward the file content verbatim for Phase 3.

For INLINE items:
- Carry forward the inline text verbatim for Phase 3.
```

RULES:
- Read before write. Never emit the resource `.md` for an item until its transcription call has returned and you have read the text. A write that runs in the same turn as, or concurrently with, the transcription call is forbidden; the `.md` body comes only from the real returned text, and an item with no result stays `failed` with no `.md`.
- One transcription call per new/retry/reprocess audio item. Do not batch unrelated files unless the tool explicitly supports it.
- Never call free-whisper for resources marked `reuse`.
- Never invent a transcript. A failed item stays failed and is surfaced to the user.
- Do not proceed to Phase 3 with silent failures. Every AUDIO item is either reused, transcribed, or explicitly `TRANSCRIPTION_FAILED`.
- If a transcription call fails with an authentication error (HTTP 401, "unauthorized", or a missing/invalid token), present the `TRANSCRIPTION_FAILED` guidance as the 4 numbered steps below, **written in the user's current interaction language** (translate the wording — this plugin is bilingual, never hardcode Spanish or English). Keep the URL and the slash commands literal. **Step 1, the token URL, is MANDATORY** — never omit it or change `https://transcribe.skillbase.yareytech.com`. Do not add or reorder steps. Do NOT retry the call until the user reconfigures.
  1. Get your token at https://transcribe.skillbase.yareytech.com
  2. Save it: `/machine-discovery:setup-token`
  3. Reconnect the MCP: run `/mcp`, select **free-whisper**, reconnect it
  4. Retry: `/machine-discovery:process-input <project-slug>`
- If the free-whisper server does not appear in your available tools at all, STOP and tell the user (in their interaction language) to: get the token at https://transcribe.skillbase.yareytech.com, run `/machine-discovery:setup-token` to save it, then `/mcp` to (re)connect free-whisper (see `plugins/machine-discovery/README.md`). Do not work around it by transcribing manually.

OUTPUT FORMAT - per AUDIO item, show the source and result:

- `memo1.m4a` -> reuse: `transcriptions/memo1.md`
- `memo2.m4a` -> new transcript, 1240 chars: "Bueno, la idea es que..."
- `memo3.mp3` -> `TRANSCRIPTION_FAILED: connection refused`

ADVANCE: show all transcription results, then continue straight to Phase 3 when every non-reused audio transcribed cleanly.

STOP only if at least one item is `TRANSCRIPTION_FAILED`: report which ones failed and ask whether to proceed with successful resources, retry after fixing setup, or cancel. If the user proceeds, Phase 3 updates failed items in `index.json` and writes records only for ready resources.
