// readTuning.mjs: the flags that ask a take's tuning and reading again (lane line-rerun: its recorded takes always). import assert from "node:assert/strict"; import { test } from "node:test"; import { tuningArgvOf } from "./readTuning.mjs"; import { nextReadingOf } from "umtool-report-to-video/post-narration"; const made = (o) => ({ temperature: 0.55, top_p: 0.85, top_k: 50, min_p: 0, repeat_penalty: 1.2, takes: 3, ...o }); test("tuningArgvOf: the takes a take recorded are asked again even when they are the code's 3 (the settings' default may differ); a sampler default is not", () => { assert.deepEqual(tuningArgvOf({ tuning: made({}), reading: 0 }), ["--chunk-takes", "3"]); assert.deepEqual(tuningArgvOf({ tuning: made({ takes: 4, top_p: 0.9 }), reading: 2 }), ["--reading", "2", "--top-p", "0.9", "--chunk-takes", "4"]); assert.deepEqual(tuningArgvOf({ engine: "kokoro" }), []); }); test("nextReadingOf: one past the highest reading of THESE words among the synthesized takes; new words read first (0)", () => { const takes = [ { file: "a", script: "One line.", reading: 0 }, { file: "b", script: "One line.", reading: 2 }, { file: "c", script: "One line." }, { file: "d", script: "Other words.", reading: 7 }, { file: "e", engine: "recorded", script: "One line." }, { file: "f", script: "One line.", reading: 9, read: { kind: "thread" } }, ]; assert.equal(nextReadingOf(takes, "One line."), 3); assert.equal(nextReadingOf(takes, "Other words."), 8); assert.equal(nextReadingOf(takes, "Never read."), 0); assert.equal(nextReadingOf([], "x"), 0); });