Skip to content

JaimeJunr/claude-code-frontend-skills / plugins/hyperframes/skills/media-use

media-use

Verified

Get or make any media for a HyperFrames video - music, sound effects, images, icons, logos, voiceover, avatar and generated video, transcripts, cutouts, colour grades and looks - with HeyGen or free local tools, and mix placed audio. Also for footage that looks dark, flat or dull, or should be stylized or hidden.

FileKindSize
.gitignoreother17 B
SKILL.mdskill md5.3 KB
audio/assets/sfx/CREDITS.mdmarkdown1.2 KB
audio/assets/sfx/chime.mp3binary26.7 KB
audio/assets/sfx/click-soft.mp3binary11.4 KB
audio/assets/sfx/click.mp3binary11.4 KB
audio/assets/sfx/error.mp3binary50.6 KB
audio/assets/sfx/glitch-1.mp3binary82.4 KB
audio/assets/sfx/glitch-2.mp3binary109.5 KB
audio/assets/sfx/glitch-3.mp3binary96.8 KB
audio/assets/sfx/impact-bass-1.mp3binary66.1 KB
audio/assets/sfx/impact-bass-2.mp3binary81.0 KB
audio/assets/sfx/key-press.mp3binary3.8 KB
audio/assets/sfx/manifest.jsonconfig3.6 KB
audio/assets/sfx/notification.mp3binary76.7 KB
audio/assets/sfx/ping.mp3binary25.8 KB
audio/assets/sfx/pop.mp3binary22.5 KB
audio/assets/sfx/riser.mp3binary313.5 KB
audio/assets/sfx/sparkle.mp3binary56.3 KB
audio/assets/sfx/typing.mp3binary26.2 KB
audio/assets/sfx/whoosh-cinematic.mp3binary173.3 KB
audio/assets/sfx/whoosh-short.mp3binary18.0 KB
audio/assets/sfx/whoosh.mp3binary18.0 KB
audio/references/bgm.mdmarkdown7.9 KB
audio/references/captions/authoring.mdmarkdown9.2 KB
audio/references/captions/motion.mdmarkdown5.4 KB
audio/references/captions/transcript-handling.mdmarkdown5.3 KB
audio/references/remove-background.mdmarkdown8.3 KB
audio/references/requirements.mdmarkdown4.7 KB
audio/references/sfx.mdmarkdown4.0 KB
audio/references/transcribe.mdmarkdown2.8 KB
audio/references/tts-to-captions.mdmarkdown1.7 KB
audio/references/tts.mdmarkdown13.9 KB
audio/scripts/audio.mjsscript15.2 KB
audio/scripts/audio.test.mjsscript8.4 KB
audio/scripts/carve.mjsscript20.1 KB
audio/scripts/carve.test.mjsscript12.2 KB
audio/scripts/extract-audio-data.pyscript7.1 KB
audio/scripts/gemini-pipeline.test.mjsscript4.8 KB
audio/scripts/heygen-tts.mjsexecutablescript4.3 KB
audio/scripts/heygen-tts.test.mjsscript1.4 KB
audio/scripts/heygen-voice.mjsscript3.8 KB
audio/scripts/heygen-voice.test.mjsscript8.3 KB
audio/scripts/lib/audio-carve.mjsscript16.6 KB
audio/scripts/lib/audio-meta.mjsscript1.1 KB
audio/scripts/lib/audio-meta.test.mjsscript4.5 KB
audio/scripts/lib/bgm-volume.mjsscript236 B
audio/scripts/lib/bgm.mjsscript11.5 KB
audio/scripts/lib/bgm.test.mjsscript4.7 KB
audio/scripts/lib/concurrency.mjsscript527 B
audio/scripts/lib/concurrency.test.mjsscript1.6 KB
audio/scripts/lib/gemini-auth.mjsscript1.6 KB
audio/scripts/lib/gemini-auth.pyscript1.9 KB
audio/scripts/lib/gemini-auth.test.mjsscript3.0 KB
audio/scripts/lib/gemini-auth_test.pyscript4.3 KB
audio/scripts/lib/gemini-tts.mjsscript5.0 KB
audio/scripts/lib/gemini-tts.test.mjsscript9.2 KB
audio/scripts/lib/heygen.mjsscript14.3 KB
audio/scripts/lib/heygen.test.mjsscript22.9 KB
audio/scripts/lib/main-module.mjsscript479 B
audio/scripts/lib/media-record.mjsscript5.1 KB
audio/scripts/lib/media-record.test.mjsscript12.6 KB
audio/scripts/lib/openverse.mjsscript4.9 KB
audio/scripts/lib/project-path.mjsscript2.2 KB
audio/scripts/lib/project-path.test.mjsscript3.0 KB
audio/scripts/lib/python.mjsscript4.6 KB
audio/scripts/lib/python.test.mjsscript7.8 KB
audio/scripts/lib/recording.mjsscript4.4 KB
audio/scripts/lib/sfx.mjsscript7.2 KB
audio/scripts/lib/sfx.test.mjsscript11.6 KB
audio/scripts/lib/tts.cleanup.test.mjsscript7.0 KB
audio/scripts/lib/tts.mjsscript18.6 KB
audio/scripts/lib/tts.spawn.test.mjsscript6.0 KB
audio/scripts/lib/tts.test.mjsscript10.2 KB
audio/scripts/lib/voice-credit.mjsscript686 B
audio/scripts/lib/voice-credit.test.mjsscript946 B
audio/scripts/lyria-recipe.pyscript4.9 KB
audio/scripts/recording.test.mjsscript9.2 KB
audio/scripts/trusted-program.test.mjsscript3.4 KB
audio/scripts/trusted_program.pyscript2.8 KB
audio/scripts/wait-bgm.mjsscript6.1 KB
audio/scripts/wait-bgm.test.mjsscript8.0 KB
luts/README.mdmarkdown1.1 KB
luts/index.jsonconfig2.0 KB
references/audio.mdmarkdown3.5 KB
references/grading.mdmarkdown7.0 KB
references/heygen.mdmarkdown11.8 KB
references/local.mdmarkdown2.6 KB
references/media-treatment-recipes.mdmarkdown35.0 KB
references/media-treatments.mdmarkdown13.8 KB
references/memory.mdmarkdown3.7 KB
references/meta.mdmarkdown6.4 KB
references/mixing.mdmarkdown4.5 KB
references/operations.mdmarkdown15.8 KB
references/resolve.mdmarkdown9.9 KB
references/setup-providers.mdmarkdown9.1 KB
references/telemetry-dashboard.mdmarkdown4.1 KB
scripts/audio-duck.mjsscript4.0 KB
scripts/compatibility.test.mjsscript1.6 KB
scripts/dither.mjsscript9.8 KB
scripts/dither.test.mjsscript4.6 KB
scripts/eval.mjsscript14.6 KB
scripts/lib/config-lock.mjsscript1.5 KB
scripts/lib/credit-limit.mjsscript2.0 KB
scripts/lib/cutlist.mjsscript6.2 KB
scripts/lib/duck.mjsscript3.8 KB
scripts/lib/error-diffusion.mjsscript6.5 KB
scripts/lib/index-gen.mjsscript2.0 KB
scripts/lib/manifest.mjsscript10.6 KB
scripts/lib/media-fetch.mjsscript2.8 KB
scripts/lib/media-home.mjsscript730 B
scripts/lib/npx-sync.mjsscript3.2 KB
scripts/lib/parakeet-words.mjsscript1.1 KB
scripts/lib/prefs-store.mjsscript6.8 KB
scripts/lib/recipe-store.mjsscript13.0 KB
scripts/lib/telemetry.mjsscript8.8 KB
scripts/lib/telemetry.test.mjsscript3.0 KB
scripts/lib/transcriptCutFade.mjsscript911 B
scripts/lib/windows-exe-search.mjsscript640 B
scripts/lib/words.mjsscript728 B
scripts/prefs.mjsscript2.3 KB
scripts/recipe.mjsscript3.8 KB
scripts/resolve-plugin.test.mjsscript3.2 KB
scripts/resolve.mjsscript1.4 KB
scripts/transcribe.mjsscript8.0 KB
scripts/transcribe.test.mjsscript7.7 KB
scripts/transcript-cut.mjsscript10.1 KB
scripts/transcript-cut.test.mjsscript9.6 KB

