From f75335d6d1363cdbd7801fcdd35fa3fc74cf41e4 Mon Sep 17 00:00:00 2001 From: shane Date: Sat, 5 Dec 2026 22:05:36 -0800 Subject: [PATCH] Check: a cut past a pause after a whole word isn't the word's tail cut (#358) The sound pack called any sound at a clip edge within 0.6 s of a word that word's tail or first sound cut, an error. In Dutch run 38 an out point at 8.37 s came 70 ms after "$149." ended: the take fell to its floor for 50 ms, then a sound the transcript missed started, and the cut took 20 ms of it. The word was whole. A clip edge with 30 ms of quiet between it and the word inside the clip is now a warning that names what's cut (a breath, a noise or a missed word), with the same gap to move to. A sound that runs on from the word to the cut is still the word's, an error. Co-authored-by: shinyobjectz --- sdk/goal/src/packs/sound.ts | 24 +++++++++++++++++++++++- sdk/goal/test/sound.test.ts | 12 ++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/sdk/goal/src/packs/sound.ts b/sdk/goal/src/packs/sound.ts index 54239162..1835840c 100644 --- a/sdk/goal/src/packs/sound.ts +++ b/sdk/goal/src/packs/sound.ts @@ -31,6 +31,8 @@ const FLOOR_Q = 0.1 const NEAR = 0.4 /** sound this close to a word (s) at a cut is the word's, cut; further off it's another sound */ const WORD_NEAR = 0.6 +/** a quiet this long (s) between a word and a cut means the word is whole: the sound at the cut is another one */ +const APART = 0.03 /** lines this far apart (dB) are an error, a warning */ const LEVEL_ERROR = 6 const LEVEL_WARN = 4 @@ -112,6 +114,16 @@ export function nearestGap(l: Levels, t: number, ref: number, words: Word[], ins return null } +/** whether the take falls quiet (under `under`) for APART in a row between a and b */ +export function quietBetween(l: Levels, a: number, b: number, under: number): boolean { + let run = 0 + for (let t = a; t <= b + 1e-9; t += 0.01) { + run = at(l, t) <= under ? run + 0.01 : 0 + if (run >= APART - 1e-9) return true + } + return false +} + /** the longest a spoken word runs (s): a drawn-out "sooo" is under it */ export const WORD_MAX = 2.5 @@ -191,7 +203,17 @@ export function editPoints(c: Clip, fps: number, words: Word[], l: Levels): Find // sound with no word near it isn't a word cut (12-05, run 12: a cut "5397 ms from" the nearest word was an // error): a laugh, a noise, or speech the transcript missed, for the ear: a warning const off = near ? Math.min(Math.abs(near.start - t), Math.abs(near.end - t)) : Infinity - out.push({ level: off <= WORD_NEAR ? "error" : "warn", kind: "edit-on-sound", at: cutAt, says: `${where} lands on sound ${Math.max(0, ref - here).toFixed(0)} dB under the speech${near ? `, ${Math.round(Math.min(Math.abs(near.start - t), Math.abs(near.end - t)) * 1000)} ms from “${near.text}”` : ""}: the word's ${edge === "in" ? "first sound" : "tail"} is cut. ${move[0].toUpperCase()}${move.slice(1)}` }) + const under = `${where} lands on sound ${Math.max(0, ref - here).toFixed(0)} dB under the speech` + const Move = `${move[0].toUpperCase()}${move.slice(1)}` + // the word inside the clip is whole when the take falls quiet between it and the cut (12-05, Dutch run 38: "$149." + // ended at 8.30 s, the street fell to its floor for 50 ms, and an out point at 8.37 s, 20 ms into a sound the + // transcript missed, was called the word's tail cut): what's cut is another sound, for the ear + const whole = near && (edge === "out" ? near.end <= t && quietBetween(l, near.end, t, quietUnder(l, ref)) : near.start >= t && quietBetween(l, t, near.start, quietUnder(l, ref))) + if (near && whole) { + out.push({ level: "warn", kind: "edit-on-sound", at: cutAt, says: `${under}, ${edge === "out" ? "past the pause after" : "ahead of the pause before"} “${near.text}”: the word is whole, and what's cut is a breath, a noise or a word the transcript missed. ${Move}` }) + continue + } + out.push({ level: off <= WORD_NEAR ? "error" : "warn", kind: "edit-on-sound", at: cutAt, says: `${under}${near ? `, ${Math.round(off * 1000)} ms from “${near.text}”` : ""}: the word's ${edge === "in" ? "first sound" : "tail"} is cut. ${Move}` }) } } return out diff --git a/sdk/goal/test/sound.test.ts b/sdk/goal/test/sound.test.ts index 10ba1de2..c7096eb2 100644 --- a/sdk/goal/test/sound.test.ts +++ b/sdk/goal/test/sound.test.ts @@ -47,6 +47,18 @@ test("the sound pack's measures", async () => { assert.ok(away.length >= 1 && away.every((x) => x.level === "warn"), JSON.stringify(away)) ok("a cut on a sound far from any word is a warning, not a word cut") + // an out point 70 ms after "next" ends, past 50 ms of street, 20 ms into a sound the transcript missed: the word is + // whole (12-05, Dutch run 38, "$149." at 8.30 s and a cut at 8.37 s); the same cut where "next" runs on to it is a tail cut + const after: number[] = db.map((x, i) => (i >= 285 && i < 300 ? -24 : x)) + const whole = editPoints(clip(1.95, 0.92), fps, words, { start: 0, db: after }) + assert.deepEqual(whole.map((x) => x.level), ["warn"], JSON.stringify(whole)) + assert.match(whole[0].says, /past the pause after “next”: the word is whole/) + const runsOn: number[] = db.map((x, i) => (i >= 280 && i < 300 ? -24 : x)) + const tail = editPoints(clip(1.95, 0.92), fps, words, { start: 0, db: runsOn }) + assert.deepEqual(tail.map((x) => x.level), ["error"], JSON.stringify(tail)) + assert.match(tail[0].says, /the word's tail is cut/) + ok("a cut on a sound past a pause after a whole word is a warning; on the word's own tail, an error") + // "loud" and "next" run together with no pause: a cut on their boundary is tight (a warning), not a cut word const run = [{ text: "say", start: 1.0, end: 1.4 }, { text: "so", start: 1.42, end: 1.7 }, { text: "then", start: 1.72, end: 2.0 }] const runDb: number[] = []