Skip to content

Makkov-design/makkov-harness / 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
LICENSEother10.5 KB
SKILL.mdskill md5.9 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.4 KB
audio/references/sfx.mdmarkdown6.4 KB
audio/references/transcribe.mdmarkdown2.8 KB
audio/references/tts-to-captions.mdmarkdown1.7 KB
audio/references/tts.mdmarkdown13.7 KB
audio/scripts/audio.mjsscript13.1 KB
audio/scripts/audio.test.mjsscript5.9 KB
audio/scripts/carve.mjsscript23.3 KB
audio/scripts/carve.test.mjsscript11.5 KB
audio/scripts/extract-audio-data.pyscript7.0 KB
audio/scripts/gemini-pipeline.test.mjsscript5.0 KB
audio/scripts/heygen-tts.mjsscript4.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-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.3 KB
audio/scripts/lib/bgm.test.mjsscript2.6 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.mjsscript12.6 KB
audio/scripts/lib/heygen.test.mjsscript14.8 KB
audio/scripts/lib/main-module.mjsscript479 B
audio/scripts/lib/media-record.mjsscript4.1 KB
audio/scripts/lib/media-record.test.mjsscript7.7 KB
audio/scripts/lib/openverse.mjsscript7.8 KB
audio/scripts/lib/openverse.test.mjsscript4.3 KB
audio/scripts/lib/python.mjsscript3.2 KB
audio/scripts/lib/python.test.mjsscript5.2 KB
audio/scripts/lib/sfx.mjsscript7.2 KB
audio/scripts/lib/sfx.test.mjsscript11.6 KB
audio/scripts/lib/tts.cleanup.test.mjsscript6.6 KB
audio/scripts/lib/tts.mjsscript17.3 KB
audio/scripts/lib/tts.spawn.test.mjsscript5.1 KB
audio/scripts/lib/tts.test.mjsscript8.1 KB
audio/scripts/lyria-recipe.pyscript4.9 KB
audio/scripts/wait-bgm.mjsscript5.7 KB
audio/scripts/wait-bgm.test.mjsscript3.3 KB
luts/README.mdmarkdown1.1 KB
luts/index.jsonconfig2.0 KB
references/audio.mdmarkdown2.4 KB
references/grading.mdmarkdown7.0 KB
references/heygen.mdmarkdown8.5 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.8 KB
references/mixing.mdmarkdown4.5 KB
references/operations.mdmarkdown15.7 KB
references/resolve.mdmarkdown9.5 KB
references/setup-providers.mdmarkdown9.3 KB
references/telemetry-dashboard.mdmarkdown4.1 KB
scripts/audio-duck.mjsscript4.0 KB
scripts/compatibility.test.mjsscript1.6 KB
scripts/dither.mjsscript9.7 KB
scripts/dither.test.mjsscript4.6 KB
scripts/eval.mjsscript14.5 KB
scripts/lib/config-lock.mjsscript1.5 KB
scripts/lib/cutlist.mjsscript6.2 KB
scripts/lib/duck.mjsscript3.8 KB
scripts/lib/error-diffusion.mjsscript6.5 KB
scripts/lib/hyperframes-pin.mjsscript1.8 KB
scripts/lib/hyperframes-pin.test.mjsscript1.0 KB
scripts/lib/index-gen.mjsscript1.9 KB
scripts/lib/manifest.mjsscript9.2 KB
scripts/lib/media-fetch.mjsscript2.8 KB
scripts/lib/media-home.mjsscript730 B
scripts/lib/npx-sync.mjsscript2.3 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.mjsscript2.8 KB
scripts/lib/transcriptCutFade.mjsscript911 B
scripts/lib/words.mjsscript728 B
scripts/prefs.mjsscript2.3 KB
scripts/recipe.mjsscript3.8 KB
scripts/resolve-plugin.test.mjsscript2.5 KB
scripts/resolve.mjsscript1.3 KB
scripts/transcribe.mjsscript7.5 KB
scripts/transcribe.test.mjsscript4.0 KB
scripts/transcript-cut.mjsscript10.0 KB
scripts/transcript-cut.test.mjsscript9.6 KB

audio/scripts/lib/openverse.mjs

