Skip to content

JimLiu/baocut / skills/baocut/built-in-skills/virtual-host

virtual-host

Flagged

做会说话的卡通虚拟主播时用:一个卡通角色(半身像)跟着旁白自动对口型,会眨眼、呼吸、点头转头、头发跟着晃,可以换表情,常驻在画面角落讲解或整镜出镜。用户没有自己的角色时从 BaoCut 自带的 19 个原创主播里推荐,要自己的形象时才生成正面像、改图拆成分层的角色包;口型按读音与音量算成动作轨;放上时间线是一个角色贴纸,预览与导出直接画,不用烘焙。不用于:真人照片或实拍视频对口型、换脸与写实数字人;角色走动、拿东西的表演(character-animation);只要一张插图。

scripts/puppet-mask.mjs

View on GitHub
#!/usr/bin/env node
// i18n-ignore-file: 给智能体拷走用的独立脚本,日志与报错写英文
// The mask for the bald repaint: the portrait's hair (as puppet-build.mjs finds it, or as the part map paints it),
// grown 4 px, as strokes for the retouch tool's repaint (`mask: { strokes }`). Plain Node >= 22.
//
//   node puppet-mask.mjs <character.json> [out.json]
//
// Reads "portrait" and "partmap" (or, without a part map, "skin" / "line" / "hair" when set) from character.json. Writes out.json (default: hair-mask.json next
// to character.json) and out.png, the mask to look at: white is what gets repainted.
import fs from 'node:fs';
import path from 'node:path';
import { readImage, writeGray } from './puppet/png.mjs';
import { segment } from './puppet/segment.mjs';
import { maskStrokes, keyOut } from './puppet/seg.mjs';
import { dilate, count, bbox, or } from './puppet/ops.mjs';
import { readLabels, part } from './puppet/partmap.mjs';

// what the retouch tool takes
const MAX_STROKES = 500, MAX_SHARE = 0.6;

const [cfgArg, outArg] = process.argv.slice(2);
if (!cfgArg) {
  console.error('usage: node puppet-mask.mjs <character.json> [out.json]');
  process.exit(2);
}
const cfgPath = path.resolve(cfgArg);
const cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf8'));
if (!cfg.portrait) {
  console.error('FIX  config: "portrait" is required');
  process.exit(1);
}
const out = path.resolve(outArg ?? path.join(path.dirname(cfgPath), 'hair-mask.json'));
const im = readImage(path.resolve(path.dirname(cfgPath), cfg.portrait)), { w, h } = im;
let hair;
if (cfg.partmap) {
  const pm = readImage(path.resolve(path.dirname(cfgPath), cfg.partmap));
  if (pm.w !== w || pm.h !== h) {
    console.error(`FIX  part map: ${pm.w}x${pm.h}, the portrait is ${w}x${h}; ask for the same size`);
    process.exit(1);
  }
  const { lab } = readLabels(im, pm, keyOut(im));
  hair = or(or(part(lab, 'front'), part(lab, 'side')), part(lab, 'back'));
} else {
  try {
    hair = segment(im, { skin: cfg.skin, line: cfg.line, hair: cfg.hair, glasses: cfg.glasses }).hair;
  } catch (e) {
    console.error(`FIX  portrait: ${e.message}`);
    process.exit(1);
  }
}
const m = dilate(hair, w, h, 4);
const share = count(m) / (w * h);
if (share > MAX_SHARE) {
  console.error(`FIX  the hair mask covers ${(100 * share).toFixed(1)}% of the image (the repaint takes at most 60%): make the character smaller in the frame`);
  process.exit(1);
}
// one stroke per run of each row band; coarser bands until the count fits (a stroke's radius covers its band)
let step = 4, strokes = maskStrokes(m, w, h, step, 3);
while (strokes.length > MAX_STROKES) {
  step += 2;
  strokes = maskStrokes(m, w, h, step, Math.ceil(step / 2) + 1);
}
fs.writeFileSync(out, JSON.stringify({ strokes }) + '\n');
writeGray(out.replace(/\.json$/, '') + '.png', w, h, m.map((v) => v * 255));
console.log(`ok   hair mask: ${count(hair)} px of hair in ${bbox(hair, w, h)}, ${(100 * share).toFixed(1)}% of the image, ${strokes.length} strokes -> ${out}`);
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: 197kUpdated 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