audio/scripts/lib/tts.test.mjs

View on GitHub
import { test } from "node:test";
import assert from "node:assert/strict";
import {
  mkdirSync,
  mkdtempSync,
  readFileSync,
  writeFileSync,
  chmodSync,
  rmSync,
  existsSync,
} from "node:fs";
import { join, dirname } from "node:path";
import { tmpdir } from "node:os";
import {
  parseFfmpegDurationBanner,
  ffprobeDuration,
  synthesizeOne,
  synthesizeHeygen,
  synthResult,
  pickProvider,
  transcribeWav,
  _resetNpxResolutionWarnForTests,
} from "./tts.mjs";

test("parseFfmpegDurationBanner reads ffmpeg's stderr Duration line", () => {
  const stderr = [
    "ffmpeg version 6.0",
    "Input #0, wav, from 'a.wav':",
    "  Duration: 00:00:03.42, bitrate: 705 kb/s",
    "At least one output file must be specified",
  ].join("\n");
  assert.equal(parseFfmpegDurationBanner(stderr), 3.42);
});

test("parseFfmpegDurationBanner handles an hours component", () => {
  const stderr = "  Duration: 01:02:03.50, start: 0.000000, bitrate: 128 kb/s";
  assert.equal(parseFfmpegDurationBanner(stderr), 3723.5);
});

