// A READ's Orpheus tuning and reading as umtool's words (lane orpheus-tuning): the flags `umtool posts narrate
// - --take` takes for them, and the flags that ask a take's own again -- what a re-read keeps, as it keeps a
// take's own --speed. The ranges and the defaults are the editor's (yt-dlp-transcript-common/lib/ttsTuning.mjs).
//
// Plain ESM, pure.
import { normalizeTtsTuning } from "yt-dlp-transcript-common/lib/ttsTuning.mjs";
/** The flags that make a read's tuning, and the tuning field each sets. */
export const TUNING_FLAGS = Object.freeze({
"--temperature": "temperature", "--top-p": "top_p", "--top-k": "top_k", "--min-p": "min_p", "--repeat-penalty": "repeat_penalty", "--chunk-takes": "takes",
});
/**
* The flags that ask a take's tuning and reading again: `--reading N` when it was not the first reading, a flag for
* each sampler value that is not Orpheus's default, and the takes it recorded ALWAYS (`--chunk-takes`: the settings'
* default may differ from the code's 3, and the editor drops a value equal to its settings' own -- the same key).
* `[]` for a take that records neither (another engine, an older take).
*/
export function tuningArgvOf(take) {
const a = [];
if (Number.isInteger(take?.reading) && take.reading > 0) a.push("--reading", String(take.reading));
const off = normalizeTtsTuning(take?.tuning);
for (const [flag, field] of Object.entries(TUNING_FLAGS)) if (off[field] !== undefined) a.push(flag, String(off[field]));
return a;
}