diff --git a/sdk/goal/src/packs/sound.ts b/sdk/goal/src/packs/sound.ts index c5ffd0eb..e151d709 100644 --- a/sdk/goal/src/packs/sound.ts +++ b/sdk/goal/src/packs/sound.ts @@ -102,6 +102,9 @@ export function nearestGap(l: Levels, t: number, ref: number, words: Word[], ins return null } +/** the longest a spoken word runs (s): a drawn-out "sooo" is under it */ +export const WORD_MAX = 2.5 + /** how close (s) a cut is to a boundary between two words that run together to count as on it (word timings are good * to about 30 ms) */ const SEAM = 0.03 @@ -134,7 +137,9 @@ export function editPoints(c: Clip, fps: number, words: Word[], l: Levels): Find out.push({ level: "warn", kind: "edit-on-sound", at: cutAt, says: `${where} is between “${seam.before}” and “${seam.after}” with no pause: a tight cut. Look at it on the waveform, or move it to a pause if one is near` }) continue } - const word = words.find((w) => w.start + 0.02 < t && w.end - 0.02 > t) + // a "word" longer than WORD_MAX is a transcriber's timing gone wrong, not a word (12-04, Elfster run 5: "secret" + // timed 143.28-166.96 s, and a cut 15 s into it was called a word cut in two): the sound there is read instead + const word = words.find((w) => w.start + 0.02 < t && w.end - 0.02 > t && w.end - w.start <= WORD_MAX) const gap = nearestGap(l, t, ref, words, inside, inside === 1 ? tout - 0.1 : tin + 0.1) const ms = (x: number) => `${x >= t ? "+" : ""}${Math.round((x - t) * 1000)} ms` const bound = gap === null ? seams(words).filter((x) => Math.abs(x.at - t) <= NEAR && (inside === 1 ? x.at < tout - 0.1 : x.at > tin + 0.1)).sort((p, q) => Math.abs(p.at - t) - Math.abs(q.at - t))[0] : undefined diff --git a/sdk/goal/test/sound.test.ts b/sdk/goal/test/sound.test.ts index ffe26d6f..73ee944e 100644 --- a/sdk/goal/test/sound.test.ts +++ b/sdk/goal/test/sound.test.ts @@ -97,3 +97,13 @@ test("a voice clip, or a take named only by a farm cache's hash, that isn't here assert.deepEqual(findings.map((x) => [x.level, x.at]), [["error", 0], ["warn", 0], ["error", 1]]) assert.match(findings[0].says, /^a take named only by its hash isn't on this machine/) }) + +test("a word timed longer than a word runs is no word to cut in two (12-04, Elfster run 5: \"secret\" over 23.7 s)", () => { + const words = [{ text: "secret", start: 1.0, end: 24.7 }] + const db: number[] = [] + for (let t = 0; t < 30; t += 0.01) db.push(-50) + const take: Levels = { start: 0, db } + const clip: Clip = { key: "n1", from: 150, to: 300, src: "/w/work/media/raw/take.mov", at: 5, gainDb: 0, bus: "voice" } + // a cut 4 s into the stretch, on quiet: nothing to say about a word + assert.equal(editPoints(clip, 30, words, take).filter((f) => f.kind === "edit-in-word").length, 0) +})