commit 8a5ee09e1d4dfaf787cf6706941d3a11f4518dae
parent 90839d47ca239da9a60b777570dfebb91e3a7103
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 17 Nov 2026 11:16:29 -0500
umtool narration: a card reading kept under the reading it was ASKED at (an engine with no seed reports none)
Found by the new narration-review e2e: a Kokoro card read again was listed as reading 0 and its Pick refused
("made with another voice or speed"). narration-store.mjs records askedReading beside askedTuning; the CLI, its
list and the narration view read it (readingOfRecord). Unit test: a no-seed engine's reading kept, listed and
picked back to its key (fails before this).
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
4 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/umtool/lib/report/cardNarration.test.mjs b/umtool/lib/report/cardNarration.test.mjs
@@ -91,3 +91,35 @@ test("--read --text reads other words (the card keeps its own until a pick); set
const list = await run([p.id, "--list", "--json"]);
assert.equal(list.json().cards[0].readings.length, 1);
});
+
+test("AN ENGINE WITH NO SEED (Kokoro reports no reading): a reading asked is kept under it, listed as it, and picked back to its key", async () => {
+ const p = await project("kokoro");
+ const m = await manifest(p);
+ m.timeline[0].narration = { text: CARD.narration.text, engine: "kokoro", voice: "af_heart" };
+ await writeFile(path.join(p.dir, "video.manifest.json"), JSON.stringify(m, null, 2));
+ const asked = [];
+ const noSeed = async ({ narrations, dir }) => {
+ const recs = new Map();
+ for (const n of narrations) {
+ asked.push(n);
+ const wav = path.join(ROOT, `${n.key}.k.wav`);
+ execFileSync("ffmpeg", ["-v", "error", "-y", "-f", "lavfi", "-i", "sine=f=330:d=1.2", "-ar", "48000", "-ac", "1", wav]);
+ recs.set(n.id, await keepNarration(dir, n, { wav, engine: n.engine, voice: n.voice }, { jobId: "job" }));
+ }
+ return recs;
+ };
+ const go = async (args) => {
+ const lines = [];
+ const code = await cardNarrationCommand(args, { root: REPORTS, out: (s) => lines.push(s), err: (s) => lines.push(s), narrate: noSeed });
+ return { code, out: lines.join("\n") };
+ };
+ assert.equal((await go([p.id, "c1", "--read"])).code, 0);
+ assert.equal((await go([p.id, "c1", "--read", "--reading", "next"])).code, 0);
+ assert.equal(asked[1].reading, 1);
+ const readings = await cardReadings(p.dir, "c1");
+ const second = readings.find((x) => x.key === asked[1].key);
+ const r = await go([p.id, "c1", "--pick", second.key]);
+ assert.equal(r.code, 0, r.out);
+ assert.equal((await manifest(p)).timeline[0].narration.reading, 1);
+ assert.equal(narrationsOf(await manifest(p))[0].key, second.key);
+});
diff --git a/umtool/lib/report/cardNarrationCli.mjs b/umtool/lib/report/cardNarrationCli.mjs
@@ -65,15 +65,18 @@ export async function cardReadings(projectDir, cardId) {
return (await allCardReadings(projectDir)).get(cardId) ?? [];
}
+/** The reading a record was asked at (`askedReading`; an engine with no seed reports none), else the one reported. */
+export const readingOfRecord = (r) => (Number.isInteger(r?.askedReading) ? r.askedReading : Number.isInteger(r?.reading) ? r.reading : 0);
+
/** One past the highest reading `text` was kept at (a record with none: 0), or 0 when it never was. */
export function nextCardReading(readings, text) {
let hi = -1;
- for (const r of readings) if (spacing(r.text) === spacing(text)) hi = Math.max(hi, Number.isInteger(r.reading) ? r.reading : 0);
+ for (const r of readings) if (spacing(r.text) === spacing(text)) hi = Math.max(hi, readingOfRecord(r));
return hi + 1;
}
/** A reading as a line: its key, words, reading, tuning, length -- and whether the card plays it. */
-const readingLine = (r, current) => ` ${r.key === current ? "▶" : " "} ${r.key.slice(0, 12)} ${Number(r.seconds).toFixed(2)} s reading ${r.reading ?? 0}${r.askedTuning ? ` ${Object.entries(r.askedTuning).map(([k, v]) => `${k} ${v}`).join(", ")}` : ""} "${spacing(r.text).slice(0, 70)}"`;
+const readingLine = (r, current) => ` ${r.key === current ? "▶" : " "} ${r.key.slice(0, 12)} ${Number(r.seconds).toFixed(2)} s reading ${readingOfRecord(r)}${r.askedTuning ? ` ${Object.entries(r.askedTuning).map(([k, v]) => `${k} ${v}`).join(", ")}` : ""} "${spacing(r.text).slice(0, 70)}"`;
/** `umtool narration <project> …` */
export async function cardNarrationCommand(args, { root = REPORTS_ROOT, out = (s) => console.log(s), err = (s) => console.error(s), narrate = null } = {}) {
@@ -139,7 +142,7 @@ export async function cardNarrationCommand(args, { root = REPORTS_ROOT, out = (s
const key = String(str("--pick")).trim();
const rec = readings.find((x) => x.key === key || (key.length >= 8 && x.key.startsWith(key)));
if (!rec) throw new NarrateError(`${cardId} has no reading ${key} kept (umtool narration ${project.id} ${cardId})`);
- const patch = { text: rec.text, reading: Number.isInteger(rec.reading) && rec.reading > 0 ? rec.reading : null, tuning: rec.askedTuning ?? null };
+ const patch = { text: rec.text, reading: readingOfRecord(rec) > 0 ? readingOfRecord(rec) : null, tuning: rec.askedTuning ?? null };
const want = resolveNarration({ ...e, narration: { ...e.narration, text: patch.text, reading: patch.reading ?? undefined, tuning: patch.tuning ?? undefined } }, manifest.render);
if (narrationKey(want) !== rec.key) throw new NarrateError(`${cardId}: reading ${rec.key.slice(0, 12)} was made with another voice or speed than the card's now -- read it again (--read)`);
const { result } = await write(patch);
@@ -150,7 +153,7 @@ export async function cardNarrationCommand(args, { root = REPORTS_ROOT, out = (s
const kept = !!row?.verdict && row.key === now.key && spacing(row.text) === spacing(rec.text);
if (kept) await setNarrationReview(project.dir, cardId, { verdict: row.verdict, key: rec.key, text: rec.text });
if (json) out(JSON.stringify({ ok: true, id: cardId, key: rec.key, narration: result.entry.narration, verdictKept: kept, token: result.token ?? null }, null, 2));
- else out(`${cardId}: plays reading ${rec.reading ?? 0} (${rec.key.slice(0, 12)})${kept ? ` -- still ${row.verdict} (the same words)` : ""}`);
+ else out(`${cardId}: plays reading ${readingOfRecord(rec)} (${rec.key.slice(0, 12)})${kept ? ` -- still ${row.verdict} (the same words)` : ""}`);
return 0;
}
const patch = {};
diff --git a/umtool/lib/report/narration-review.mjs b/umtool/lib/report/narration-review.mjs
@@ -13,7 +13,7 @@ import { stat } from "node:fs/promises";
import { estimatedNarratedCardSeconds, narrationWords } from "umtool-report-to-video/narration";
import { DRAFTS_REVIEW_FILE, readNarrationReview, reviewRows } from "umtool-report-to-video/narration-review";
import { narrationDir, narrationWavPath, readNarrationRecord } from "umtool-report-to-video/narration-store";
-import { allCardReadings } from "./cardNarrationCli.mjs";
+import { allCardReadings, readingOfRecord } from "./cardNarrationCli.mjs";
/**
* @param {string} projectDir
@@ -61,7 +61,7 @@ export async function narrationReviewView(projectDir, manifest) {
reading: Number.isInteger(e.narration?.reading) ? e.narration.reading : 0,
tuning: e.narration?.tuning ?? null,
madeWith: rec?.tuning ?? null,
- readings: (kept.get(r.id) ?? []).map((x) => ({ key: x.key, text: x.text, reading: Number.isInteger(x.reading) ? x.reading : 0, tuning: x.askedTuning ?? null, seconds: x.seconds, createdAt: x.createdAt ?? null })),
+ readings: (kept.get(r.id) ?? []).map((x) => ({ key: x.key, text: x.text, reading: readingOfRecord(x), tuning: x.askedTuning ?? null, seconds: x.seconds, createdAt: x.createdAt ?? null })),
});
}
const counts = { approved: 0, rejected: 0, edited: 0, unreviewed: 0 };
diff --git a/umtool/report-to-video/narration-store.mjs b/umtool/report-to-video/narration-store.mjs
@@ -124,6 +124,8 @@ export async function keepNarration(dir, n, result, { jobId = null } = {}) {
// The tuning it was ASKED with (lane line-rerun): what the card says to ask this file again -- its key -- when
// another reading is picked (umtool narration <p> <card> --pick <key>).
...(n.tuning && typeof n.tuning === "object" && Object.keys(n.tuning).length ? { askedTuning: n.tuning } : {}),
+ // ...and the reading it was ASKED at: an engine with no seed (Kokoro) reports none, yet the key holds it.
+ ...(Number.isInteger(n.reading) && n.reading > 0 ? { askedReading: n.reading } : {}),
editor: {
jobId,
cached: result.cached === true,