Skip to content

jianshuo/claude-skills / wjs-voicedrop-creating-motion-book

wjs-voicedrop-creating-motion-book

Flagged

Use when the user wants a whole book (usually a VoiceDrop 书架 book) turned into a chaptered explainer animation narrated by the book's own audiobook (书架「听本章」) — vertical 视频号 9:16 by default, art style auto-picked from the book's content, delivered as an in-browser HTML player and optionally MP4. Triggers — "把这本书做成动画", "做成艺术动画片", "读书动画", "听书配动画", "motion book", "/wjs-voicedrop-creating-motion-book <书名>".

FileKindSize
SKILL.mdskill md11.2 KB
cloud/harvest_kits.shscript3.2 KB
cloud/mb.mjsscript2.4 KB
cloud/probe.mjsscript1.3 KB
cloud/run_book.shscript23.6 KB
cloud/setup_worker.shscript3.3 KB
kits/8bit/.harvestedother16 B
kits/8bit/kit.jsonconfig6.6 KB
kits/8bit/lib.jsscript49.2 KB
kits/USAGE.tsvother3.0 KB
kits/banknote/fonts/NotoSerifSC-Black.woffbinary2.1 MB
kits/banknote/fonts/NotoSerifSC-Regular.woffbinary2.1 MB
kits/banknote/fonts/OFL.txtmarkdown4.2 KB
kits/banknote/kit.jsonconfig1.1 KB
kits/banknote/lib.jsscript16.6 KB
kits/bauhaus/.harvestedother15 B
kits/bauhaus/kit.jsonconfig2.5 KB
kits/bauhaus/lib.jsscript37.0 KB
kits/cave/.harvestedother22 B
kits/cave/kit.jsonconfig2.6 KB
kits/cave/lib.jsscript33.1 KB
kits/constructivism/.harvestedother19 B
kits/constructivism/kit.jsonconfig3.0 KB
kits/constructivism/lib.jsscript47.0 KB
kits/cubism/.harvestedother24 B
kits/cubism/kit.jsonconfig1.6 KB
kits/cubism/lib.jsscript13.0 KB
kits/dali/.harvestedother21 B
kits/dali/kit.jsonconfig4.2 KB
kits/dali/lib.jsscript51.8 KB
kits/dunhuang/.harvestedother13 B
kits/dunhuang/kit.jsonconfig5.7 KB
kits/dunhuang/lib.jsscript49.4 KB
kits/egypt/.harvestedother21 B
kits/egypt/kit.jsonconfig3.9 KB
kits/egypt/lib.jsscript72.4 KB
kits/flat2026/kit.jsonconfig2.1 KB
kits/flat2026/lib.jsscript50.5 KB
kits/ghibli/.harvestedother15 B
kits/ghibli/kit.jsonconfig5.4 KB
kits/ghibli/lib.jsscript74.9 KB
kits/gothic/.harvestedother17 B
kits/gothic/kit.jsonconfig5.6 KB
kits/gothic/lib.jsscript70.6 KB
kits/greek/.harvestedother10 B
kits/greek/kit.jsonconfig2.5 KB
kits/greek/lib.jsscript49.6 KB
kits/haring/.harvestedother19 B
kits/haring/kit.jsonconfig3.4 KB
kits/haring/lib.jsscript36.4 KB
kits/hopper/.harvestedother13 B
kits/hopper/kit.jsonconfig4.2 KB
kits/hopper/lib.jsscript45.2 KB
kits/impression/.harvestedother15 B
kits/impression/kit.jsonconfig6.2 KB
kits/impression/lib.jsscript71.2 KB
kits/ink/.harvestedother19 B
kits/ink/fonts/NotoSerifSC-Black.woffbinary2.1 MB
kits/ink/fonts/NotoSerifSC-Regular.woffbinary2.1 MB
kits/ink/fonts/OFL.txtmarkdown4.2 KB
kits/ink/kit.jsonconfig5.0 KB
kits/ink/lib.jsscript47.7 KB
kits/kirby/.harvestedother14 B
kits/kirby/kit.jsonconfig3.1 KB
kits/kirby/lib.jsscript40.9 KB
kits/klimt/.harvestedother13 B
kits/klimt/kit.jsonconfig6.4 KB
kits/klimt/lib.jsscript36.5 KB
kits/kurzgesagt/kit.jsonconfig1.0 KB
kits/kurzgesagt/lib.jsscript16.1 KB
kits/kusama/.harvestedother15 B
kits/kusama/kit.jsonconfig5.4 KB
kits/kusama/lib.jsscript53.9 KB
kits/matisse/.harvestedother9 B
kits/matisse/kit.jsonconfig6.4 KB
kits/matisse/lib.jsscript43.1 KB
kits/monet/.harvestedother10 B
kits/monet/kit.jsonconfig5.4 KB
kits/monet/lib.jsscript64.5 KB
kits/munch/.harvestedother36 B
kits/munch/kit.jsonconfig2.8 KB
kits/munch/lib.jsscript17.8 KB
kits/nouveau/.harvestedother9 B
kits/nouveau/kit.jsonconfig6.9 KB
kits/nouveau/lib.jsscript34.2 KB
kits/picasso_blue/.harvestedother12 B
kits/picasso_blue/kit.jsonconfig6.2 KB
kits/picasso_blue/lib.jsscript58.4 KB
kits/pop/.harvestedother11 B
kits/pop/kit.jsonconfig2.5 KB
kits/pop/lib.jsscript37.3 KB
kits/raytrace/.harvestedother20 B
kits/raytrace/kit.jsonconfig3.2 KB
kits/raytrace/lib.jsscript39.7 KB
kits/renaissance/.harvestedother12 B
kits/renaissance/kit.jsonconfig6.4 KB
kits/renaissance/lib.jsscript95.2 KB
kits/rickmorty/.harvestedother8 B
kits/rickmorty/kit.jsonconfig2.4 KB
kits/rickmorty/lib.jsscript53.4 KB
kits/roman/.harvestedother18 B
kits/roman/kit.jsonconfig2.0 KB
kits/roman/lib.jsscript53.8 KB
kits/rubberhose/.harvestedother10 B
kits/rubberhose/kit.jsonconfig5.0 KB
kits/rubberhose/lib.jsscript52.4 KB
kits/seurat/.harvestedother15 B
kits/seurat/kit.jsonconfig3.1 KB
kits/seurat/lib.jsscript17.8 KB
kits/shadowpuppet/.harvestedother21 B
kits/shadowpuppet/kit.jsonconfig3.2 KB
kits/shadowpuppet/lib.jsscript43.2 KB
kits/shinkai/.harvestedother9 B
kits/shinkai/kit.jsonconfig3.7 KB
kits/shinkai/lib.jsscript39.0 KB
kits/vangogh/.harvestedother18 B
kits/vangogh/README.mdmarkdown1.5 KB
kits/vangogh/kit.jsonconfig11.1 KB
kits/vangogh/lib.jsscript94.0 KB
kits/vaporwave/.harvestedother12 B
kits/vaporwave/kit.jsonconfig7.7 KB
kits/vaporwave/lib.jsscript57.8 KB
player/template.htmlother13.0 KB
references/章节制作规范.mdmarkdown6.2 KB
references/踩坑.mdmarkdown4.6 KB
references/选画风.mdmarkdown6.3 KB
scripts/add_cover.mjsscript3.7 KB
scripts/assemble.mjsscript9.7 KB
scripts/build_html.mjsscript6.1 KB
scripts/common.mjsscript7.8 KB
scripts/fetch_book.mjsscript1.7 KB
scripts/framing_sheet.mjsscript2.6 KB
scripts/narrate.mjsscript8.4 KB
scripts/new_book.mjsscript4.4 KB
scripts/optimize_html.mjsscript5.2 KB
scripts/pick_styles.mjsscript3.9 KB
scripts/publish_video.mjsscript5.1 KB
scripts/qa_batches.mjsscript3.4 KB
scripts/render_chunks.mjsscript5.7 KB
scripts/render_lock.shscript783 B
scripts/republish_player.mjsscript4.9 KB
scripts/smoke.mjsscript20.7 KB
scripts/split_chapters.mjsscript2.7 KB

