Target Audience
This is written for indie developers and small teams building online education tools, knowledge-paid SaaS products, or sitting on a batch of course videos they want to structure. You don't need an algorithm background—as long as you can call APIs, you can implement this.
The Business Pain Point: Chapter Splitting and Summary Writing Are Two "Time Black Holes"
I've worked with several small teams running course platforms, and their workflows are almost identical:
Splitting chapters. For a 3-hour course, an editor has to scrub the timeline back and forth, repeatedly listening to determine "the topic changed here" and manually marking the points. This takes 3–4 hours per course on average, and doubles for instructors with heavy accents or fast speech. If the platform has 200 existing courses to restructure, at 3.5 hours per course, that's 700 hours of labor—one person working full-time for three months.
Writing summaries. Splitting chapters isn't enough. Each chapter needs a short description and a few knowledge-point tags so learners can search and preview-locate content. Written manually, each chapter takes 10–15 minutes, which adds another 5–7 hours for a 30-chapter course.
Combined, the structuring cost of a single course approaches one person-day. For indie developers, this directly determines whether the "batch course processing" feature is viable—doing it manually just doesn't pencil out.
After transforming this with an AI pipeline, the same course: transcription and analysis are fully automated, with end-to-end processing of about 40 minutes, with only a final 10 minutes of spot-checking chapter boundaries by a human. Per-course cost drops from about 8 hours of labor to 0.2 hours—a roughly 97% reduction; the 200 existing courses go from 700 hours to 40 hours, clearable within a week.
Architecture Design: A Four-Stage Pipeline
The overall architecture isn't complex. The core idea is "break a one-shot large task into small, re-runnable, cacheable steps":
课程视频文件
│
▼
[1] 抽音频 ──── ffmpeg 提取音轨,压缩为 16k 单声道
│
▼
[2] 转写 ────── Whisper 类模型,带时间戳的逐句文本
│ (结果落库缓存,后续重跑不重复计费)
▼
[3] 章节切分 ── LLM 滑动窗口读带时间戳文本,
│ 输出 [{start, end, topic}] 列表
▼
[4] 摘要生成 ── 按章节切片喂给 LLM,
输出 80字简介 + 3~5个知识点标签A few design decisions deserve elaboration:
Transcription results must be cached. It's the most expensive and slowest stage in the pipeline (about 70% of the time). Once persisted to object storage, you can iterate on chapter algorithms or rewrite summaries with a new prompt without re-transcribing. We didn't cache early on and had to re-run 30 courses for one prompt tuning round, burning transcription fees for nothing—don't pay this tuition again.
Chapter splitting uses a sliding window instead of stuffing in the whole thing. The transcription text of a 3-hour course is about 30,000 characters; stuffing it in directly exceeds the context and makes boundaries blurry. Slide in 20-minute windows, have the model output topic switch points within each window, then deduplicate and merge across windows—boundary error can be kept within ±15 seconds, which is plenty for chapter navigation.
Summaries are sliced by chapter with a word limit. The input is the text segment corresponding to a chapter; the output is forced into JSON format ({"summary": "...", "tags": [...]}), making it easy to write directly to the database and render on the frontend.
Key Implementation Steps and Core Code
import json
def split_chapters(segments, window_min=20):
"""segments: [{'start':秒, 'end':秒, 'text':句文本}]"""
chapters = []
window_sec = window_min * 60
cursor, buf = 0, []
for seg in segments:
buf.append(seg)
if seg["end"] - cursor >= window_sec:
prompt = build_prompt(buf) # 带时间戳文本 + 输出schema
resp = llm.chat(prompt, response_format="json")
chapters += merge_points(resp["topic_breaks"], buf)
cursor, buf = seg["end"], []
if buf:
chapters.append(close_last(buf))
return merge_adjacent(chapters) # 合并相邻同主题
def gen_summary(chapter_text):
prompt = f"""你是课程编辑。为以下章节写80字以内的简介,
并提炼3-5个知识点标签,返回JSON:
{{"summary": "...", "tags": ["..."]}}
章节内容:{chapter_text}"""
return json.loads(llm.chat(prompt, response_format="json"))Process checklist (follow this when implementing):
- Extract audio with ffmpeg:
ffmpeg -i course.mp4 -ac 1 -ar 16000 audio.wav - Call the transcription model, store the per-sentence timestamped results in object storage, keyed by video hash for deduplication
- Run chapter splitting with the sliding window, manually spot-check 10% of boundaries; if errors exceed 30 seconds, tune the window parameters
- Generate summaries per chapter slice; auto-retry once on JSON validation failure
- Write all results to the database; the frontend renders the player with chapter-based timeline positioning
Why a Unified AI Gateway Reduces Maintenance Costs
This pipeline requires calling two or more model types: a transcription model and a chat LLM. In practice, you'll likely mix and match—e.g., a specialized model for transcription, a cost-effective model for chapter splitting, and a stronger model for summaries. If you connect directly to each vendor's native SDK, you'll face: different authentication methods, different error code systems, each with their own retry and rate-limiting logic, and four or five separate bills. Each new model adds roughly 1–2 days of adaptation and integration work, and when something breaks, you have to debug vendor by vendor.
The value of a unified AI gateway: an OpenAI-compatible unified protocol, unified key management, unified usage billing and error monitoring. Switching models means changing one model parameter, without touching the request-layer code; if you want to A/B test summary models A vs. B, you can go live in 10 minutes. For an indie developer, this means the trial-and-error cost of model selection drops from "days" to "minutes"—and that's precisely the fastest-iterating part of this kind of application.
Doing the math from earlier: one pipeline compresses per-course processing from 8 hours to 40 minutes. In batch scenarios, the annual labor savings are enough for a small team to shift its energy from "grunt work" back to the product itself.
If you're planning to build this pipeline, you can start by registering a unified gateway account at https://api.thistoken.ai/register—one key covers both transcription and LLMs. Get your first course structured, starting tonight.
---
Ready to try it yourself? Sign up at https://api.thistoken.ai/register to get your API key and start building.
Token.AI を試してみませんか?
プロジェクトレベルの API Key を作成し、コンソールでチャネルを有効にして、ルーティング、予算、監査ログを設定しましょう。
注册 ThisToken.AI 并获取 API Key