test("parseFfmpegDurationBanner returns NaN when there is no Duration line", () => {
  assert.ok(Number.isNaN(parseFfmpegDurationBanner("ffmpeg: command not found")));
  assert.ok(Number.isNaN(parseFfmpegDurationBanner("")));
  assert.ok(Number.isNaN(parseFfmpegDurationBanner(undefined)));
});

// Regression for the actual bug: ffprobeDuration used to collapse "ffprobe
// binary is missing" (ENOENT — the "essentials"-style Windows ffmpeg build
// with no ffprobe.exe) and "file is genuinely unreadable" into the same NaN,
// giving audio.mjs no way to tell "measure differently" from "give up".
//
// Builds an isolated PATH containing only a fake `ffmpeg` stub (no `ffprobe`
// at all) so ffprobeDuration's spawnSync("ffprobe", ...) call ENOENTs for
// real, then verifies it recovers the duration via the ffmpeg fallback
// instead of returning NaN.
test("ffprobeDuration falls back to ffmpeg when the ffprobe binary itself is missing", () => {
  const dir = mkdtempSync(join(tmpdir(), "tts-ffprobe-fallback-"));
  const fakeFfmpeg = join(dir, "ffmpeg");
  writeFileSync(
    fakeFfmpeg,
    "#!/bin/sh\necho 'Duration: 00:00:02.50, start: 0.000000, bitrate: 128 kb/s' 1>&2\nexit 1\n",
  );
  chmodSync(fakeFfmpeg, 0o755);
  const originalPath = process.env.PATH;
  try {
    process.env.PATH = dir; // only the fake ffmpeg resolves; no real ffprobe on this PATH
    assert.equal(ffprobeDuration("/does/not/matter.wav"), 2.5);
  } finally {
    process.env.PATH = originalPath;
    rmSync(dir, { recursive: true, force: true });
  }
});

test("ffprobeDuration returns NaN when neither ffprobe nor ffmpeg resolve", () => {
  const dir = mkdtempSync(join(tmpdir(), "tts-no-binaries-"));
  const originalPath = process.env.PATH;
  try {
    process.env.PATH = dir; // empty directory — nothing resolves
    assert.ok(Number.isNaN(ffprobeDuration("/does/not/matter.wav")));
  } finally {
    process.env.PATH = originalPath;
    rmSync(dir, { recursive: true, force: true });
  }
});