scripts/narrate.mjs

View on GitHub
#!/usr/bin/env node
// 口播=书架有声书的整章朗读(不写新稿、不调 TTS):ch01…chNN 各自
//   1. 音频/chNN.mp3 ← 听书接口 <base>/<slug>/<stem>:先 HEAD 查缓存(HEAD 不触发合成);GET 有缓存直接回源,没缓存由听书接口合成一次并写回 R2
//      ——以后用户听书、再做动画都不再花 TTS 的钱。我们这边从不往听书缓存里写。
//   2. 音频/chNN.asr.json ← 火山大模型流式 ASR(直接推 mp3 字节,不用解码)
//   3. 稿/chNN.txt ← 听书接口 <stem>.txt 给的朗读原文(合成时实际念的那份:有脚本用脚本,没有就是章节页编排);
//      字幕用原文,ASR 只出时间——ASR 文本会听错字(2026-10-27 用户报:字幕错字)。原文拿不到、或对齐率 < 80%
//      (修过书、缓存的 mp3 还是旧稿)才退回 ASR 文本。音频/chNN.句时间.txt ← 原文按 ASR 字时间对齐
// 已有的文件跳过(删掉 chNN.mp3 才会重取);默认 3 章并发。凭据:VOLC_ASR_APPID/VOLC_ASR_ACCESS_TOKEN(或 VOLC_APPID/VOLC_TOKEN)。
// 用法:node narrate.mjs <项目目录> [ch03 ch07 …] [-j 3]
import fs from 'node:fs';
import path from 'node:path';
import zlib from 'node:zlib';
import crypto from 'node:crypto';
import { ensureWebSocket, loadEnv, book, chapterIds, alignPhrases, formatRows, mp3Frames, pool } from './common.mjs';
ensureWebSocket();

