wjs-teaching-english

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Teach an English word as a video supercut

将英文单词制作成视频超级剪辑课程

Turn one English word into a self-contained HLS lesson:
intro.ts  (word /IPA/ · 中文 gloss · usage + Volcano TTS)
   ⋯ EXT-X-DISCONTINUITY
[supercut] every season2 clip where the word is spoken  (search-app /api/playlist, COS URLs)
   ⋯ EXT-X-DISCONTINUITY
cta.ts    (关注王建硕 + Volcano TTS)
= search-app/out/<word>.m3u8
No MP4 is burned — only the two cards are rendered as tiny
.ts
, re-encoded to match the supercut's codec so they play in any HLS player.
将单个英文单词转换为独立的HLS课程:
intro.ts  (word /IPA/ · 中文 gloss · usage + Volcano TTS)
   ⋯ EXT-X-DISCONTINUITY
[supercut] every season2 clip where the word is spoken  (search-app /api/playlist, COS URLs)
   ⋯ EXT-X-DISCONTINUITY
cta.ts    (关注王建硕 + Volcano TTS)
= search-app/out/<word>.m3u8
无需生成MP4文件——仅将两张卡片渲染为小型
.ts
文件,并重新编码以匹配超级剪辑的编码格式,确保可在任何HLS播放器中播放。

Prerequisites (check once)

前置条件(只需检查一次)

  • ffmpeg
    /
    ffprobe
    on PATH (Homebrew).
  • Python
    volcengine
    SDK (declared in mira
    requirements.txt
    , used for TTS):
    python3 -c "import volcengine"
    . If missing, ask the user to allow
    pip3 install volcengine==1.0.58
    (it's a pinned repo dependency).
  • The deployed search-app at
    https://search-app-three-kappa.vercel.app
    (default). Override with
    SEARCH_APP_BASE=http://localhost:3000
    if running locally (needs Node ≥ 23.6 +
    npm start
    ).
  • 系统PATH中需配置
    ffmpeg
    /
    ffprobe
    (可通过Homebrew安装)。
  • Python
    volcengine
    SDK(已在mira的
    requirements.txt
    中声明,用于语音合成):执行
    python3 -c "import volcengine"
    验证是否安装。若未安装,请用户允许执行
    pip3 install volcengine==1.0.58
    (这是固定版本的仓库依赖)。
  • 已部署的search-app服务,默认地址为
    https://search-app-three-kappa.vercel.app
    。若本地运行,可通过设置
    SEARCH_APP_BASE=http://localhost:3000
    覆盖默认地址(需Node版本≥23.6,并执行
    npm start
    启动服务)。

Steps

操作步骤

  1. Get the word. A single English word (or short phrase). If the user gave a sentence, pick the target word.
  2. Write the mini-lesson JSON. YOU (Claude) author it — no dictionary API. Keep it accurate and concise. Save to a temp file, e.g.
    /tmp/lesson.json
    :
    json
    {
      "word": "love",
      "ipa": "/lʌv/",
      "pos": "v. / n.",
      "gloss": "爱,热爱",
      "usage": "下面是它在真实电影里的说法",
      "tts_text": "love. 爱。"
    }
    • tts_text
      is read aloud over the intro card — keep it to the word + a short 中文 gloss (Volcano reads mixed English/中文 fine).
    • usage
      is one short line shown on the card (≤ ~20 chars renders best at low resolutions).
  3. Build it:
    bash
    cd /Users/jianshuo/code/mira/search-app
    python3 scripts/build_lesson.py --word love --lesson /tmp/lesson.json
    Useful flags:
    --speaker zh_female_qingxin
    (default),
    --limit 300
    (max clips),
    --no-tts
    (silent cards),
    --base <url>
    ,
    --out <dir>
    .
  4. Report the printed output path (
    search-app/out/<word>.m3u8
    ) and the clip count. The
    .m3u8
    plus its sibling
    <word>.intro.ts
    /
    <word>.cta.ts
    are the deliverable;
    out/
    is git-ignored.
  1. 获取目标单词:单个英文单词(或短语)。若用户提供的是句子,需提取其中的目标单词。
  2. 编写迷你课程JSON文件:由你(Claude)创作内容——无需调用词典API。内容需准确简洁,保存至临时文件,例如
    /tmp/lesson.json
    json
    {
      "word": "love",
      "ipa": "/lʌv/",
      "pos": "v. / n.",
      "gloss": "爱,热爱",
      "usage": "下面是它在真实电影里的说法",
      "tts_text": "love. 爱。"
    }
    • tts_text
      是介绍卡片的语音旁白内容——只需包含单词+简短中文释义(Volcano支持中英文混合语音合成)。
    • usage
      是显示在卡片上的一行简短说明(≤约20个字符时,在低分辨率下显示效果最佳)。
  3. 生成课程视频
    bash
    cd /Users/jianshuo/code/mira/search-app
    python3 scripts/build_lesson.py --word love --lesson /tmp/lesson.json
    常用参数:
    --speaker zh_female_qingxin
    (默认发音人)、
    --limit 300
    (最大片段数量)、
    --no-tts
    (无语音卡片)、
    --base <url>
    (指定search-app地址)、
    --out <dir>
    (指定输出目录)。
  4. 反馈结果:告知用户打印出的输出路径(
    search-app/out/<word>.m3u8
    )以及片段数量。交付物包括
    .m3u8
    文件及其配套的
    <word>.intro.ts
    <word>.cta.ts
    文件;
    out/
    目录已被git忽略。

Notes

注意事项

  • If the word has no clips, the script exits with "no clips match" and writes nothing — tell the user and suggest a more common word.
  • Intro/CTA are encoded to the FIRST supercut segment's resolution/codec/fps so the first discontinuity needs no decoder re-init (avoids
    bufferAppendError
    ).
  • To play locally:
    ffplay search-app/out/<word>.m3u8
    , or serve the
    out/
    folder over HTTP and open in any HLS player (Safari plays
    .m3u8
    natively).
  • 若该单词无匹配片段,脚本会提示“no clips match”并终止运行,不会生成任何文件——需告知用户并建议使用更常用的单词。
  • 介绍/CTA卡片会按照超级剪辑的第一个片段的分辨率、编码格式和帧率进行编码,因此第一次格式切换无需重新初始化解码器(避免
    bufferAppendError
    错误)。
  • 本地播放方式:执行
    ffplay search-app/out/<word>.m3u8
    ,或通过HTTP服务托管
    out/
    目录后,在任意HLS播放器中打开(Safari原生支持播放.m3u8文件)。