test("synthesizeOne(elevenlabs) creates the output dir before writing", async () => {
  const dir = mkdtempSync(join(tmpdir(), "tts-el-mkdir-"));
  const wavAbs = join(dir, "assets", "voice", "line-0.wav"); // nested, not yet created
  const savedKey = process.env.ELEVENLABS_API_KEY;
  try {
    // Unset the key so the Python side fails fast — the mkdir must run before
    // the spawn regardless, which is what this guards.
    delete process.env.ELEVENLABS_API_KEY;
    await synthesizeOne({
      provider: "elevenlabs",
      text: "hi",
      voiceId: "v",
      wavAbs,
      hyperframesDir: dir,
    });
    assert.ok(existsSync(dirname(wavAbs)), "output directory should be created");
  } finally {
    if (savedKey === undefined) delete process.env.ELEVENLABS_API_KEY;
    else process.env.ELEVENLABS_API_KEY = savedKey;
    rmSync(dir, { recursive: true, force: true });
  }
});

test("synthesizeHeygen surfaces a thrown HTTP error (e.g. 402) instead of swallowing it", async () => {
  const res = await synthesizeHeygen(
    { text: "hi", voiceId: "v1", lang: "en", speed: 1, wavAbs: "/tmp/x.wav" },
    {
      heygenAuthHeaders: () => ({}),
      heygenJSON: async () => {
        throw new Error("HeyGen POST /voices/speech → HTTP 402\nplan_upgrade_required");
      },
    },
  );
  assert.equal(res.ok, false);
  assert.match(res.error, /402/);
  assert.match(res.error, /plan_upgrade_required/);
});

test("synthesizeHeygen surfaces a failed audio_url fetch with its status", async () => {
  const res = await synthesizeHeygen(
    { text: "hi", voiceId: "v1", lang: "en", speed: 1, wavAbs: "/tmp/x.wav" },
    {
      heygenAuthHeaders: () => ({}),
      heygenJSON: async () => ({ data: { audio_url: "http://audio.example/x" } }),
      fetch: async () => ({ ok: false, status: 403 }),
    },
  );
  assert.equal(res.ok, false);
  assert.match(res.error, /HTTP 403/);
});

test("synthesizeHeygen reports a missing audio_url", async () => {
  const res = await synthesizeHeygen(
    { text: "hi", voiceId: "v1", lang: "en", speed: 1, wavAbs: "/tmp/x.wav" },
    { heygenAuthHeaders: () => ({}), heygenJSON: async () => ({}) },
  );
  assert.equal(res.ok, false);
  assert.match(res.error, /no audio_url/);
});

test("synthesizeHeygen reports wav transcode failures", async () => {
  const dir = mkdtempSync(join(tmpdir(), "hf-tts-test-"));
  try {
    const res = await synthesizeHeygen(
      { text: "hi", voiceId: "v1", lang: "en", speed: 1, wavAbs: join(dir, "voice.wav") },
      {
        heygenAuthHeaders: () => ({}),
        heygenJSON: async () => ({ data: { audio_url: "http://audio.example/x" } }),
        fetch: async () => ({ ok: true, status: 200, arrayBuffer: async () => new ArrayBuffer(0) }),
        transcodeToWav: () => false,
      },
    );
    assert.equal(res.ok, false);
    assert.equal(res.error, "wav transcode failed (ffmpeg)");
  } finally {
    rmSync(dir, { recursive: true, force: true });
  }
});

test("synthResult names a non-zero subprocess exit", () => {
  const res = synthResult({ status: 2 }, "/tmp/none.wav", "kokoro (npx hyperframes tts)");
  assert.equal(res.ok, false);
  assert.match(res.error, /kokoro .* exited with status 2/);
});

// Kokoro runs `hyperframes tts` through the CLI its caller hands over in HYPERFRAMES_CLI_ENTRY; a
// fake entry records the argv synthesizeOne really builds, so a dropped flag fails here.
async function kokoroArgv(options) {
  const dir = mkdtempSync(join(tmpdir(), "tts-kokoro-argv-"));
  const argvLog = join(dir, "argv.txt");
  const cli = join(dir, "cli.mjs");
  writeFileSync(
    cli,
    `import { writeFileSync } from "node:fs";\n` +
      `writeFileSync(${JSON.stringify(argvLog)}, process.argv.slice(2).join("\\n"));\n`,
  );
  const originalEntry = process.env.HYPERFRAMES_CLI_ENTRY;
  try {
    process.env.HYPERFRAMES_CLI_ENTRY = cli;
    await synthesizeOne({
      provider: "kokoro",
      text: "hi",
      voiceId: "am_michael",
      wavAbs: join(dir, "line-0.wav"),
      hyperframesDir: dir,
      ...options,
    });
    return readFileSync(argvLog, "utf8").trim().split("\n");
  } finally {
    if (originalEntry === undefined) delete process.env.HYPERFRAMES_CLI_ENTRY;
    else process.env.HYPERFRAMES_CLI_ENTRY = originalEntry;
    rmSync(dir, { recursive: true, force: true });
  }
}