const args = process.argv.slice(2); let jobs = 3;
const ji = args.indexOf('-j'); if (ji >= 0) { jobs = +args[ji + 1]; args.splice(ji, 2); }
const P = path.resolve(args[0]), only = new Set(args.slice(1)), A = path.join(P, '音频'), env = loadEnv(), B = book(P);
const AB = { base: 'https://jianshuo.dev/voicedrop/books/audiobook', ...(B.audiobook || {}) };
const stemOf = ch => (AB.stems || [])[+ch.slice(2) - 1] || ch.slice(2);   // 听书章节 stem,缺省 01、02…

// ---------- 听书音频 ----------
async function audiobookMp3(ch) {
  const url = `${AB.base}/${encodeURIComponent(B.slug)}/${encodeURIComponent(stemOf(ch))}`;
  const head = () => fetch(url, { method: 'HEAD', signal: AbortSignal.timeout(30000) }).catch(() => ({ status: 0, headers: new Headers() }));
  const h = await head(), hit = h.status === 200;
  let r = await fetch(url, { signal: AbortSignal.timeout(900000) });   // 没缓存时这一下触发合成(8 分钟音频约 1 分钟合成完)
  if (!r.ok) throw new Error(`听书接口 ${r.status}:${url}`);
  let buf = Buffer.from(await r.arrayBuffer());
  // 没缓存时拿到的是边合成边推的流,可能中途断(2026-10-25《炮声里的股市》第 8 章只拿到 72 秒)。
  // 听书接口会在后台合成完整章写进 R2,所以等缓存出现,再取缓存里那份完整的。
  if (!hit) {
    let cl = 0;
    for (let k = 0; k < 60; k++) { const hh = await head(); cl = +(hh.headers.get('content-length') || 0); if (hh.status === 200 && cl > 0) break; await new Promise(s => setTimeout(s, 10000)); }
    if (!cl) throw new Error(`听书缓存 10 分钟还没写好:${url}`);
    r = await fetch(url, { signal: AbortSignal.timeout(300000) });
    if (!r.ok) throw new Error(`取听书缓存 ${r.status}:${url}`);
    buf = Buffer.from(await r.arrayBuffer());
    if (buf.length < cl * 0.98) throw new Error(`听书缓存没取全:${buf.length}/${cl} 字节`);
  }
  return { mp3: Buffer.concat(mp3Frames(buf).frames), hit };   // 只留音频帧:多段朗读每段都带 ID3 头,夹在中间 ASR 会报 Invalid audio format
}

// 朗读原文(不触发合成;拿不到返回 null,调用方退回 ASR 文本)
async function audiobookText(ch) {
  const url = `${AB.base}/${encodeURIComponent(B.slug)}/${encodeURIComponent(stemOf(ch))}.txt`;
  try { const r = await fetch(url, { signal: AbortSignal.timeout(30000) }); return r.ok ? (await r.text()).trim() : null; } catch { return null; }
}
const MIN_RATIO = 0.8;

