---
name: elevenlabs-scribe-captions
description: Automate speech-to-text captioning with ElevenLabs Scribe v2 on fal.ai (fal-ai/elevenlabs/speech-to-text/scribe-v2 at $0.008/min, or $0.0104/min with custom keyterms), including timeline-zero 16 kHz mono WAV extraction, speaker_id diarization, deterministic <=38-char YouTube SRT wrapping, and 3-word active-highlight 9:16 Reels ASS burn-in. Use when generating synced video subtitles, podcast transcripts, or chapter clips.
---

# ElevenLabs Scribe v2 STT -> Synced SRT & 9:16 ASS Captions Skill

## 1. Mandatory Endpoint & Billing Rules
- **ALWAYS pin `fal-ai/elevenlabs/speech-to-text/scribe-v2`:** Base rate is **`$0.008` / input audio minute** (`$0.48/hour`), or **`$0.0104/min`** (`+30%`) when passing domain `keyterms`. Never hit the root legacy `/speech-to-text` path (`$0.03/min`, 3.75x more expensive).
- Measure exact audio duration via `ffprobe` and print estimated USD spend before calling the API.

## 2. Step 1 — Timeline-Zero 16 kHz Mono WAV Extraction
Eliminate MP4 edit-list sync drift before ASR:
```bash
ffmpeg -y -i master_cfr.mp4 -vn -ac 1 -ar 16000 -af "aresample=async=1:first_pts=0" audio_16k.wav
```

## 3. Step 2 — Call Scribe v2 With Diarization & Brand Keyterms
Upload `audio_16k.wav` (or pass a signed URL) and request word-level JSON:
```bash
curl -sS -X POST "https://fal.run/fal-ai/elevenlabs/speech-to-text/scribe-v2" \
  -H "Authorization: Key $FAL_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "audio_url": "'"$AUDIO_URL"'",
    "diarize": true,
    "tag_audio_events": false,
    "keyterms": ["FramesField", "SeedVR2", "FASHN", "ComfyUI", "Remotion"]
  }' > scribe.json
```
- Set `tag_audio_events: false` for clean social burn-in captions; set `true` for accessible YouTube SDH tracks.

## 4. Step 3 — Deterministic SRT (<=38 Chars) + 9:16 ASS (MarginV=500)
Filter `words` to `w["type"] == "word"`:
- **YouTube SRT:** Flush a cue whenever `speaker_id` changes, pause gap `> 0.65s`, line length `> 38 chars`, or cue duration `> 3.2s`.
- **9:16 Reels ASS (`PlayResX: 1080`, `PlayResY: 1920`):** Group `<=3` words per chunk (breaking on `speaker_id` flip or `>0.55s` pause), set `Alignment=2, MarginV=500` inside the safe middle third, and emit per-word active highlight color (`{\c&H002044E0&}` in BGR hex).

## 5. Step 4 — Mux Soft Subs or Burn ASS Captions
- **Universal soft-sub MP4 (works on all FFmpeg builds):**
  ```bash
  ffmpeg -y -i master_cfr.mp4 -i out.srt -c:v copy -c:a copy -c:s mov_text captioned_soft.mp4
  ```
- **Hard-burn 9:16 ASS (requires FFmpeg compiled with `libass`; on macOS use `ffmpeg-full`):**
  ```bash
  ffmpeg -y -i vertical_916.mp4 -vf "ass=out.ass" -c:v libx264 -crf 18 -pix_fmt yuv420p -c:a copy -movflags +faststart vertical_burned.mp4
  ```
- **Verification Gate:** Check sync on the final 10 seconds of the video (not just the first 5 seconds) to confirm zero VFR drift.
