mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-06 05:33:38 -10:00
Compare commits
1
Commits
main
...
check-fp-39
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37e33d624c |
No files matched your search
@@ -22,7 +22,7 @@ fn a_placeholder_brand_kit_is_flagged() {
|
||||
brand_kit(&["", video.to_str().unwrap()], &mut issues, &mut passed);
|
||||
(issues.iter().map(|i| i.p).collect::<Vec<_>>(), passed.len())
|
||||
};
|
||||
assert_eq!(rules(Some(r#"{"domain":"acme.test","source":{"thin":["no font-family in its CSS"]}}"#)), (vec![1], 0));
|
||||
assert_eq!(rules(Some(r#"{"domain":"acme.test","source":{"thin":["no font-family in its CSS"]}}"#)), (vec![2], 0));
|
||||
assert_eq!(rules(Some(r#"{"domain":"acme.test","source":{"thin":["x"],"by_hand":{"palette.accent":"hero button"}}}"#)), (vec![], 1));
|
||||
assert_eq!(rules(Some(r#"{"domain":"acme.test","source":{"thin":[]}}"#)), (vec![], 1));
|
||||
assert_eq!(rules(None), (vec![2], 0));
|
||||
|
||||
@@ -73,8 +73,10 @@ impl Run {
|
||||
}
|
||||
|
||||
/// The brand kit the cut was styled from (brand/ at or above the manifest's or the video's folder, as render finds
|
||||
/// brand.css): a kit `raea brand` read from a thin fetch that nobody corrected by hand is a placeholder, P1; a brand.css
|
||||
/// with no brand.json beside it wasn't read from the brand at all, P2
|
||||
/// brand.css): a kit `raea brand` read from a thin fetch that nobody corrected by hand is a placeholder, and a brand.css
|
||||
/// with no brand.json beside it wasn't read from the brand at all, both P2: where a kit came from is a note for the person
|
||||
/// at sign-off, not a fault in the cut (12-05, run 39: all four of Body Shop's cuts held an error for a fetch of the
|
||||
/// brand's site that read 40 of its 95 colour and face variables)
|
||||
pub fn brand_kit(near: &[&str], issues: &mut Vec<Issue>, passed: &mut Vec<String>) {
|
||||
let mut seen = std::collections::HashSet::new();
|
||||
for start in near.iter().filter(|p| !p.is_empty()) {
|
||||
@@ -95,7 +97,7 @@ pub fn brand_kit(near: &[&str], issues: &mut Vec<Issue>, passed: &mut Vec<String
|
||||
let thin: Vec<&str> = kit["source"]["thin"].as_array().map(|a| a.iter().filter_map(Value::as_str).collect()).unwrap_or_default();
|
||||
let by_hand = kit["source"]["by_hand"].as_object().is_some_and(|o| !o.is_empty());
|
||||
if !thin.is_empty() && !by_hand {
|
||||
issues.push(Issue { rule: "brand", p: 1, at: None, says: format!("styled from a placeholder kit: raea brand's fetch of {} was thin ({}) and nothing in brand.json's source.by_hand says it was checked; read the live site in a browser and fix the kit (raea guide brand, \"When the fetch was thin\")", kit["domain"].as_str().unwrap_or("the site"), thin.join("; ")) });
|
||||
issues.push(Issue { rule: "brand", p: 2, at: None, says: format!("styled from a placeholder kit: raea brand's fetch of {} was thin ({}) and nothing in brand.json's source.by_hand says it was checked; read the live site in a browser and fix the kit (raea guide brand, \"When the fetch was thin\")", kit["domain"].as_str().unwrap_or("the site"), thin.join("; ")) });
|
||||
} else {
|
||||
passed.push(format!("brand: the cut is styled from {}'s kit{}", kit["domain"].as_str().unwrap_or("the brand"), if by_hand { ", checked by hand" } else { "" }));
|
||||
}
|
||||
|
||||
@@ -64,7 +64,9 @@ export function logo(on: "light" | "dark" = "dark"): string | null {
|
||||
|
||||
/** the caption style every cut takes: the brand's heading font, white with a shadow, the word being said and the key
|
||||
* words in the accent */
|
||||
export const CAPTION = { size: 84, accent: COLORS.accent, color: "var(--brand-text, #fff)" };
|
||||
// white with a yellow lit word, on raea's dark caption plate: never the website's text and accent colours, which are
|
||||
// dark on light (12-05, Dutch's kit: --brand-text and --brand-accent both #000, black words on the black plate)
|
||||
export const CAPTION = { size: 84, accent: "#ffd400", color: "#fff" };
|
||||
|
||||
/** the app's UI zones (its header, buttons, caption and bar), px at this size: the same table raea's check and Region
|
||||
* hold text to (the box image's sdk/video zones.ts), so nothing placed here lands where the check says it can't */
|
||||
|
||||
@@ -73,9 +73,13 @@ function aboveRail(x: Measured): Measured | null {
|
||||
if (!m || +m[1] + +m[2] > RAIL * +m[3]) return x
|
||||
return / more like it/.test(x.says) ? { ...x, level: x.level === "error" ? "warn" : x.level } : null
|
||||
}
|
||||
/** where a cut's brand kit came from is a note for the person, never an error in the cut (12-05, run 39: all four of Body
|
||||
* Shop's cuts held one for a thin fetch of its site; raea from before then calls it P1) */
|
||||
const PROVENANCE = /styled from a placeholder kit/
|
||||
export const faultsOf = (xs: Measured[]) =>
|
||||
xs
|
||||
.filter((x) => !NOT_A_FAULT.some((r) => r.test(x.says)))
|
||||
.map((x) => (x.level === "error" && PROVENANCE.test(x.says) ? { ...x, level: "warn" as const } : x))
|
||||
.map((x) => (x.level === "error" && UNTOLD.test(x.says) ? { ...x, level: "warn" as const } : x))
|
||||
.map(aboveRail)
|
||||
.filter((x): x is Measured => !!x)
|
||||
|
||||
@@ -31,6 +31,22 @@ export const FACE_LIKE = 0.75
|
||||
* 0.9 has lost more than a third and the eyes with it (12-05, run 35: Dutch's speaker at the top edge read 1.05-1.07,
|
||||
* eyes, mouth and chin all in the picture, and was an error) */
|
||||
export const TOP_KEEPS = 0.9
|
||||
/** a face at a side edge is cut when more than this share of its box is past the edge: the reader's box runs past the
|
||||
* face on each side, and the eyes sit about 30% in from each side, so less is a cheek or the box's margin (12-05, run 39:
|
||||
* Body Shop's interviewer at the left edge, 2-5 px of a 65-75 px box past it, both eyes, mouth and chin in the picture,
|
||||
* was an error) */
|
||||
export const SIDE_OUT = 0.15
|
||||
/** a box a reader holds to the frame (flush with the edge, nothing past it): one this narrow for its height has lost more
|
||||
* than SIDE_OUT (the reader's whole faces read 0.62-0.80 wide for their height) */
|
||||
export const SIDE_KEEPS = 0.55
|
||||
/** which side edge cuts a face's box, if one does */
|
||||
export function sideCut(x: number, fw: number, fh: number, w: number): "the left edge" | "the right edge" | null {
|
||||
for (const [by, past, flush] of [["the left edge", -x, x <= 1], ["the right edge", x + fw - w, x + fw >= w - 1]] as const) {
|
||||
if (!flush) continue
|
||||
if (past > 1 ? past / fw > SIDE_OUT : fw / fh < SIDE_KEEPS) return by
|
||||
}
|
||||
return null
|
||||
}
|
||||
/** least font sizes, in pixels of a frame 1080 wide (its shorter side): the Direct Response skill's table */
|
||||
export const TEXT_ERROR = 40
|
||||
export const TEXT_WARN = 48
|
||||
@@ -62,9 +78,10 @@ function cutBy(fr: NonNullable<Faces>, splits: Split[]): { by: string; score: nu
|
||||
const faces = big(fr)
|
||||
for (const [x, y, fw, fh, s] of faces) {
|
||||
const score = Number.isFinite(s) ? s : 1
|
||||
const side = sideCut(x, fw, fh, fr.w)
|
||||
const by =
|
||||
x <= 1 ? "the left edge"
|
||||
: x + fw >= fr.w - 1 ? "the right edge"
|
||||
side ? side
|
||||
: x <= 1 || x + fw >= fr.w - 1 ? null
|
||||
: y <= 1 && fh / fw < TOP_KEEPS ? "the top edge"
|
||||
: y + fh >= fr.h - 1 ? "the bottom edge"
|
||||
: splits.some((sp) => {
|
||||
|
||||
@@ -124,6 +124,12 @@ export function quietBetween(l: Levels, a: number, b: number, under: number): bo
|
||||
return false
|
||||
}
|
||||
|
||||
/** whether any 10 ms of the take between a and b is quiet (under `under`) */
|
||||
export function dipsBetween(l: Levels, a: number, b: number, under: number): boolean {
|
||||
for (let t = a; t <= b + 1e-9; t += 0.01) if (at(l, t) <= under) return true
|
||||
return false
|
||||
}
|
||||
|
||||
/** the longest a spoken word runs (s): a drawn-out "sooo" is under it */
|
||||
export const WORD_MAX = 2.5
|
||||
|
||||
@@ -173,7 +179,17 @@ export function editPoints(c: Clip, fps: number, words: Word[], l: Levels): Find
|
||||
for (const [edge, t, cutAt, inside] of [["in", tin, c.from / fps, 1], ["out", tout, c.to / fps, -1]] as const) {
|
||||
const where = `the ${edge === "in" ? "start" : "end"} of the clip at ${secs(cutAt)} (${name} ${secs(t)})`
|
||||
// speech that runs on with no pause still has its boundaries between words: a cut on one is tight, not a cut word
|
||||
const seam = seams(words).find((x) => Math.abs(x.at - t) <= SEAM)
|
||||
// and so are two words the take runs straight on between, whatever gap the transcript times there (12-05, run 39:
|
||||
// "Everyone" 16.40-16.88 s and "is" from 16.96, never under -24 dB between them where quiet is -30, and an in point at
|
||||
// 16.90 was called "Everyone"'s first sound cut)
|
||||
// the two neighbouring words with the cut between them (none when it's inside a word)
|
||||
const ni = words.findIndex((w) => w.start >= t - 1e-9)
|
||||
const next = ni > 0 ? words[ni] : undefined
|
||||
const prev = next && words[ni - 1].end <= t + 1e-9 ? words[ni - 1] : undefined
|
||||
// (where the take dips to quiet at all between them there was a place to cut: 59.53 s in run 39's Dutch, 30 ms past a
|
||||
// dip to -32 dB, on "I" at -9, stays a cut word)
|
||||
const runOn = prev && next && next.start - prev.end <= NEAR && !dipsBetween(l, prev.end, next.start, quietUnder(l, ref)) ? { at: t, before: prev.text, after: next.text } : undefined
|
||||
const seam = seams(words).find((x) => Math.abs(x.at - t) <= SEAM) ?? runOn
|
||||
if (seam) {
|
||||
const here = edge === "in" ? peak(l, t, t + 0.01) : peak(l, t - 0.01, t)
|
||||
if (here >= ref - ON_SOUND)
|
||||
@@ -205,15 +221,20 @@ export function editPoints(c: Clip, fps: number, words: Word[], l: Levels): Find
|
||||
const off = near ? Math.min(Math.abs(near.start - t), Math.abs(near.end - t)) : Infinity
|
||||
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}` })
|
||||
// the word is whole when the take falls quiet between it and the cut, on either side of 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; run 39: "it." ended at 22.94 s, quiet to 23.01, and an in point
|
||||
// at 23.03 on the next sound was called "it."'s first sound cut): what's cut is another sound, for the ear
|
||||
const inClip = near && (edge === "out" ? near.end <= t : near.start >= t)
|
||||
const beyond = near && (edge === "out" ? near.start >= t : near.end <= t)
|
||||
const span: [number, number] | null = !near ? null : inClip ? (edge === "out" ? [near.end, t] : [t, near.start]) : beyond ? (edge === "out" ? [t, near.start] : [near.end, t]) : null
|
||||
if (near && span && quietBetween(l, span[0], span[1], quietUnder(l, ref))) {
|
||||
out.push({ level: "warn", kind: "edit-on-sound", at: cutAt, says: `${under}, with a pause between it and “${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}` })
|
||||
// a word beyond the cut that runs into it: a sliver of it is heard in the clip
|
||||
const what = near && beyond ? `a sliver of “${near.text}” is heard as the clip ${edge === "in" ? "starts" : "ends"}` : `the word's ${edge === "in" ? "first sound" : "tail"} is cut`
|
||||
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}”` : ""}: ${what}. ${Move}` })
|
||||
}
|
||||
}
|
||||
return out
|
||||
|
||||
@@ -69,3 +69,8 @@ test("text at the right edge above the app's buttons isn't in its UI zone; below
|
||||
const top = { level: "error" as const, says: "“Hook” sits in the app's UI zone at the top (keep 220 px clear): its letters 86,150 908x196 in 1080x1920" }
|
||||
expect(faultsOf([top])).toEqual([top])
|
||||
})
|
||||
|
||||
test("where a cut's brand kit came from is a warning for the person, never an error in the cut (12-05, run 39 Body Shop)", () => {
|
||||
const kit = { level: "error" as const, says: "styled from a placeholder kit: raea brand's fetch of acme.test was thin (55 of the 95 variables its colours and faces use are set by script, not in its CSS)" }
|
||||
expect(faultsOf([kit])).toEqual([{ ...kit, level: "warn" }])
|
||||
})
|
||||
@@ -20,7 +20,7 @@ test("the frames pack's measures", () => {
|
||||
const guest = [260, 300, 110, 130, 0.95]
|
||||
f = cutFaces([fr([[0, 598, 41, 82, 0.79], guest]), fr([[0, 594, 40, 84, 0.65], guest]), fr([guest])])
|
||||
assert.deepEqual(f.map((x) => x.level), ["warn"])
|
||||
f = cutFaces([fr([[0, 280, 100, 128, 0.74], guest]), fr([[0, 282, 98, 127, 0.61], guest]), fr([guest])])
|
||||
f = cutFaces([fr([[-40, 280, 100, 128, 0.74], guest]), fr([[-40, 282, 98, 127, 0.61], guest]), fr([guest])])
|
||||
assert.deepEqual(f.map((x) => [x.level, x.at, x.until]), [["error", 0, 1]])
|
||||
assert.doesNotMatch(f[0].says, /sure/)
|
||||
// a split screen: a lone line held; a caption's box (two lines close together) isn't one
|
||||
@@ -72,3 +72,19 @@ test("a face at the top edge that lost only its forehead isn't cut; one that los
|
||||
const eyes = cutFaces([fr([[218.5, 0.1, 104.1, 60, 0.941]]), fr([[149, 0.4, 99.9, 58, 0.941]]), fr([[150, 0.2, 100, 61, 0.94]])])
|
||||
assert.ok(eyes.some((f) => f.level === "error" && f.says.includes("top edge")), JSON.stringify(eyes))
|
||||
})
|
||||
|
||||
test("a face at a side edge is cut when more than 15% of its box is past it; its box's margin and a cheek aren't (12-05, run 39 Body Shop)", () => {
|
||||
const fr = (faces: number[][]) => ({ w: 540, h: 960, faces, seams: [] as [string, number, number][] })
|
||||
const guest = [243, 308, 89, 122, 0.9]
|
||||
// the reader's own boxes for the interviewer at 9.0-10.0 s: 2-5 px of a 72-75 px box past the left edge
|
||||
const margin = [[-4.6, 304, 74.5, 105.4, 0.92], [-4.3, 312, 74, 101.4, 0.92], [9.5, 304, 72.8, 107.4, 0.91]]
|
||||
assert.deepEqual(cutFaces(margin.map((m) => fr([m, guest]))), [])
|
||||
// the same face a third past the edge, and one past the right edge: cut
|
||||
const third = cutFaces([0, 1, 2].map(() => fr([[-25, 304, 74, 105, 0.92], guest])))
|
||||
assert.deepEqual(third.map((x) => [x.level, x.says.includes("left edge")]), [["error", true]])
|
||||
const right = cutFaces([0, 1, 2].map(() => fr([[500, 304, 74, 105, 0.92], guest])))
|
||||
assert.ok(right.length === 1 && right[0].says.includes("right edge"), JSON.stringify(right))
|
||||
// a reader that holds its box to the frame: a whole face's width for its height touches it, a narrow one is cut
|
||||
assert.deepEqual(cutFaces([0, 1, 2].map(() => fr([[0, 304, 74, 105, 0.92], guest]))), [])
|
||||
assert.equal(cutFaces([0, 1, 2].map(() => fr([[0, 304, 40, 105, 0.92], guest])))[0]?.level, "error")
|
||||
})
|
||||
@@ -52,13 +52,34 @@ test("the sound pack's measures", async () => {
|
||||
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/)
|
||||
assert.match(whole[0].says, /with a pause between it and “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")
|
||||
|
||||
// 12-05, run 39: an in point 230 ms after "next" ends, past a pause, 30 ms into a sound the transcript missed: "next" is
|
||||
// whole, a warning (Dutch's 23.03 s, called "it."'s first sound cut)
|
||||
const missed: number[] = db.map((x, i) => (i >= 300 && i < 340 ? -22 : x))
|
||||
const fresh = editPoints(clip(3.03, 0.6), fps, words, { start: 0, db: missed })
|
||||
assert.deepEqual(fresh.map((x) => x.level), ["warn"], JSON.stringify(fresh))
|
||||
assert.match(fresh[0].says, /with a pause between it and “next”: the word is whole/)
|
||||
// two words the take runs straight on between (never quiet), 80 ms apart in the transcript: a cut between them is tight,
|
||||
// a warning (Body Shop's "Everyone" / "is" at 16.90 s); where the take dips to quiet between them and the cut lands past
|
||||
// the dip on the next word's sound, the word's first sound is cut, an error (Dutch's "if" / "I" at 59.53 s)
|
||||
const pair = [{ text: "every", start: 1.0, end: 1.48 }, { text: "is", start: 1.56, end: 1.8 }]
|
||||
const runs: number[] = []
|
||||
for (let t = 0; t < 4; t += 0.01) runs.push(t >= 0.995 && t <= 1.805 ? (t > 1.475 && t < 1.555 ? -26 : -20) : -50)
|
||||
const tightCut = editPoints(clip(1.5, 0.6), fps, pair, { start: 0, db: runs })
|
||||
assert.deepEqual(tightCut.map((x) => x.level), ["warn"], JSON.stringify(tightCut))
|
||||
assert.match(tightCut[0].says, /between “every” and “is” with no pause: a tight cut/)
|
||||
const dipped = runs.map((x, i) => (i >= 149 && i <= 150 ? -45 : i >= 151 && i < 156 ? -20 : x))
|
||||
const onIs = editPoints(clip(1.53, 0.6), fps, pair, { start: 0, db: dipped })
|
||||
assert.deepEqual(onIs.map((x) => x.level), ["error"], JSON.stringify(onIs))
|
||||
assert.match(onIs[0].says, /“is”: the word's first sound is cut/)
|
||||
ok("a cut past a pause before an unheard sound is a warning; between words that run on, tight; past a dip, on the next word, 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[] = []
|
||||
|
||||
@@ -113,7 +113,10 @@ function CaptionLine({ g, saying, px, accent, style, className, children }: { g:
|
||||
fontWeight: 800,
|
||||
fontSize: px,
|
||||
lineHeight: 1.05,
|
||||
color: "var(--brand-text, #fff)",
|
||||
// white on the plate, never the brand's text colour: a website's text is dark on light, and 12-05's Dutch kit
|
||||
// (--brand-text #000) put black words on the black plate. The render manifest records this colour, so it's
|
||||
// the one the contrast check measures; a brand's `style` restyles it
|
||||
color: "#fff",
|
||||
// a dark plate under the line: the words hold 3:1 over a white wall, a sky or a lit window. A shadow alone
|
||||
// darkened only the letters' edges, and 12-05's street cuts read 2.4-2.9:1 over bright walls. The brand's
|
||||
// `style` restyles it (its colour, or a darker one); 60% black keeps white 5.7:1 and the accent yellow 4:1
|
||||
@@ -129,7 +132,7 @@ function CaptionLine({ g, saying, px, accent, style, className, children }: { g:
|
||||
{children
|
||||
? children(g, saying)
|
||||
: g.map((w, j) => (
|
||||
<span key={j} style={accent && j === saying ? { color: "var(--brand-accent, #ffd400)" } : undefined}>
|
||||
<span key={j} style={accent && j === saying ? { color: "#ffd400" } : undefined}>
|
||||
{w.text + (j < g.length - 1 ? " " : "")}
|
||||
</span>
|
||||
))}
|
||||
|
||||
Reference in new issue
Block a user