Spaces:
Running
Running
Replace SED video with interactive canvas explainer
Browse filesFiles changed (3)
- index.html+14-4
- sed_pipeline_explainer.cssAdded+88
- sed_pipeline_explainer.jsAdded+671
3 unmodified lines456789373 unmodified lines38338438538638738838939039139296 unmodified lines4894904914924933 unmodified lines<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>How Granary-HiFi Turns Wild Speech Into a High-Fidelity Resource for European Languages</title><style>@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');373 unmodified lines<p><strong>Problem:</strong> Web audio is noisy. Music beds, applause, traffic, keyboard clicks, and other non-speech events are common.</p><p><strong>Solution:</strong> A sound-event detection model annotates each segment with the presence and type of background events. Segments with persistent non-speech interference are flagged or excluded.</p><p><strong>Why it matters:</strong> A high-fidelity subset cannot leave music, applause, and other non-speech in the recording and expect every later user to ignore them.</p><video class="stage-video" controls preload="metadata" playsinline><source src="sed_pipeline_explainer.mp4" type="video/mp4">Your browser does not support embedded MP4 video.</video></div><div class="stage-section" id="stage-3">96 unmodified linesGranary-HiFi was developed by researchers at NVIDIA to support reproducible research on multilingual speech.</p></body></html>3 unmodified lines45678910373 unmodified lines38438538638738838939039139239339439539639739839940040196 unmodified lines4984995005015025033 unmodified lines<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>How Granary-HiFi Turns Wild Speech Into a High-Fidelity Resource for European Languages</title><link rel="stylesheet" href="sed_pipeline_explainer.css"><style>@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');373 unmodified lines<p><strong>Problem:</strong> Web audio is noisy. Music beds, applause, traffic, keyboard clicks, and other non-speech events are common.</p><p><strong>Solution:</strong> A sound-event detection model annotates each segment with the presence and type of background events. Segments with persistent non-speech interference are flagged or excluded.</p><p><strong>Why it matters:</strong> A high-fidelity subset cannot leave music, applause, and other non-speech in the recording and expect every later user to ignore them.</p><div class="sed-explainer" data-sed-explainer><div class="sed-explainer__viewport"><canvas role="img" aria-label="Animated explanation of the sound event detection pipeline, from an audio waveform through log-mel features and class probabilities to clean speech segments."></canvas></div><div class="sed-explainer__controls"><button class="sed-explainer__button" data-action="play" type="button" aria-label="Play SED animation">Play</button><button class="sed-explainer__button" data-action="restart" type="button">Restart</button><input class="sed-explainer__timeline" type="range" min="0" max="48" step="0.05" value="0" aria-label="SED animation timeline"><span class="sed-explainer__time">0:00 / 0:48</span></div><p class="sed-explainer__fallback">Audio waveform → log-mel features → framewise class probabilities → speech events → GBT → selected clean speech.</p></div></div><div class="stage-section" id="stage-3">96 unmodified linesGranary-HiFi was developed by researchers at NVIDIA to support reproducible research on multilingual speech.</p><script src="sed_pipeline_explainer.js"></script></body></html>
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788.sed-explainer { --sed-green: #76b900; --sed-panel: #111111; --sed-muted: #b3b3b3; width: 100%; margin-top: 18px; overflow: hidden; border: 1px solid #2f2f2f; border-radius: 10px; background: #000; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2); color: #fff; font-family: "NVIDIA Sans", Inter, Arial, sans-serif;}
.sed-explainer__viewport { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 260px; background: #000;}
.sed-explainer canvas { display: block; width: 100%; height: 100%;}
.sed-explainer__controls { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 7px 10px; border-top: 1px solid #282828; background: #0b0b0b;}
.sed-explainer__button { min-width: 68px; padding: 6px 10px; border: 1px solid #4b4b4b; border-radius: 5px; background: #181818; color: #fff; font: 600 12px/1 "NVIDIA Sans", Inter, Arial, sans-serif; cursor: pointer;}
.sed-explainer__button:hover,.sed-explainer__button:focus-visible { border-color: var(--sed-green); outline: none;}
.sed-explainer__timeline { flex: 1; accent-color: var(--sed-green); cursor: pointer;}
.sed-explainer__time { min-width: 76px; color: var(--sed-muted); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums;}
.sed-explainer__fallback { margin: 0; padding: 10px 14px; color: var(--sed-muted); background: #000; font-size: 12px;}
@media (max-width: 640px) { .sed-explainer__viewport { min-height: 210px; } .sed-explainer__controls { gap: 6px; } .sed-explainer__button { min-width: 60px; padding-inline: 7px; } .sed-explainer__time { min-width: 62px; }}
@media (prefers-reduced-motion: reduce) { .sed-explainer__button[data-action="play"] { display: none; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671(function () { "use strict";
const DURATION = 48; const W = 1600; const H = 900; const C = { bg: "#000000", panel: "#111111", grid: "#343434", muted: "#b3b3b3", white: "#ffffff", green: "#76b900", cyan: "#42d3ff", teal: "#4de2c5", gold: "#ffd166", coral: "#ff6b6b", blue: "#4f8cff", purple: "#b9a7ff", orange: "#ff9f43", }; const CHANNELS = [ ["Speech", C.teal], ["Male", C.blue], ["Female", C.purple], ["Child", C.green], ["Conversation", C.orange], ["Narration", C.gold], ["Synthesizer", C.cyan], ]; const EVENTS = [ [0.86, 2.68, C.cyan], [3.12, 5.28, C.teal], [6.04, 6.68, C.gold], ];
const clamp = (v, a = 0, b = 1) => Math.max(a, Math.min(b, v)); const smooth = (v) => { v = clamp(v); return v * v * (3 - 2 * v); }; const phase = (t, a, b) => smooth((t - a) / (b - a)); const lerp = (a, b, t) => a + (b - a) * t; const gauss = (x, m, s) => Math.exp(-Math.pow((x - m) / s, 2));
function waveform(t) { const e = 0.05 + 0.82 * gauss(t, 1.65, 0.68) + 0.66 * gauss(t, 4.15, 1.10) + 0.30 * gauss(t, 6.35, 0.36); return e * (0.57 * Math.sin(2 * Math.PI * 4.2 * t) + 0.27 * Math.sin(2 * Math.PI * 9.1 * t) + 0.11 * Math.sin(2 * Math.PI * 15.4 * t)); }
function speechProb(t) { return clamp(0.035 + 0.80 * gauss(t, 1.68, 0.72) + 0.72 * gauss(t, 4.18, 1.12) + 0.48 * gauss(t, 6.34, 0.34)); }
function channelProb(index, t) { if (index === 0) return clamp(0.025 + 0.62 * gauss(t, 1.65, 0.74) + 0.55 * gauss(t, 4.15, 1.14) + 0.30 * gauss(t, 6.35, 0.37)); const center = 0.65 + index * 0.82; const base = 0.025 + (0.055 + index * 0.014) * gauss(t, center, 0.48); const texture = 0.018 * (1 + Math.sin(t * (2.0 + index * 0.3) + index)); const eventEnergy = (index === 1 || index === 5) ? 0.14 * gauss(t, 6.35, 0.30) : 0; return clamp(base + texture + eventEnergy, 0.01, 0.64); }
function font(size, weight = 400) { return `${weight} ${size}px "NVIDIA Sans", Inter, Arial, sans-serif`; }
function text(ctx, value, x, y, size, color = C.white, align = "center", weight = 400) { ctx.save(); ctx.font = font(size, weight); ctx.fillStyle = color; ctx.textAlign = align; ctx.textBaseline = "middle"; ctx.fillText(value, x, y); ctx.restore(); }
function roundedRect(ctx, x, y, w, h, r, fill, stroke, lineWidth = 1) { ctx.beginPath(); ctx.roundRect(x, y, w, h, r); if (fill) { ctx.fillStyle = fill; ctx.fill(); } if (stroke) { ctx.strokeStyle = stroke; ctx.lineWidth = lineWidth; ctx.stroke(); } }
function pill(ctx, value, x, y, color, size = 20, width) { ctx.save(); ctx.font = font(size, 700); const w = width || ctx.measureText(value).width + 30; ctx.globalAlpha = 0.95; roundedRect(ctx, x - w / 2, y - 18, w, 36, 10, "#101010", color, 1.5); text(ctx, value, x, y + 1, size, color, "center", 700); ctx.restore(); }
function heading(ctx, eyebrow, title, alpha = 1) { ctx.save(); ctx.globalAlpha = alpha; text(ctx, eyebrow, W / 2, 45, 19, C.white, "center", 700); text(ctx, title, W / 2, 91, 42, C.green, "center", 700); ctx.restore(); }
function plotRect() { return { x: 125, y: 155, w: 1350, h: 545 }; }
function drawAxes(ctx, probability = false, alpha = 1) { const r = plotRect(); ctx.save(); ctx.globalAlpha = alpha; ctx.strokeStyle = C.grid; ctx.lineWidth = 1; for (let i = 0; i <= 8; i++) { const x = r.x + (i / 8) * r.w; ctx.beginPath(); ctx.moveTo(x, r.y); ctx.lineTo(x, r.y + r.h); ctx.stroke(); text(ctx, `${i} s`, x, r.y + r.h + 26, 15, C.muted); } const lines = probability ? 4 : 2; for (let i = 0; i <= lines; i++) { const y = r.y + (i / lines) * r.h; ctx.beginPath(); ctx.moveTo(r.x, y); ctx.lineTo(r.x + r.w, y); ctx.stroke(); } if (probability) { text(ctx, "1.0", r.x - 24, r.y, 14, C.muted, "right"); text(ctx, "0.5", r.x - 24, r.y + r.h / 2, 14, C.muted, "right"); text(ctx, "0", r.x - 24, r.y + r.h, 14, C.muted, "right"); } ctx.restore(); }
function drawWave(ctx, color = C.cyan, alpha = 1, ranges) { const r = plotRect(); ctx.save(); ctx.strokeStyle = color; ctx.globalAlpha = alpha; ctx.lineWidth = 3; ctx.shadowColor = color; ctx.shadowBlur = 10; ctx.beginPath(); let started = false; for (let i = 0; i <= 700; i++) { const t = 8 * i / 700; const visible = !ranges || ranges.some(([a, b]) => t >= a && t <= b); if (!visible) { started = false; continue; } const x = r.x + r.w * t / 8; const y = r.y + r.h / 2 - waveform(t) * r.h * 0.42; if (!started) ctx.moveTo(x, y); else ctx.lineTo(x, y); started = true; } ctx.stroke(); ctx.restore(); }
function drawLegend(ctx, alpha = 1) { const y = 854; const totalW = 1030; const start = (W - totalW) / 2; ctx.save(); ctx.globalAlpha = alpha; roundedRect(ctx, start - 24, y - 25, totalW + 48, 48, 12, "#111111ee", "#333333"); CHANNELS.forEach(([name, color], i) => { const x = start + i * (totalW / CHANNELS.length); ctx.strokeStyle = color; ctx.lineWidth = 7; ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x + 28, y); ctx.stroke(); text(ctx, name, x + 39, y, 15, C.white, "left", 600); }); ctx.restore(); }
function drawMel(ctx, amount, alpha = 1) { const r = plotRect(); const rows = 16; const cols = 58; ctx.save(); ctx.globalAlpha = alpha; for (let row = 0; row < rows; row++) { for (let col = 0; col < cols; col++) { const t = 8 * col / (cols - 1); const energy = 0.08 + 0.78 * gauss(t, 1.65, 0.76) + 0.62 * gauss(t, 4.15, 1.18) + 0.23 * gauss(t, 6.35, 0.40); const texture = 0.5 + 0.5 * Math.sin(0.58 * col + 0.83 * row); const opacity = clamp(energy * (0.24 + 0.76 * texture), 0.04, 0.97); const targetX = r.x + col * r.w / cols; const targetY = r.y + (rows - 1 - row) * r.h / rows; const sourceY = r.y + r.h / 2 - waveform(t) * r.h * 0.42; const x = targetX; const y = lerp(sourceY, targetY, amount); const cellW = lerp(4, r.w / cols + 1, amount); const cellH = lerp(4, r.h / rows + 1, amount); ctx.fillStyle = row > 8 ? `rgba(185,167,255,${opacity})` : `rgba(79,140,255,${opacity})`; ctx.fillRect(x, y, cellW, cellH); } } ctx.restore(); }
function drawCurve(ctx, fn, color, width = 2, alpha = 1, clipRanges) { const r = plotRect(); ctx.save(); ctx.strokeStyle = color; ctx.lineWidth = width; ctx.globalAlpha = alpha; ctx.beginPath(); let started = false; for (let i = 0; i <= 240; i++) { const t = 8 * i / 240; const visible = !clipRanges || clipRanges.some(([a, b]) => t >= a && t <= b); if (!visible) { started = false; continue; } const x = r.x + r.w * t / 8; const y = r.y + r.h * (1 - fn(t)); if (!started) ctx.moveTo(x, y); else ctx.lineTo(x, y); started = true; } ctx.stroke(); ctx.restore(); }
function drawEvents(ctx, alpha = 1, labels = "speech event") { const r = plotRect(); ctx.save(); ctx.globalAlpha = alpha; EVENTS.forEach(([a, b, color], i) => { const x = r.x + r.w * a / 8; const w = r.w * (b - a) / 8; ctx.fillStyle = color + "18"; ctx.fillRect(x, r.y, w, r.h); ctx.strokeStyle = color; ctx.lineWidth = 2; ctx.strokeRect(x, r.y, w, r.h); text(ctx, labels === "speech event" ? `speech event ${i + 1}` : `E${i + 1} class channels`, x + w / 2, r.y - 19, labels === "speech event" ? 17 : 20, color, "center", 700); }); ctx.restore(); }
function drawStrips(ctx, p) { const r = plotRect(); EVENTS.forEach(([a, b, eventColor], eventIndex) => { const x = r.x + r.w * a / 8; const w = r.w * (b - a) / 8; const targetY = r.y + 13; CHANNELS.forEach(([, color], i) => { const y0 = r.y + r.h * (1 - channelProb(i, (a + b) / 2)); const y = lerp(y0, targetY, p); const sx = x + i * w / CHANNELS.length; ctx.strokeStyle = color; ctx.lineWidth = lerp(3, 15, p); ctx.beginPath(); ctx.moveTo(sx, y); ctx.lineTo(sx + w / CHANNELS.length + 1, y); ctx.stroke(); }); ctx.strokeStyle = eventColor; ctx.lineWidth = 2; ctx.strokeRect(x, r.y, w, r.h); text(ctx, `E${eventIndex + 1} class channels`, x + w / 2, r.y - 25, 20, C.white, "center", 700); }); }
const COLS = [ ["Speech", C.teal], ["Music", C.purple], ["Natural", C.blue], ["Urban", C.orange], ["Animal", C.green], ["Indoor", C.gold], ["Background", "#4267a8"], ["Vocal", C.coral], ]; const ROWS = ["mean", "std", "p50", "p90", "p95", "max", "frac≥.3"]; const VALUES = [ [.78, .05, .03, .04, .02, .06, .04, .08], [.10, .03, .02, .03, .02, .04, .02, .05], [.80, .04, .02, .03, .01, .05, .04, .07], [.88, .09, .06, .08, .05, .11, .07, .15], [.90, .11, .08, .10, .07, .13, .09, .18], [.93, .15, .12, .14, .11, .19, .13, .24], [.96, .02, .00, .01, .00, .02, .00, .04], ];
function matrixGeometry() { return { x: 95, y: 190, rowW: 110, cellW: 116, cellH: 59 }; }
function drawMatrix(ctx, alpha = 1, highlights = {}) { const g = matrixGeometry(); ctx.save(); ctx.globalAlpha = alpha; roundedRect(ctx, g.x, g.y, g.rowW, g.cellH, 0, C.panel, C.grid); text(ctx, "metric", g.x + g.rowW / 2, g.y + g.cellH / 2, 15, C.muted, "center", 700); COLS.forEach(([name, color], col) => { const x = g.x + g.rowW + col * g.cellW; ctx.globalAlpha = alpha; ctx.fillStyle = color + "30"; ctx.fillRect(x, g.y, g.cellW, g.cellH); ctx.strokeStyle = C.grid; ctx.strokeRect(x, g.y, g.cellW, g.cellH); text(ctx, name, x + g.cellW / 2, g.y + g.cellH / 2, 13, color, "center", 700); }); ROWS.forEach((name, row) => { const y = g.y + (row + 1) * g.cellH; ctx.fillStyle = C.panel; ctx.fillRect(g.x, y, g.rowW, g.cellH); ctx.strokeStyle = C.grid; ctx.strokeRect(g.x, y, g.rowW, g.cellH); text(ctx, name, g.x + g.rowW / 2, y + g.cellH / 2, 15, C.muted, "center", 700); COLS.forEach(([, color], col) => { const x = g.x + g.rowW + col * g.cellW; const key = `${row}:${col}`; const h = highlights[key] || 0; ctx.fillStyle = h ? `rgba(118,185,0,${0.25 + 0.65 * h})` : color + "42"; ctx.fillRect(x, y, g.cellW, g.cellH); ctx.strokeStyle = h ? C.green : C.grid; ctx.lineWidth = h ? 3 : 1; ctx.strokeRect(x, y, g.cellW, g.cellH); text(ctx, VALUES[row][col].toFixed(2), x + g.cellW / 2, y + g.cellH / 2, 16, C.white, "center", h ? 700 : 400); }); }); ctx.restore(); }
function treeNode(ctx, value, x, y, w, active = 0, muted = false) { ctx.save(); ctx.globalAlpha = muted ? 0.28 : 1; roundedRect(ctx, x - w / 2, y - 29, w, 58, 10, active ? "#19270a" : C.panel, active ? C.green : "#777777", active ? 4 : 2); text(ctx, value, x, y, 16, C.white, "center", 700); ctx.restore(); }
function drawTree(ctx, p) { const x = 1300; const root = [x, 255], second = [x, 395], clean = [1198, 555], reject = [1405, 555]; const firstDone = phase(p, .05, .36); const secondDone = phase(p, .42, .73); ctx.save(); ctx.lineWidth = 4; ctx.strokeStyle = firstDone > .6 ? C.green : C.grid; ctx.beginPath(); ctx.moveTo(root[0], root[1] + 30); ctx.lineTo(second[0], second[1] - 30); ctx.stroke(); ctx.strokeStyle = secondDone > .6 ? C.green : C.grid; ctx.beginPath(); ctx.moveTo(second[0], second[1] + 30); ctx.lineTo(clean[0], clean[1] - 30); ctx.stroke(); ctx.globalAlpha = secondDone > .6 ? .25 : 1; ctx.strokeStyle = C.grid; ctx.beginPath(); ctx.moveTo(second[0], second[1] + 30); ctx.lineTo(reject[0], reject[1] - 30); ctx.stroke(); ctx.restore(); text(ctx, "one tree in the ensemble", x, 191, 15, C.muted); treeNode(ctx, "speech mean > .55?", ...root, 220, firstDone); treeNode(ctx, "music p95 < .25?", ...second, 220, secondDone); treeNode(ctx, "CLEAN", ...clean, 140, secondDone); treeNode(ctx, "NOT CLEAN", ...reject, 158, 0, secondDone > .6); if (p > .76) { pill(ctx, "E2 clean_speech_event_score = 0.31 → CLEAN", x, 660, C.green, 15, 465); text(ctx, "classifier threshold = 0.1197503", x, 704, 14, C.muted); } return { "0:0": firstDone, "4:1": secondDone, }; }
function drawFinal(ctx, p) { const r = plotRect(); drawAxes(ctx, false, 0.8); drawWave(ctx, C.muted, .35); EVENTS.slice(0, 2).forEach(([a, b]) => { const x = r.x + r.w * a / 8; const w = r.w * (b - a) / 8; ctx.fillStyle = C.green + "18"; ctx.fillRect(x, r.y, w, r.h); ctx.strokeStyle = C.green; ctx.lineWidth = 2; ctx.strokeRect(x, r.y, w, r.h); pill(ctx, "clean speech", x + w / 2, r.y + 52, C.green, 17); }); drawWave(ctx, C.green, 1, EVENTS.slice(0, 2)); drawWave(ctx, C.coral, .35, [EVENTS[2]]); pill(ctx, "rejected", r.x + r.w * 6.35 / 8, r.y + 160, C.coral, 17);
const valuesAlpha = phase(p, .12, .37); ctx.save(); ctx.globalAlpha = valuesAlpha; const eventValues = [ [1.77, "₁", "1.82 s", "0.77", "0.27"], [4.20, "₂", "2.16 s", "0.70", "0.31"], ]; eventValues.forEach(([center, index, duration, evidence, score]) => { const x = r.x + r.w * center / 8; text(ctx, `duration (t${index}) = ${duration}`, x, 735, 15, C.white); text(ctx, `mean p_speech (μ${index}) = ${evidence}`, x, 760, 15, C.teal); text(ctx, `clean_speech_event_score (q${index}) = ${score}`, x, 785, 15, C.gold); }); ctx.restore();
const metricsAlpha = phase(p, .43, .72); ctx.save(); ctx.globalAlpha = metricsAlpha; const x = 1150; text(ctx, "SEGMENT-LEVEL METRICS", x, 728, 16, C.muted, "left", 700); text(ctx, "rₛₚₑₑ꜀ₕ = Σᵢ Δtᵢ / T = 0.498", x, 759, 18, C.white, "left", 500); text(ctx, "cₘₒdₑₗ = Σᵢ (Δtᵢ / T) μᵢ = 0.364", x, 790, 18, C.teal, "left", 500); text(ctx, "cɢʙᴛ = Σᵢ (Δtᵢ / T) qᵢ = 0.145", x, 821, 18, C.gold, "left", 500); ctx.restore(); }
function drawFrame(ctx, t) { ctx.clearRect(0, 0, W, H); ctx.fillStyle = C.bg; ctx.fillRect(0, 0, W, H);
if (t < 4) { heading(ctx, "THE SAME 8-SECOND SEGMENT", "Audio waveform"); drawAxes(ctx); drawWave(ctx); pill(ctx, "mono • 16 kHz", W / 2, 810, C.cyan, 17); return; } if (t < 8) { const p = phase(t, 4, 7); heading(ctx, "SAME TIME AXIS", "Log-mel spectrogram"); drawAxes(ctx, false, 1 - p); drawWave(ctx, C.cyan, 1 - p); drawMel(ctx, p); pill(ctx, "1024-sample window • hop 320 • 64 mel bins", W / 2, 810, C.purple, 17); return; } if (t < 13) { const p = phase(t, 8, 10); heading(ctx, "CNN14 • SIGMOID • 50 FRAMES/S", "Framewise class probabilities"); drawAxes(ctx, true); CHANNELS.forEach(([, color], i) => drawCurve(ctx, x => channelProb(i, x), color, 2.5, p)); drawLegend(ctx, p); return; } if (t < 17) { const p = phase(t, 13, 15); heading(ctx, "7 SPEECH CLASSES → NOISY-OR", "One speech probability"); drawAxes(ctx, true); CHANNELS.forEach(([, color], i) => drawCurve(ctx, x => channelProb(i, x), color, 2.2, .32)); drawCurve(ctx, speechProb, C.teal, 7, p); pill(ctx, "pₛₚₑₑ꜀ₕ(t) = 1 − ∏c∈S [1 − p꜀(t)]", 1185, 190, C.teal, 18, 470); drawLegend(ctx); return; } if (t < 22) { const p = phase(t, 17, 19); heading(ctx, "MEDIAN 0.2 s • THRESHOLD 0.2 • MERGE GAP ≤ 0.1 s", "Speech events on the same timeline"); drawAxes(ctx, true); CHANNELS.forEach(([, color], i) => drawCurve(ctx, x => channelProb(i, x), color, 1.8, .16)); drawCurve(ctx, speechProb, C.teal, 6); const r = plotRect(); const y = r.y + r.h * .8; ctx.strokeStyle = C.coral; ctx.lineWidth = 2; ctx.beginPath(); ctx.moveTo(r.x, y); ctx.lineTo(r.x + r.w, y); ctx.stroke(); pill(ctx, "0.2", r.x + r.w - 32, y - 26, C.coral, 14, 58); drawEvents(ctx, p); drawLegend(ctx); return; } if (t < 26) { const p = phase(t, 22, 24); heading(ctx, "INSIDE EACH DETECTED EVENT", "Speech-event evidence from p_speech"); drawAxes(ctx, true); drawCurve(ctx, speechProb, C.teal, 6); drawEvents(ctx, .45); const r = plotRect(); const a = EVENTS[1][0], b = EVENTS[1][1], mean = .70; const x1 = r.x + r.w * a / 8, x2 = r.x + r.w * b / 8; const y = r.y + r.h * (1 - mean); ctx.strokeStyle = C.white; ctx.lineWidth = 4; ctx.beginPath(); ctx.moveTo(x1, y); ctx.lineTo(lerp(x1, x2, p), y); ctx.stroke(); if (p > .45) pill(ctx, "speech_event_evidence(E2) = mean pₛₚₑₑ꜀ₕ(t) = 0.70", (x1 + x2) / 2, y + 45, C.white, 16, 510); if (p > .72) pill(ctx, "max = 0.91", r.x + r.w * 4.25 / 8, r.y + 35, C.gold, 16); drawLegend(ctx); return; } if (t < 31) { const p = phase(t, 26, 29); heading(ctx, "KEEP CLASS PROBABILITIES ONLY INSIDE EACH EVENT", "Each speech event becomes a feature strip"); drawAxes(ctx, true); if (p < .75) CHANNELS.forEach(([, color], i) => drawCurve(ctx, x => channelProb(i, x), color, 2.5, 1 - p * .65, EVENTS)); drawEvents(ctx, .75, "class channels"); drawStrips(ctx, p); drawLegend(ctx); return; } if (t < 37) { const p = phase(t, 31, 34); heading(ctx, "E2 STRIP EXPANDS INTO EVENT FEATURES", "Metrics × class probability matrix"); if (p < .6) { const fade = 1 - phase(p, .2, .6); ctx.save(); ctx.globalAlpha = fade; drawStrips(ctx, 1); ctx.restore(); } drawMatrix(ctx, phase(p, .38, .85)); drawLegend(ctx); return; } if (t < 42) { const p = phase(t, 37, 41); heading(ctx, "GBT EVALUATES THE FULL MATRIX FOR E2", "Tree decisions select clean segments"); const highlights = drawTree(ctx, p); ctx.save(); ctx.translate(-40, 35); ctx.scale(.74, .74); drawMatrix(ctx, 1, highlights); ctx.restore(); drawLegend(ctx); return; } const p = phase(t, 42, 47); heading(ctx, "BACK ON THE ORIGINAL AUDIO TIMELINE", "Selected clean speech segments"); drawFinal(ctx, p); drawLegend(ctx); }
class SedExplainer { constructor(root) { this.root = root; this.canvas = root.querySelector("canvas"); this.ctx = this.canvas.getContext("2d"); this.playButton = root.querySelector('[data-action="play"]'); this.restartButton = root.querySelector('[data-action="restart"]'); this.timeline = root.querySelector(".sed-explainer__timeline"); this.timeLabel = root.querySelector(".sed-explainer__time"); this.time = 0; this.playing = false; this.lastFrame = 0; this.visible = false; this.reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
this.resize = this.resize.bind(this); this.tick = this.tick.bind(this); this.toggle = this.toggle.bind(this); this.restart = this.restart.bind(this); this.seek = this.seek.bind(this); this.resizeObserver = new ResizeObserver(this.resize); this.resizeObserver.observe(root); this.intersectionObserver = new IntersectionObserver((entries) => { this.visible = entries[0].isIntersecting; if (this.visible && !this.reducedMotion && this.time === 0) this.play(); if (!this.visible) this.pause(); }, { threshold: 0.2 }); this.intersectionObserver.observe(root); this.playButton.addEventListener("click", this.toggle); this.restartButton.addEventListener("click", this.restart); this.timeline.addEventListener("input", this.seek);
if (this.reducedMotion) this.time = DURATION; this.resize(); this.render(); }
resize() { const viewport = this.root.querySelector(".sed-explainer__viewport"); const bounds = viewport.getBoundingClientRect(); if (!bounds.width || !bounds.height) return; const dpr = Math.min(window.devicePixelRatio || 1, 2); this.canvas.width = Math.round(bounds.width * dpr); this.canvas.height = Math.round(bounds.height * dpr); this.render(); }
render() { const sx = this.canvas.width / W; const sy = this.canvas.height / H; this.ctx.setTransform(sx, 0, 0, sy, 0, 0); drawFrame(this.ctx, this.time); this.timeline.value = String(this.time); this.timeLabel.textContent = `${Math.floor(this.time / 60)}:${String(Math.floor(this.time % 60)).padStart(2, "0")} / 0:48`; }
play() { if (this.time >= DURATION) this.time = 0; if (this.playing) return; this.playing = true; this.playButton.textContent = "Pause"; this.playButton.setAttribute("aria-label", "Pause SED animation"); this.lastFrame = performance.now(); requestAnimationFrame(this.tick); }
pause() { this.playing = false; this.playButton.textContent = "Play"; this.playButton.setAttribute("aria-label", "Play SED animation"); }
toggle() { if (this.playing) this.pause(); else this.play(); }
restart() { this.time = 0; this.render(); if (!this.reducedMotion) this.play(); }
seek(event) { this.time = Number(event.target.value); this.render(); }
tick(now) { if (!this.playing) return; const delta = Math.min((now - this.lastFrame) / 1000, .1); this.lastFrame = now; this.time += delta; if (this.time >= DURATION) { this.time = DURATION; this.pause(); } this.render(); if (this.playing) requestAnimationFrame(this.tick); } }
function initialize(root) { if (root.__sedExplainer) return; root.__sedExplainer = new SedExplainer(root); }
function scan(node) { if (!(node instanceof Element || node instanceof Document)) return; if (node.matches && node.matches("[data-sed-explainer]")) initialize(node); if (node.querySelectorAll) { node.querySelectorAll("[data-sed-explainer]").forEach(initialize); } }
function start() { scan(document); new MutationObserver((mutations) => { mutations.forEach((mutation) => mutation.addedNodes.forEach(scan)); }).observe(document.body, { childList: true, subtree: true }); }
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start); else start();})();index.html+14-4
sed_pipeline_explainer.cssAdded+88
sed_pipeline_explainer.jsAdded+671