test("synthesizeOne(kokoro) forwards a non-default speed to the CLI", async () => {
  const argv = await kokoroArgv({ speed: 0.8, lang: "es" });
  assert.equal(argv[0], "tts");
  assert.deepEqual(argv.slice(-4), ["--lang", "es", "--speed", "0.8"]);
});

test("synthesizeOne(kokoro) leaves --speed off at the default", async () => {
  assert.ok(!(await kokoroArgv({})).includes("--speed"));
});

test(
  "kokoro and transcription without a handed-over CLI fail with the fix, never npx",
  { skip: process.platform === "win32" },
  async () => {
    const dir = mkdtempSync(join(tmpdir(), "tts-kokoro-no-cli-"));
    const marker = join(dir, "npx-ran");
    writeFileSync(join(dir, "npx"), `#!/bin/sh\ntouch "${marker}"\n`);
    chmodSync(join(dir, "npx"), 0o755);
    const saved = { PATH: process.env.PATH, entry: process.env.HYPERFRAMES_CLI_ENTRY };
    const originalError = console.error;
    const errors = [];
    try {
      process.env.PATH = dir;
      delete process.env.HYPERFRAMES_CLI_ENTRY;
      console.error = (message) => errors.push(String(message));
      _resetNpxResolutionWarnForTests();
      const res = await synthesizeOne({
        provider: "kokoro",
        text: "hi",
        voiceId: "am_michael",
        wavAbs: join(dir, "line-0.wav"),
        hyperframesDir: dir,
      });
      assert.equal(res.ok, false);
      assert.match(res.error, /HYPERFRAMES_CLI_ENTRY/);
      assert.equal(await transcribeWav({ wavRel: "line-0.wav", hyperframesDir: dir }), null);
      assert.equal(existsSync(marker), false);
      assert.equal(errors.length, 1);
    } finally {
      console.error = originalError;
      process.env.PATH = saved.PATH;
      if (saved.entry !== undefined) process.env.HYPERFRAMES_CLI_ENTRY = saved.entry;
      rmSync(dir, { recursive: true, force: true });
    }
  },
);

test("pickProvider heygen with an unreadable credentials path says to fix that path", () => {
  const saved = ["HEYGEN_API_KEY", "HYPERFRAMES_API_KEY", "HYPERFRAMES_CONFIG_DIR"].map((k) => [
    k,
    process.env[k],
  ]);
  const dir = mkdtempSync(join(tmpdir(), "tts-cred-"));
  try {
    delete process.env.HEYGEN_API_KEY;
    delete process.env.HYPERFRAMES_API_KEY;
    process.env.HYPERFRAMES_CONFIG_DIR = dir;
    mkdirSync(join(dir, "credentials"));
    assert.throws(() => pickProvider("heygen"), /fix or remove that path/);
  } finally {
    for (const [k, v] of saved) {
      if (v === undefined) delete process.env[k];
      else process.env[k] = v;
    }
    rmSync(dir, { recursive: true, force: true });
  }
});

test("synthesizeHeygen refuses under a credit limit before any request", async () => {
  const dir = mkdtempSync(join(tmpdir(), "hf-tts-limit-"));
  mkdirSync(join(dir, ".hyperframes"));
  writeFileSync(join(dir, ".hyperframes", "credit-limit.json"), '{"credits": 5}');
  let asked = false;
  const r = await synthesizeHeygen(
    { text: "hi", voiceId: "v", lang: "en", speed: 1, wavAbs: join(dir, "a.wav") },
    { projectDir: dir, heygenJSON: async () => ((asked = true), {}) },
  );
  assert.equal(r.ok, false);
  assert.match(r.error, /credit limit of 5/);
  assert.equal(asked, false);
});
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