# Workflow 1 — Audio to Transcript

## What it does
Receives an audio file URL via webhook → downloads it → transcribes with OpenAI Whisper → outputs a clean structured transcript with auto-generated chapter chunks (every ~5 minutes), segment-level timestamps, word count, and duration metadata.

## Prerequisites
- n8n instance (cloud trial or self-hosted, v1.50+)
- OpenAI API key with credit (~$0.006 per minute of audio = ~$0.36 for a 60-min episode)
- Audio file accessible via public URL (S3, Dropbox direct link, podcast RSS enclosure, etc.)
  - Max file size: 25 MB (OpenAI Whisper limit). For longer episodes, compress the audio first — one-liner: `ffmpeg -i episode.mp3 -ac 1 -b:a 48k episode_small.mp3` (mono 48kbps keeps a 3-hour episode under 25 MB with no transcription quality loss).

## Setup (5 min)
1. Open your n8n instance → Workflows → Import from File → select `01_audio_to_transcript.json`
2. Click the "OpenAI Whisper" node → Credentials → "Create New" → paste your OpenAI API key → Save
3. Click "Save" on the workflow, then "Activate" toggle in top right
4. Copy the Production webhook URL from the Webhook node (looks like `https://your-n8n.app/webhook/podcastpipeline-transcript`)

## Test it
Send a POST request to your webhook URL with body:
```json
{ "audio_url": "https://example.com/your-podcast-episode.mp3" }
```

You'll get back JSON like:
```json
{
  "full_text": "Welcome to the show. Today we're talking about...",
  "duration_seconds": 3247.5,
  "duration_formatted": "54:07",
  "language": "en",
  "word_count": 7821,
  "chapter_count": 11,
  "chapters": [
    {
      "index": 1,
      "start_seconds": 0,
      "end_seconds": 297.4,
      "start_formatted": "0:00",
      "end_formatted": "4:57",
      "text": "Welcome to the show. Today..."
    }
  ],
  "segments": [...]
}
```

## What to do with the output
The structured transcript is the input for every other workflow in this pack:
- **Workflow 2** (SEO blog post) — feeds the full text + chapters
- **Workflow 3** (social pack) — feeds the full text
- **Workflow 4** (newsletter + show notes) — feeds chapters + timestamps for show notes
- **Workflow 5** (viral clips) — feeds segments for moment detection

Most users save the transcript to Google Sheets, Airtable, Notion, or a database between workflows so they can run the downstream workflows independently.

## Costs
- OpenAI Whisper: $0.006/min of audio
  - 30-min episode: $0.18
  - 60-min episode: $0.36
  - 90-min episode: $0.54
- n8n: free (cloud trial 14 days, then $20/mo cloud OR free self-hosted)

## Troubleshooting
| Issue | Fix |
|---|---|
| "Credentials not found" on OpenAI node | Re-create credential, ensure key starts with `sk-` |
| 25MB file size error | Convert audio to mono + lower bitrate: `ffmpeg -i episode.mp3 -ac 1 -b:a 48k episode_small.mp3` |
| Webhook not responding | Check workflow is **Activated** (not just saved), and you're hitting the Production URL not Test URL |
| Empty transcript | Audio file likely failed to download — check URL is publicly accessible |

## Customization
Common tweaks (all in the "Structure Transcript" Code node):
- Change `CHAPTER_SECONDS` to adjust chapter length (default 300 = 5 min)
- Add language detection if your podcasts are multilingual
- Add speaker diarization (swap the Whisper node for AssemblyAI or Deepgram — both have n8n-compatible HTTP APIs)
