// Estimates spoken run time from the speaker notes at 140 words per minute. // [Bracketed] cues are stage directions and are not counted. import { readdirSync, readFileSync } from 'node:fs' import { join } from 'node:path' const dir = new URL('../src/slides', import.meta.url).pathname const WPM = Number(process.env.WPM ?? 140) let total = 0 const rows = [] for (const f of readdirSync(dir).filter((f) => f.endsWith('.html')).sort()) { const html = readFileSync(join(dir, f), 'utf8') const id = html.match(/
([\s\S]*?)<\/aside>/)?.[1] ?? '') .replace(/<[^>]+>/g, ' ') .replace(/\[[^\]]*\]/g, ' ') const words = notes.split(/\s+/).filter((w) => /\w/.test(w)).length total += words rows.push([id, words, words / WPM]) } for (const [id, words, min] of rows) console.log(`${id.padEnd(22)} ${String(words).padStart(4)} words ${(min * 60).toFixed(0).padStart(4)}s`) console.log(`${'total'.padEnd(22)} ${String(total).padStart(4)} words ${(total / WPM).toFixed(1)} min at ${WPM} wpm (budget 20 min)`)