Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

raea words: a dip in a word counts as a crossfade only when it comes back up inside the word (Whisper's spans take in the quiet after a word, so a sentence trailing off was flagged on raea-2's first real take); Whisper's joined words ("for $60") split before comparing; edge words flagged only when the sound is at speech level on the first or last 30 ms. Checked on raea-2 (box updated) and on the finished Dutch cut (passes, one warning), the crossfaded and mid-word cuts (still fail).

shinyobjectzab6312065399
diff --git a/sdk/cloud/server/words.ts b/sdk/cloud/server/words.ts
index b55ac4ff..ea42a6db 100644
--- a/sdk/cloud/server/words.ts
+++ b/sdk/cloud/server/words.ts
@@ -113,13 +113,22 @@ export function fades(db: number[], heard: Word[], seconds: number): Finding[] {
const w = heard[n]
const a = Math.floor(w.start * 100)
const b = Math.min(db.length, Math.ceil(w.end * 100))
+ // a dip that comes back up inside the word: a fade out and in across a join. One that runs on to the word's end is
+ // the word trailing off (Whisper's spans take in the quiet after a word), not a fade
let run = 0
+ let deepest = 0
for (let f = a; f < b; f++) {
- run = quiet(f) ? run + 1 : 0
- if (run === 12 && f / 100 - lastAt > 1) {
+ if (quiet(f)) {
+ run++
+ deepest = Math.max(deepest, median - db[f])
+ continue
+ }
+ if (run >= 12 && db[f] > median - 8 && f / 100 - lastAt > 1) {
lastAt = f / 100
- out.push({ level: "warn", kind: "faded", at: (f - 11) / 100, says: `"${w.text}" at ${w.start.toFixed(2)} s dips ${(median - db[f]).toFixed(0)} dB under the speech for ${run * 10}+ ms: a crossfade or fade over speech? Dialogue joins are hard cuts in the gap between words, with fades of 20 ms at most` })
+ out.push({ level: "warn", kind: "faded", at: (f - run) / 100, says: `"${w.text}" at ${w.start.toFixed(2)} s dips ${deepest.toFixed(0)} dB under the speech for ${run * 10} ms and comes back: a crossfade or fade over speech? Dialogue joins are hard cuts in the gap between words, with fades of 20 ms at most` })
}
+ run = 0
+ deepest = 0
}
}
const first = heard[0]
diff --git a/sdk/cloud/test/words.ts b/sdk/cloud/test/words.ts
index 5cfe1785..6643ed49 100644
--- a/sdk/cloud/test/words.ts
+++ b/sdk/cloud/test/words.ts
@@ -16,6 +16,7 @@ const db = Array.from({ length: 200 }, (_, i) => (i >= 40 && i < 70 ? -40 : -20)
const hw = [w("So", 0.1, 0.3), w("hurt", 0.35, 0.8), w("his", 0.8, 1.2), w("paw", 1.2, 1.9)]
ok(fades(db, hw, 2).some((x) => x.kind === "faded"), "a crossfade dip inside a word is found")
ok(!fades(Array(200).fill(-20), hw, 2).some((x) => x.kind === "faded"), "even speech has no dip")
+ok(!fades(Array.from({ length: 200 }, (_, i) => (i >= 60 && i < 80 ? -40 : -20)), hw, 2).some((x) => x.kind === "faded"), "a word trailing off to its end is not a fade")
ok(fades(Array(200).fill(-20), [w("Hi", 0.0, 0.3), ...hw.slice(1)], 2).some((x) => x.kind === "edge"), "a word on the first frame is flagged when the sound is loud there")
ok(!fades([-60, -60, -60, ...Array(197).fill(-20)], [w("Hi", 0.0, 0.3), ...hw.slice(1)], 2).some((x) => x.kind === "edge"), "Whisper putting a word at 0 over silence is not")
ok(split([w("for $60", 1, 2)]).map((x) => x.text).join("|") === "for|$60", "two words handed back as one are split")