diff --git a/skills-manifest.json b/skills-manifest.json index 9dbe9e2340..b6cc82c519 100644 --- a/skills-manifest.json +++ b/skills-manifest.json @@ -18,7 +18,7 @@ "files": 13 }, "media-use": { - "hash": "476ec9020960f6f0", + "hash": "d979128f61f6ab95", "files": 131 }, "remotion-to-hyperframes": { diff --git a/skills/media-use/audio/scripts/audio.mjs b/skills/media-use/audio/scripts/audio.mjs index 5eee69c108..8ef0d81b1b 100644 --- a/skills/media-use/audio/scripts/audio.mjs +++ b/skills/media-use/audio/scripts/audio.mjs @@ -127,7 +127,12 @@ const outRel = relative(hyperframesDir, outPath); const outInProject = outRel !== ".." && !outRel.startsWith(`..${sep}`) && !isAbsolute(outRel); if (outInProject && !projectPath(hyperframesDir, outRel)) die(`${outPath} leads outside the project folder; replace it with a regular file`); -const audioMeta = openAudioMeta(outPath); +let audioMeta; +try { + audioMeta = openAudioMeta(outPath); +} catch (e) { + die(`audio_meta.json at ${outPath}: ${e.message}`); +} const prev = audioMeta.value; const anomalies = []; @@ -353,7 +358,9 @@ anomalies.push(...recordInManifest(hyperframesDir, written)); console.log(terminalText(`✓ audio engine → ${outPath}`)); console.log(` heygen: ${heygenOK ? "yes" : "no"} · ran: ${[...only].join(",")}`); console.log( - ` voices: ${voices.length} · bgm: ${bgm ? `${bgmFields.bgm_provider}${bgmFields.bgm_pending ? " (pending)" : ""}` : "none"} · sfx: ${sfx.length}`, + terminalText( + ` voices: ${voices.length} · bgm: ${bgm ? `${bgmFields.bgm_provider}${bgmFields.bgm_pending ? " (pending)" : ""}` : "none"} · sfx: ${sfx.length}`, + ), ); console.log(` total voice duration: ${totalDuration}s`); if (anomalies.length) { diff --git a/skills/media-use/audio/scripts/audio.test.mjs b/skills/media-use/audio/scripts/audio.test.mjs index a8ad665de9..81fd33aaf2 100644 --- a/skills/media-use/audio/scripts/audio.test.mjs +++ b/skills/media-use/audio/scripts/audio.test.mjs @@ -270,3 +270,52 @@ test("a broken audio_request.json prints its bytes with control characters as es rmSync(dir, { recursive: true, force: true }); } }); + +// With --only, bgm_provider and sfx carry over from audio_meta.json unchanged into the summary. +for (const only of ["tts", "sfx"]) { + test(`--only ${only}: values kept from audio_meta.json print with control characters as escapes`, () => { + const dir = mkdtempSync(join(tmpdir(), "audio-kept-escape-")); + try { + writeFileSync(join(dir, "audio_request.json"), JSON.stringify({ lines: [] })); + const kept = { + bgm: { path: "assets/bgm/track.wav" }, + bgm_provider: "p\x1b[2J\x07", + sfx: { length: "n\x1b]0;x\x07" }, + }; + writeFileSync(join(dir, "audio_meta.json"), JSON.stringify(kept)); + const run = spawnSync( + process.execPath, + [join(HERE, "audio.mjs"), "--hyperframes", dir, "--only", only], + { encoding: "utf8", env: { ...process.env, HOME: dir } }, + ); + assert.equal(run.status, 0, run.stderr); + const shown = run.stdout + run.stderr; + assert.match(shown, /bgm: p\\x1b\[2J\\x07/); + if (only === "tts") assert.match(shown, /sfx: n\\x1b\]0;x\\x07/); + for (const raw of ["\x1b", "\x07"]) assert.ok(!shown.includes(raw), JSON.stringify(shown)); + const meta = JSON.parse(readFileSync(join(dir, "audio_meta.json"), "utf8")); + assert.equal(meta.bgm_provider, kept.bgm_provider); + if (only === "tts") assert.deepEqual(meta.sfx, kept.sfx); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }); +} + +test("a broken audio_meta.json prints its bytes with control characters as escapes", () => { + const dir = mkdtempSync(join(tmpdir(), "audio-broken-meta-")); + try { + writeFileSync(join(dir, "audio_request.json"), JSON.stringify({ lines: [] })); + writeFileSync(join(dir, "audio_meta.json"), '{"sfx": [ \x1b]0;x \x07 ]}'); + const run = spawnSync( + process.execPath, + [join(HERE, "audio.mjs"), "--hyperframes", dir, "--only", "sfx"], + { encoding: "utf8", env: { ...process.env, HOME: dir } }, + ); + assert.notEqual(run.status, 0, run.stdout); + assert.match(run.stderr, /audio_meta\.json at .*: .*\\x1b/); + for (const raw of ["\x1b", "\x07"]) assert.ok(!run.stderr.includes(raw), run.stderr); + } finally { + rmSync(dir, { recursive: true, force: true }); + } +});