View on GitHub
// Changed by makkov-harness (see NOTICE at the repository root); the original is HeyGen's, Apache-2.0.
// Sound effects from Openverse (https://api.openverse.org): free, no key needed.
// Anonymous use is rate limited (20 requests a minute, 200 a day). With a free registered
// app (OPENVERSE_CLIENT_ID + OPENVERSE_CLIENT_SECRET in the environment) searches carry a
// Bearer token and get the higher registered limits. Callers fall back to the bundled
// library when Openverse is unavailable.

import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { dirname } from "node:path";

const OPENVERSE_AUDIO_URL = "https://api.openverse.org/v1/audio/";
const OPENVERSE_TOKEN_URL = "https://api.openverse.org/v1/auth_tokens/token/";
// The only licences media-use accepts: no NonCommercial, ShareAlike or NoDerivatives.
export const OPENVERSE_SFX_LICENSES = new Set(["cc0", "by"]);
const PLAYABLE_FILETYPES = new Set(["mp3", "wav", "ogg", "flac"]);
const MAX_SFX_MS = 15000;
const IDEAL_SFX_MS = 4000;
const BY_PENALTY = 2;
const SEARCH_TIMEOUT_MS = 10000;

// Openverse text lands in markdown and JSON: one line, no control or markdown-structure characters, bounded.
const oneLine = (text) =>
  String(text ?? "")
    .replace(/[\p{Cc}`[\]<>\\]+/gu, " ")
    .trim()
    .slice(0, 300);
// Openverse's audio providers (api.openverse.org/v1/audio/stats/); a new provider's link is dropped until listed.
const SOURCE_HOSTS = new Set(["freesound.org", "www.jamendo.com", "commons.wikimedia.org"]);
function httpsUrl(url, hosts) {
  try {
    const parsed = new URL(url);
    return parsed.protocol === "https:" && (!hosts || hosts.has(parsed.hostname))
      ? oneLine(parsed.href)
      : "";
  } catch {
    return "";
  }
}

/** Openverse could not answer (offline, rate limited, server error): stop asking it this run. */
export class OpenverseUnavailableError extends Error {
  constructor(message) {
    super(message);
    this.name = "OpenverseUnavailableError";
  }
}

function usable(result) {
  return (
    OPENVERSE_SFX_LICENSES.has(result?.license) &&
    PLAYABLE_FILETYPES.has(result.filetype) &&
    typeof result.url === "string" &&
    result.url.startsWith("https://") &&
    Number.isFinite(result.duration) &&
    result.duration > 0 &&
    result.duration <= MAX_SFX_MS
  );
}

// Lower is better: relevance position, then seconds past a typical cue length, then CC0 over CC BY.
function penalty(result, position) {
  const longBy = Math.max(0, result.duration - IDEAL_SFX_MS) / 1000;
  return position + longBy + (result.license === "by" ? BY_PENALTY : 0);
}

/** Best usable sound in Openverse's relevance-ordered results, or null. */
export function pickOpenverseSfx(results) {
  let best = null;
  results.forEach((result, position) => {
    if (!usable(result)) return;
    const score = penalty(result, position);
    if (!best || score < best.score) best = { result, score };
  });
  if (!best) return null;
  const r = best.result;
  return {
    id: r.id,
    url: r.url,
    ext: `.${r.filetype}`,
    title: oneLine(r.title),
    creator: oneLine(r.creator),
    license: r.license,
    licenseUrl: httpsUrl(r.license_url),
    sourceUrl: httpsUrl(r.foreign_landing_url, SOURCE_HOSTS),
    credit: oneLine(r.attribution),
    durationS: Math.round(r.duration) / 1000,
  };
}

// Access token for a registered Openverse app, cached until a minute before it expires.
// The credentials only ever come from the environment and are never written anywhere.
// A refused pair is remembered for a few minutes too, so a wrong key costs one extra
// request per run instead of one per search.
let cachedToken = null;
const REFUSED_RETRY_MS = 5 * 60 * 1000;
const refuse = (clientId, now) => {
  cachedToken = { clientId, value: null, expiresAt: now() + REFUSED_RETRY_MS };
  return null;
};

/** Forget the cached token (tests, or after Openverse rejected it). */
export function resetOpenverseToken() {
  cachedToken = null;
}

/** Bearer token when OPENVERSE_CLIENT_ID and OPENVERSE_CLIENT_SECRET are set, else null (anonymous). */
export async function openverseToken({ fetchImpl = fetch, env = process.env, now = Date.now } = {}) {
  const clientId = env.OPENVERSE_CLIENT_ID?.trim();
  const clientSecret = env.OPENVERSE_CLIENT_SECRET?.trim();
  if (!clientId || !clientSecret) return null;
  if (cachedToken && cachedToken.clientId === clientId && cachedToken.expiresAt > now())
    return cachedToken.value;
  try {
    const response = await fetchImpl(OPENVERSE_TOKEN_URL, {
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" },
      body: new URLSearchParams({
        grant_type: "client_credentials",
        client_id: clientId,
        client_secret: clientSecret,
      }).toString(),
      signal: AbortSignal.timeout(SEARCH_TIMEOUT_MS),
    });
    if (!response.ok) return refuse(clientId, now);
    const body = await response.json();
    if (typeof body?.access_token !== "string" || !body.access_token) return refuse(clientId, now);
    const lifetimeS = Number.isFinite(body.expires_in) ? body.expires_in : 3600;
    cachedToken = {
      clientId,
      value: body.access_token,
      expiresAt: now() + Math.max(0, lifetimeS - 60) * 1000,
    };
    return cachedToken.value;
  } catch {
    // An unverified email, a typo or a network blip: search anonymously instead of failing.
    return refuse(clientId, now);
  }
}

/** Best licensed sound effect for `query`, null on no match; throws OpenverseUnavailableError. */
export async function searchOpenverseSfx(
  query,
  { fetchImpl = fetch, env = process.env, now = Date.now } = {},
) {
  const params = new URLSearchParams({
    q: query,
    page_size: "20",
    license: [...OPENVERSE_SFX_LICENSES].join(","),
  });
  const search = async (token) => {
    const headers = { Accept: "application/json" };
    if (token) headers.Authorization = `Bearer ${token}`;
    try {
      return await fetchImpl(`${OPENVERSE_AUDIO_URL}?${params}`, {
        headers,
        signal: AbortSignal.timeout(SEARCH_TIMEOUT_MS),
      });
    } catch (error) {
      throw new OpenverseUnavailableError(`Openverse unreachable (${error.message})`);
    }
  };
  const token = await openverseToken({ fetchImpl, env, now });
  let response = await search(token);
  if (token && response.status === 401) {
    // Revoked or expired early: stay anonymous for a while and ask once more without a token.
    refuse(env.OPENVERSE_CLIENT_ID.trim(), now);
    response = await search(null);
  }
  if (response.status === 429)
    throw new OpenverseUnavailableError("Openverse rate limit reached (HTTP 429)");
  if (!response.ok) throw new OpenverseUnavailableError(`Openverse HTTP ${response.status}`);
  let body;
  try {
    body = await response.json();
  } catch {
    throw new OpenverseUnavailableError("Openverse returned non-JSON");
  }
  return pickOpenverseSfx(Array.isArray(body?.results) ? body.results : []);
}

/** Record a CC BY sound's credit for `file` in the project's credits file (one line per file). */
export function writeSfxCredit(creditsPath, file, sound) {
  if (sound.license !== "by") return;
  // The sound may come from a saved record, not this run's pick: clean it again here.
  const sourceUrl = httpsUrl(sound.sourceUrl, SOURCE_HOSTS);
  const source = sourceUrl ? ` Source: ${sourceUrl}` : "";
  const line = `- \`${file}\`: ${oneLine(sound.credit)}${source}`;
  let prior = "";
  try {
    prior = readFileSync(creditsPath, "utf8");
  } catch (error) {
    if (error.code !== "ENOENT") throw error;
  }
  const kept = prior
    .split("\n")
    .filter((l) => l.startsWith("- ") && !l.startsWith(`- \`${file}\`:`));
  const header =
    "# Sound effect credits\n\nThese sounds are licensed CC BY: credit them wherever the video is published.\n\n";
  mkdirSync(dirname(creditsPath), { recursive: true });
  writeFileSync(creditsPath, `${header}${[...kept, line].join("\n")}\n`);
}
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