---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://framesfield.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
title: "Automated Speech-to-Text Subtitles, Karaoke Captions & Chapter Clips Pipeline"
description: "Extract a timeline-locked 16 kHz mono WAV from any video or podcast, transcribe it via ElevenLabs Scribe v2 on fal.ai ($0.008/min, or $0.0104/min with custom brand keyterms and speaker diarization), and deterministically emit both 38-char YouTube SRT subtitles and 3-word active-highlight ASS captions positioned cleanly inside 9:16 Reels/Shorts safe zones."
canonical: "https://framesfield.com/workflows/automated-speech-to-text-subtitles-and-chapter-clips-pipeline"
---

# Automated Speech-to-Text Subtitles, Karaoke Captions & Chapter Clips Pipeline

> Extract a timeline-locked 16 kHz mono WAV from any video or podcast, transcribe it via ElevenLabs Scribe v2 on fal.ai ($0.008/min, or $0.0104/min with custom brand keyterms and speaker diarization), and deterministically emit both 38-char YouTube SRT subtitles and 3-word active-highlight ASS captions positioned cleanly inside 9:16 Reels/Shorts safe zones.

- **Canonical URL:** https://framesfield.com/workflows/automated-speech-to-text-subtitles-and-chapter-clips-pipeline
- **Difficulty:** Intermediate
- **Estimated Time:** 15 min
- **Estimated Cost:** $0.08 per 10-min YouTube video · $0.48 per 60-min podcast ($0.62 w/ keyterms)
- **Last Verified:** 2026-12-01
- **Tools Used:** ElevenLabs Scribe Speech-to-Text (https://framesfield.com/specs/elevenlabs-scribe-stt), Runway Gen-4 Turbo (https://framesfield.com/specs/runway-gen-4), Ideogram 4.6 (https://framesfield.com/specs/ideogram-4-6)

## Pipeline Architecture

01. **Aligned Audio Extract** (FFmpeg 16 kHz Mono): Dump timeline-zero 16 kHz mono WAV from locked CFR master MP4
02. **Word-Timed ASR** (ElevenLabs Scribe v2): Transcribe ($0.008/min) with diarize: true and custom brand keyterms
03. **SRT & Karaoke ASS** (Python Word Chunker): Wrap <=38-char SRT cues & 3-word active-highlight ASS cues on speaker turns
04. **Mux or Hard-Burn** (FFmpeg / Remotion): Mux mov_text soft subs or burn 9:16 ASS captions inside middle safe zone

## Playbook

## Why Scribe v2 + deterministic word wrapping replaces paid clipping SaaS

Paying `$30–$60/month` for browser subtitle apps locks creators into proprietary templates, sluggish re-exports, and messy misspelled brand names. Calling **[ElevenLabs Scribe v2](/specs/elevenlabs-scribe-stt)** directly on fal.ai (`$0.008/min`, or `$0.0104/min` with `keyterms`) returns exact word-level timestamps and `speaker_id` diarization in one JSON payload—giving you total control over both YouTube accessibility SRTs and active-color Reels captions for pennies per video.

## Step-by-step execution & burn-in commands

### 1. Extract timeline-aligned audio & call Scribe v2

Always pull audio from your **final locked constant-frame-rate (CFR)** video so timestamps never drift near the end of long cuts:

```bash
# Extract aligned 16 kHz mono WAV
ffmpeg -y -i master_cfr.mp4 -vn -ac 1 -ar 16000 -af "aresample=async=1:first_pts=0" audio_16k.wav

# Call Scribe v2 on fal.ai (after uploading audio_16k.wav to a signed/public URL)
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": "https://cdn.example.com/audio_16k.wav",
    "diarize": true,
    "tag_audio_events": false,
    "keyterms": ["FramesField", "SeedVR2", "FASHN", "ComfyUI", "Remotion"]
  }' > scribe.json
```

### 2. Run the dual SRT + 9:16 ASS formatter

```bash
python3 scribe_v2_to_captions.py scribe.json youtube_subs.srt reels_karaoke.ass
```

Notice two built-in guardrails in `scribe_v2_to_captions.py`:
- **YouTube SRT:** Splits cleanly whenever `speaker_id` switches, pause exceeds `0.65s`, line length passes `38 characters`, or duration exceeds `3.2s`.
- **Reels / Shorts ASS:** Groups words into punchy **3-word chunks**, highlights the currently spoken word in signal vermilion (`&H002044E0&` in ASS BGR hex), and locks `Alignment=2, MarginV=500` on `1080×1920` so bottom TikTok/Reels buttons and descriptions never cover your captions.

### 3. Soft-mux SRT (universal FFmpeg) or hard-burn ASS (`ffmpeg-full` / Linux)

```bash
# Option A: Soft-mux SRT into MP4 (works on EVERY FFmpeg build, toggleable captions)
ffmpeg -y -i master_cfr.mp4 -i youtube_subs.srt -c:v copy -c:a copy -c:s mov_text output_softsub.mp4

# Option B: Hard-burn 9:16 active-word ASS (requires FFmpeg built with libass)
ffmpeg -y -i vertical_916.mp4 -vf "ass=reels_karaoke.ass" \
  -c:v libx264 -crf 18 -pix_fmt yuv420p -c:a copy -movflags +faststart vertical_captioned.mp4
```

On macOS, if default Homebrew `ffmpeg` lacks `libass`, see [Fix: Missing libass & drawtext on macOS](/fixes/ffmpeg-libass-drawtext-missing-macos) to install `ffmpeg-full`, or run our turnkey [Skill 67: ElevenLabs Scribe v2 to SRT & ASS Captions Skill](/skills/elevenlabs-scribe-stt-to-srt-and-ass-captions-skill). If captions still drift or misspell proper nouns, check [Fix AI Subtitles Out of Sync & Wrong Names](/fixes/ai-speech-to-text-subtitles-out-of-sync-and-wrong-names-fix).

## Copyable Asset: ElevenLabs Scribe v2 Word JSON → Synced SRT & 9:16 Karaoke ASS Builder (Python) (scribe_v2_to_captions.py)

```bash
cat <<'PY' > scribe_v2_to_captions.py
import json, sys

def srt_ts(sec: float) -> str:
    ms = max(0, int(round(sec * 1000)))
    h, ms = divmod(ms, 3600000); m, ms = divmod(ms, 60000); s, ms = divmod(ms, 1000)
    return f"{h:02d}:{m:02d}:{s:02d},{ms:03d}"

def ass_ts(sec: float) -> str:
    cs = max(0, int(round(sec * 100)))
    h, cs = divmod(cs, 360000); m, cs = divmod(cs, 6000); s, cs = divmod(cs, 100)
    return f"{h}:{m:02d}:{s:02d}.{cs:02d}"

if len(sys.argv) < 4:
    sys.exit("Usage: python3 scribe_v2_to_captions.py scribe.json out.srt out.ass")

data = json.load(open(sys.argv[1], "r", encoding="utf-8"))
words = [w for w in data.get("words", []) if w.get("type") == "word"]

# 1) Build YouTube 38-char speaker-aware SRT
srt_cues, buf = [], []
def flush_srt():
    if buf:
        srt_cues.append((buf[0]["start"], buf[-1]["end"], " ".join(x["text"] for x in buf)))
        buf.clear()

for w in words:
    if buf:
        spk_flip = w.get("speaker_id") != buf[-1].get("speaker_id")
        gap = w["start"] - buf[-1]["end"] > 0.65
        too_long = len(" ".join(x["text"] for x in buf)) + 1 + len(w["text"]) > 38
        too_slow = w["end"] - buf[0]["start"] > 3.2
        if spk_flip or gap or too_long or too_slow:
            flush_srt()
    buf.append(w)
flush_srt()

with open(sys.argv[2], "w", encoding="utf-8") as f:
    for i, (st, en, txt) in enumerate(srt_cues, 1):
        f.write(f"{i}\n{srt_ts(st)} --> {srt_ts(en)}\n{txt}\n\n")

# 2) Build 9:16 Reels 3-word active-highlight ASS (MarginV=500 safe zone)
chunks, cbuf = [], []
for w in words:
    if cbuf and (len(cbuf) >= 3 or w["start"] - cbuf[-1]["end"] > 0.55 or w.get("speaker_id") != cbuf[-1].get("speaker_id")):
        chunks.append(cbuf); cbuf = []
    cbuf.append(w)
if cbuf:
    chunks.append(cbuf)

ass_header = """[Script Info]
ScriptType: v4.00+
PlayResX: 1080
PlayResY: 1920
WrapStyle: 2

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Reels,Arial,74,&H00FFFFFF,&H002044E0,&H00111111,&H80000000,-1,0,0,0,100,100,0,0,1,6,2,2,80,80,500,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
"""
ass_lines = [line.lstrip() + "\n" for line in ass_header.strip().splitlines()]
for ch in chunks:
    st, en = ch[0]["start"], ch[-1]["end"]
    for i, active in enumerate(ch):
        w_st = active["start"]
        w_en = ch[i + 1]["start"] if i + 1 < len(ch) else en
        parts = []
        for j, tok in enumerate(ch):
            txt = tok["text"].upper()
            parts.append(f"{{\\c&H002044E0&}}{txt}{{\\c&H00FFFFFF&}}" if j == i else txt)
        ass_lines.append(f"Dialogue: 0,{ass_ts(w_st)},{ass_ts(max(w_en, w_st + 0.05))},Reels,,0,0,0,,{' '.join(parts)}\n")

with open(sys.argv[3], "w", encoding="utf-8") as f:
    f.writelines(ass_lines)
print(f"Wrote {len(srt_cues)} SRT cues ({sys.argv[2]}) and {len(ass_lines) - 12} ASS lines ({sys.argv[3]})")
PY
```

## FAQ

### Why must I pin /scribe-v2 instead of calling fal-ai/elevenlabs/speech-to-text?

The root endpoint maps to legacy Scribe v1 at $0.03/minute. Pinning fal-ai/elevenlabs/speech-to-text/scribe-v2 lowers transcription cost by 3.75× to $0.008/minute and unlocks keyterms vocabulary boosting for brand names and acronyms.

### Why did my macOS Homebrew FFmpeg throw an error on -vf ass=out.ass?

Default Homebrew ffmpeg omits libass and libfreetype. Install homebrew-ffmpeg/ffmpeg/ffmpeg-full (see our macOS libass fix playbook) for hard-burned ASS captions, or soft-mux out.srt directly using -c:s mov_text, which works in every standard FFmpeg build.

### How do I use Scribe v2 speaker_id timestamps to cut podcast chapter clips automatically?

Because every word carries exact start/end floats and speaker_id, you can pass the grouped speaker transcript to an LLM to pick 30–55 second highlight timestamps, then slice master_cfr.mp4 via ffmpeg -ss <start> -to <end> and regenerate per-clip ASS offsets.

### How much does it cost to transcribe and caption a 1-hour interview with custom brand terms?

At $0.0104/minute with keyterms enabled ($0.008 base + 30%), an entire 60-minute podcast costs $0.62—with word timestamps and speaker diarization included in the single pass.
