Skip to content

Commit 6de3415

Browse files
fix(media-use): reject zero and non-numeric TTS speed
`Number(x) || 1.0` turned 0 and non-numeric speeds into 1 before the range check, so they passed silently. The engine now parses the raw request or --speed value once, with no fallback, and the faceless-explainer, pr-to-video and product-launch-video adapters forward the raw flag instead of applying their own copy of the fallback. Co-Authored-By: Miguel Ángel <[email protected]>
1 parent 9e5055f commit 6de3415

6 files changed

Lines changed: 34 additions & 17 deletions

File tree

‎skills-manifest.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"files": 144
77
},
88
"faceless-explainer": {
9-
"hash": "db87ee2e6a1e9a6a",
9+
"hash": "3611c7079a4ccb28",
1010
"files": 27
1111
},
1212
"figma": {
@@ -54,7 +54,7 @@
5454
"files": 1
5555
},
5656
"media-use": {
57-
"hash": "2e006c6e26785901",
57+
"hash": "e2e523d50ce6baec",
5858
"files": 104
5959
},
6060
"motion-graphics": {
@@ -66,11 +66,11 @@
6666
"files": 169
6767
},
6868
"pr-to-video": {
69-
"hash": "92fa20d196073c17",
69+
"hash": "d11e258069d74db7",
7070
"files": 33
7171
},
7272
"product-launch-video": {
73-
"hash": "ec928631f3058f98",
73+
"hash": "1598d7f96e858d01",
7474
"files": 34
7575
},
7676
"remotion-to-hyperframes": {

‎skills/faceless-explainer/scripts/audio.mjs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ function runGenerate(argv) {
131131
const scriptPath = resolve(flag(argv, "script", join(hyperframesDir, "SCRIPT.md")));
132132
const outPath = resolve(flag(argv, "out", join(hyperframesDir, "audio_meta.json")));
133133
const userVoice = flag(argv, "voice", null);
134-
const speed = Number(flag(argv, "speed", "1.0")) || 1.0;
135134

136135
if (!existsSync(storyboardPath)) die(`STORYBOARD.md not found at ${storyboardPath}`);
137136
const manifest = parseStoryboard(readFileSync(storyboardPath, "utf8"));
@@ -166,7 +165,7 @@ function runGenerate(argv) {
166165
const query = (g.extra && g.extra.music) || g.message || g.arc || "calm cinematic underscore";
167166
const request = {
168167
provider: "auto",
169-
speed,
168+
speed: flag(argv, "speed", "1.0"),
170169
lines,
171170
bgm: bgmOff
172171
? { mode: "none" }

‎skills/media-use/audio/scripts/audio.mjs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ try {
109109
}
110110
const lines = Array.isArray(request.lines) ? request.lines : [];
111111
const lang = langOverride || request.lang || "en";
112-
const speed = Number(speedOverride ?? request.speed ?? 1.0) || 1.0;
113-
if (!(speed > 0 && speed <= 3)) die(`speed must be above 0 and at most 3, got ${speed}`);
112+
const speedInput = speedOverride ?? request.speed ?? 1;
113+
const speed = Number(speedInput);
114+
if (!(speed > 0 && speed <= 3))
115+
die(`speed must be above 0 and at most 3, got ${JSON.stringify(speedInput)}`);
114116

115117
// ── env + HeyGen availability (the single switch) ─────────────────────────────
116118
loadEnvFromDir(hyperframesDir);

‎skills/media-use/audio/scripts/audio.test.mjs‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,34 @@ test("two effects never share a file when one's name is taken by the person, run
126126
}
127127
});
128128

129-
test("an out-of-range speed stops the engine before any TTS runs", () => {
129+
// The engine owns speed parsing; a fallback before the check would turn 0 or junk into 1.
130+
function runEngineWith(request, ...args) {
130131
const dir = mkdtempSync(join(tmpdir(), "audio-speed-range-"));
131132
try {
132-
writeFileSync(join(dir, "audio_request.json"), JSON.stringify({ speed: 5, lines: [] }));
133-
const r = spawnSync(process.execPath, [join(HERE, "audio.mjs"), "--hyperframes", dir], {
133+
writeFileSync(join(dir, "audio_request.json"), JSON.stringify({ lines: [], ...request }));
134+
return spawnSync(process.execPath, [join(HERE, "audio.mjs"), "--hyperframes", dir, ...args], {
134135
encoding: "utf8",
135136
});
136-
assert.equal(r.status, 1);
137-
assert.match(r.stderr, /speed must be above 0 and at most 3, got 5/);
138137
} finally {
139138
rmSync(dir, { recursive: true, force: true });
140139
}
140+
}
141+
142+
for (const [label, request, args, shown] of [
143+
["request speed 5", { speed: 5 }, [], "5"],
144+
["request speed 0", { speed: 0 }, [], "0"],
145+
["request speed -1", { speed: -1 }, [], "-1"],
146+
["request speed text", { speed: "fast" }, [], '"fast"'],
147+
["--speed 0", {}, ["--speed", "0"], '"0"'],
148+
["--speed text", { speed: 1 }, ["--speed", "abc"], '"abc"'],
149+
]) {
150+
test(`${label} stops the engine before any TTS runs`, () => {
151+
const r = runEngineWith(request, ...args);
152+
assert.equal(r.status, 1);
153+
assert.ok(r.stderr.includes(`speed must be above 0 and at most 3, got ${shown}`), r.stderr);
154+
});
155+
}
156+
157+
test("a numeric string speed, as the adapters forward it, passes the check", () => {
158+
assert.doesNotMatch(runEngineWith({ speed: "0.8" }, "--only", "tts").stderr, /speed must/);
141159
});

‎skills/pr-to-video/scripts/audio.mjs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ function runGenerate(argv) {
131131
const scriptPath = resolve(flag(argv, "script", join(hyperframesDir, "SCRIPT.md")));
132132
const outPath = resolve(flag(argv, "out", join(hyperframesDir, "audio_meta.json")));
133133
const userVoice = flag(argv, "voice", null);
134-
const speed = Number(flag(argv, "speed", "1.0")) || 1.0;
135134

136135
if (!existsSync(storyboardPath)) die(`STORYBOARD.md not found at ${storyboardPath}`);
137136
const manifest = parseStoryboard(readFileSync(storyboardPath, "utf8"));
@@ -166,7 +165,7 @@ function runGenerate(argv) {
166165
const query = (g.extra && g.extra.music) || g.message || g.arc || "calm cinematic underscore";
167166
const request = {
168167
provider: "auto",
169-
speed,
168+
speed: flag(argv, "speed", "1.0"),
170169
lines,
171170
bgm: bgmOff
172171
? { mode: "none" }

‎skills/product-launch-video/scripts/audio.mjs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ function runGenerate(argv) {
130130
const outPath = resolve(flag(argv, "out", join(hyperframesDir, "audio_meta.json")));
131131
const userVoice = flag(argv, "voice", null);
132132
const provider = flag(argv, "provider", process.env.HF_TTS_PROVIDER || "auto");
133-
const speed = Number(flag(argv, "speed", "1.0")) || 1.0;
134133

135134
if (!existsSync(storyboardPath)) die(`STORYBOARD.md not found at ${storyboardPath}`);
136135
const manifest = parseStoryboard(readFileSync(storyboardPath, "utf8"));
@@ -165,7 +164,7 @@ function runGenerate(argv) {
165164
const query = (g.extra && g.extra.music) || g.message || g.arc || "calm cinematic underscore";
166165
const request = {
167166
provider,
168-
speed,
167+
speed: flag(argv, "speed", "1.0"),
169168
lines,
170169
bgm: bgmOff
171170
? { mode: "none" }

0 commit comments

Comments
 (0)