// ---------- ASR(大模型流式识别)----------
async function asrOnce(mp3) {
  const fmt = mp3Frames(mp3);
  const hdr = (t, f, ser = 1) => Buffer.from([0x11, (t << 4) | f, (ser << 4) | 1, 0]);
  const i32 = n => { const b = Buffer.alloc(4); b.writeInt32BE(n); return b; }, u32 = n => { const b = Buffer.alloc(4); b.writeUInt32BE(n); return b; };
  const pkt = (h, seq, body) => { const z = zlib.gzipSync(body); return Buffer.concat([h, i32(seq), u32(z.length), z]); };
  const parse = d => { d = Buffer.from(d); const mt = d[1] >> 4, fl = d[1] & 15, comp = d[2] & 15; let p = d.subarray(4); if (fl & 3) p = p.subarray(4);
    if (mt === 15) { const sz = p.readUInt32BE(4); let b = p.subarray(8, 8 + sz); if (comp === 1) b = zlib.gunzipSync(b); return { _error: p.readUInt32BE(0), _msg: b.toString() }; }
    const sz = p.readUInt32BE(0); let b = p.subarray(4, 4 + sz); if (comp === 1 && b.length) b = zlib.gunzipSync(b); const o = b.length ? JSON.parse(b) : {}; o._last = !!(fl & 2); return o; };
  return new Promise((resolve, reject) => {
    const ws = new WebSocket('wss://openspeech.bytedance.com/api/v3/sauc/bigmodel', { headers: { 'X-Api-App-Key': env.VOLC_ASR_APPID || env.VOLC_APPID, 'X-Api-Access-Key': env.VOLC_ASR_ACCESS_TOKEN || env.VOLC_TOKEN, 'X-Api-Resource-Id': 'volc.bigasr.sauc.duration', 'X-Api-Connect-Id': crypto.randomUUID() } });
    ws.binaryType = 'arraybuffer'; let last = null; const timer = setTimeout(() => { ws.close(); reject(new Error('ASR 超时')); }, 900000);
    ws.onopen = async () => {
      ws.send(pkt(hdr(1, 1), 1, Buffer.from(JSON.stringify({ user: { uid: 'wjs-motion-book' }, audio: { format: 'mp3', rate: fmt.sr, channel: 1 }, request: { model_name: 'bigmodel', enable_punc: true, enable_itn: true, show_utterances: true } }))));
      const CH = 6400; let seq = 1;   // 64kbps 的 mp3 这样推约 40 倍速
      for (let i = 0; i < mp3.length; i += CH) { seq++; const end = i + CH >= mp3.length; ws.send(pkt(hdr(2, end ? 3 : 1, 0), end ? -seq : seq, mp3.subarray(i, i + CH))); await new Promise(r => setTimeout(r, 20)); }
    };
    ws.onmessage = e => { const r = parse(e.data); if (r._error) { clearTimeout(timer); ws.close(); return reject(new Error(`ASR 错误 ${r._error}: ${r._msg}`)); }
      if (r.result) last = r; if (r._last) { clearTimeout(timer); ws.close(); last ? resolve({ result: last.result }) : reject(new Error('ASR 没有结果')); } };
    ws.onerror = e => { clearTimeout(timer); reject(new Error('ASR 连接失败:' + (e.message || e.type))); };
  });
}
async function asr(mp3) {
  for (let k = 0; ; k++) { try { return await asrOnce(mp3); } catch (e) { if (k === 2) throw e; await new Promise(r => setTimeout(r, 2000 * (k + 1))); } }
}

// ---------- 每章 ----------
async function one(ch) {
  const mp3f = path.join(A, `${ch}.mp3`), asrf = path.join(A, `${ch}.asr.json`), txt = path.join(P, '稿', `${ch}.txt`); let note = '';
  try {
    if (!fs.existsSync(mp3f)) {
      const { mp3, hit } = await audiobookMp3(ch); fs.writeFileSync(mp3f, mp3); fs.rmSync(asrf, { force: true }); fs.rmSync(txt, { force: true });
      note = hit ? ',听书缓存命中' : ',听书缓存没有→经听书接口合成一次(已写回 R2)';
    }
    const mp3 = fs.readFileSync(mp3f);
    if (!fs.existsSync(asrf) || !fs.statSync(asrf).size) fs.writeFileSync(asrf, JSON.stringify(await asr(mp3), null, 1));
    const res = JSON.parse(fs.readFileSync(asrf, 'utf8')), asrText = res.result.text + '\n';
    // 稿 = ASR 原样的是老流程留下的,当作没有,换成原文;手改过的稿不动。
    if (!fs.existsSync(txt) || fs.readFileSync(txt, 'utf8') === asrText) {
      const orig = await audiobookText(ch);
      const ok = orig && alignPhrases(res, orig).ratio >= MIN_RATIO;
      fs.writeFileSync(txt, ok ? orig + '\n' : asrText);
      note += ok ? ',字幕用原文' : `,⚠ 原文${orig ? `对不上(<${MIN_RATIO * 100}%)` : '拿不到'}→字幕退回 ASR 文本`;
    }
    const al = alignPhrases(res, fs.readFileSync(txt, 'utf8'));
    fs.writeFileSync(path.join(A, `${ch}.句时间.txt`), formatRows(al.rows));
    return `${ch} ${mp3Frames(mp3).dur.toFixed(1).padStart(6)}s  ${al.rows.length} 句,对上 ${Math.round(al.ratio * 100)}% 的字${note}`;
  } catch (e) { return `✗ ${ch} ${e.message}`; }
}
for (const d of [A, path.join(P, '稿')]) fs.mkdirSync(d, { recursive: true });
const chs = chapterIds(B).filter(c => !only.size || only.has(c));
const out = await pool(chs, jobs, async ch => { const s = await one(ch); console.log(s); return s; });
if (out.some(s => s.startsWith('✗'))) process.exit(1);
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall