Docs refresh: add user manual & architecture review; update README with accurate details
This commit is contained in:
@@ -0,0 +1,520 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Win Dictation — Architecture & Engineering Review</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root{
|
||||
--bg:#0E1014; --card:#16191F; --card-hi:#1E222B; --card-lo:#12151B;
|
||||
--text:#ECEEF2; --dim:#8A909C; --faint:#5A606C;
|
||||
--accent:#6E8BFF; --accent-hi:#839CFF; --danger:#FF5C5C; --good:#46D39A; --warn:#E8B84B;
|
||||
--border:#262B36; --hair:rgba(255,255,255,.06);
|
||||
--mono:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace;
|
||||
--sans:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
|
||||
}
|
||||
*{box-sizing:border-box}
|
||||
html{scroll-behavior:smooth}
|
||||
body{margin:0; background:var(--bg); color:var(--text); font-family:var(--sans);
|
||||
font-size:16.5px; line-height:1.72; -webkit-font-smoothing:antialiased; letter-spacing:.1px}
|
||||
.wrap{max-width:960px; margin:0 auto; padding:0 6vw 140px}
|
||||
a{color:var(--accent-hi); text-decoration:none} a:hover{text-decoration:underline}
|
||||
|
||||
.hero{padding:88px 0 34px; border-bottom:1px solid var(--border); margin-bottom:50px}
|
||||
.eyebrow{font-family:var(--mono); font-size:12.5px; letter-spacing:.32em; text-transform:uppercase; color:var(--accent); margin:0 0 22px}
|
||||
h1{font-size:clamp(32px,5.6vw,52px); line-height:1.05; margin:0; font-weight:800; letter-spacing:-1.2px; max-width:840px}
|
||||
.sub{font-size:20px; color:var(--dim); max-width:720px; margin:20px 0 0; font-weight:400}
|
||||
.metarow{display:flex; flex-wrap:wrap; gap:10px; margin-top:30px}
|
||||
.chip{font-family:var(--mono); font-size:12.5px; color:var(--dim); background:var(--card); border:1px solid var(--border); border-radius:999px; padding:7px 15px}
|
||||
.chip b{color:var(--text); font-weight:600}
|
||||
|
||||
.toc{background:linear-gradient(180deg,var(--card),var(--card-lo)); border:1px solid var(--border); border-radius:18px; padding:30px 34px; margin-bottom:60px}
|
||||
.toc h4{margin:0 0 18px; font-family:var(--mono); font-size:12px; letter-spacing:.28em; text-transform:uppercase; color:var(--faint)}
|
||||
.toc ol{margin:0; padding:0; list-style:none; counter-reset:t; columns:2; column-gap:46px}
|
||||
.toc li{counter-increment:t; padding:7px 0; break-inside:avoid}
|
||||
.toc li a{color:var(--text); font-weight:500; font-size:15.5px}
|
||||
.toc li a::before{content:counter(t,decimal-leading-zero); font-family:var(--mono); color:var(--accent); font-size:12px; margin-right:13px; font-weight:600}
|
||||
|
||||
section{margin:0 0 72px; scroll-margin-top:30px}
|
||||
.sec-h{display:flex; align-items:baseline; gap:16px; margin:0 0 10px}
|
||||
.sec-n{font-family:var(--mono); font-size:14px; color:var(--accent); font-weight:600; flex:none}
|
||||
h2{font-size:29px; font-weight:700; margin:0; letter-spacing:-.5px}
|
||||
h3{font-size:19px; font-weight:650; margin:38px 0 12px; letter-spacing:-.2px}
|
||||
.lead{color:var(--dim); font-size:18px; margin:0 0 26px; max-width:740px}
|
||||
p{margin:0 0 17px} .muted{color:var(--dim)} strong{color:#fff; font-weight:650}
|
||||
ul,ol{margin:0 0 18px; padding-left:22px} li{margin:9px 0}
|
||||
|
||||
code{font-family:var(--mono); font-size:14px; background:var(--card-hi); color:#cfe0ff; padding:2px 7px; border-radius:6px; border:1px solid var(--border)}
|
||||
.path{font-family:var(--mono); font-size:13.5px; color:var(--good)}
|
||||
pre{background:var(--card-lo); border:1px solid var(--border); border-radius:13px; padding:20px 22px; overflow-x:auto; margin:20px 0;
|
||||
font-family:var(--mono); font-size:13.5px; line-height:1.7; color:#c8d2e0}
|
||||
pre .c{color:var(--faint)} pre .k{color:#c98bff} pre .s{color:var(--good)} pre .n{color:var(--accent-hi)} pre .f{color:#ffd479}
|
||||
|
||||
/* verdict box */
|
||||
.verdict{background:linear-gradient(135deg,rgba(110,139,255,.12),rgba(70,211,154,.06)); border:1px solid var(--border);
|
||||
border-radius:18px; padding:30px 34px; margin:6px 0 10px; position:relative; overflow:hidden}
|
||||
.verdict::before{content:""; position:absolute; left:0; top:0; bottom:0; width:4px; background:linear-gradient(180deg,var(--accent),var(--good))}
|
||||
.verdict .vh{font-family:var(--mono); font-size:11.5px; letter-spacing:.2em; text-transform:uppercase; color:var(--accent); margin:0 0 12px}
|
||||
.verdict p{font-size:18.5px; line-height:1.66; margin:0 0 14px; color:var(--text)}
|
||||
.verdict p:last-child{margin:0}
|
||||
.verdict .big{font-size:22px; font-weight:700; letter-spacing:-.3px}
|
||||
|
||||
/* pipeline */
|
||||
.pipe{display:flex; flex-wrap:wrap; align-items:stretch; gap:0; margin:26px 0; border:1px solid var(--border); border-radius:14px; overflow:hidden; background:var(--card-lo)}
|
||||
.stage{flex:1 1 120px; min-width:120px; padding:18px 16px; border-right:1px solid var(--border); position:relative}
|
||||
.stage:last-child{border-right:0}
|
||||
.stage .si{font-family:var(--mono); font-size:11px; color:var(--faint); margin:0 0 8px}
|
||||
.stage .sn{font-weight:650; font-size:14.5px; margin:0 0 4px; color:var(--text)}
|
||||
.stage .sd{font-size:12.5px; color:var(--dim); line-height:1.5; margin:0}
|
||||
.stage.hot{background:linear-gradient(180deg,rgba(110,139,255,.1),transparent)}
|
||||
.stage.work{background:linear-gradient(180deg,rgba(70,211,154,.1),transparent)}
|
||||
|
||||
.tbl{width:100%; border-collapse:collapse; margin:20px 0; font-size:14.5px; border-radius:12px; overflow:hidden; border:1px solid var(--border)}
|
||||
.tbl th{text-align:left; font-family:var(--mono); font-size:11px; letter-spacing:.1em; text-transform:uppercase; color:var(--dim); padding:12px 15px; background:var(--card-lo); border-bottom:1px solid var(--border); font-weight:600}
|
||||
.tbl td{padding:12px 15px; border-bottom:1px solid var(--border); vertical-align:top}
|
||||
.tbl tr:last-child td{border-bottom:0}
|
||||
.tbl td code{font-size:13px}
|
||||
.tbl .r{color:var(--dim); font-size:13.5px}
|
||||
|
||||
.note{border:1px solid var(--border); border-left:3px solid var(--accent); background:linear-gradient(90deg,rgba(110,139,255,.08),transparent 60%); border-radius:12px; padding:17px 20px; margin:22px 0}
|
||||
.note.warn{border-left-color:var(--warn); background:linear-gradient(90deg,rgba(232,184,75,.09),transparent 60%)}
|
||||
.note.bad{border-left-color:var(--danger); background:linear-gradient(90deg,rgba(255,92,92,.08),transparent 60%)}
|
||||
.note.good{border-left-color:var(--good); background:linear-gradient(90deg,rgba(70,211,154,.08),transparent 60%)}
|
||||
.note .nt{font-family:var(--mono); font-size:11.5px; letter-spacing:.18em; text-transform:uppercase; color:var(--dim); margin:0 0 6px}
|
||||
.note p:last-child{margin:0}
|
||||
|
||||
/* assessment cards */
|
||||
.assess{display:grid; gap:14px; margin:22px 0}
|
||||
.ac{border:1px solid var(--border); border-radius:13px; padding:18px 20px; background:var(--card)}
|
||||
.ac .ah{display:flex; align-items:center; gap:11px; margin:0 0 7px}
|
||||
.ac .dot{width:9px;height:9px;border-radius:50%; flex:none}
|
||||
.ac.pos .dot{background:var(--good)} .ac.neg .dot{background:var(--danger)} .ac.neu .dot{background:var(--warn)}
|
||||
.ac h4{margin:0; font-size:16.5px; font-weight:650}
|
||||
.ac p{margin:0; color:var(--dim); font-size:14.5px; line-height:1.62}
|
||||
.ac .ref{font-family:var(--mono); font-size:12px; color:var(--faint); margin-top:7px}
|
||||
|
||||
/* scorecard */
|
||||
.score{background:var(--card); border:1px solid var(--border); border-radius:16px; padding:28px 30px; margin:24px 0}
|
||||
.srow{display:grid; grid-template-columns:200px 1fr 50px; align-items:center; gap:18px; padding:11px 0; border-bottom:1px solid var(--border)}
|
||||
.srow:last-child{border-bottom:0}
|
||||
.srow .sl{font-size:14.5px; font-weight:500}
|
||||
.srow .sb{height:9px; background:var(--card-hi); border-radius:99px; overflow:hidden}
|
||||
.srow .sf{height:100%; border-radius:99px; background:linear-gradient(90deg,var(--accent),var(--accent-hi))}
|
||||
.srow .sf.hi{background:linear-gradient(90deg,#46D39A,#6ee0b0)}
|
||||
.srow .sf.lo{background:linear-gradient(90deg,#E8B84B,#f0cd77)}
|
||||
.srow .sf.vlo{background:linear-gradient(90deg,#FF5C5C,#ff8585)}
|
||||
.srow .sv{font-family:var(--mono); font-size:14px; font-weight:600; text-align:right; color:var(--text)}
|
||||
.overall{display:flex; align-items:baseline; gap:16px; margin-top:22px; padding-top:22px; border-top:1px solid var(--border)}
|
||||
.overall .num{font-size:46px; font-weight:800; letter-spacing:-2px; color:var(--accent-hi); font-family:var(--mono)}
|
||||
.overall .ot{color:var(--dim); font-size:15px}
|
||||
|
||||
/* recommendations */
|
||||
.rec{counter-reset:r; margin:22px 0; padding:0; list-style:none}
|
||||
.rec li{counter-increment:r; position:relative; padding:16px 18px 16px 60px; margin:0 0 12px; background:var(--card); border:1px solid var(--border); border-radius:12px}
|
||||
.rec li::before{content:counter(r); position:absolute; left:16px; top:16px; width:30px;height:30px;border-radius:9px; background:var(--card-hi); color:var(--accent); font-family:var(--mono); font-weight:700; display:flex; align-items:center; justify-content:center; font-size:14px}
|
||||
.rec h4{margin:0 0 4px; font-size:16px; font-weight:650}
|
||||
.rec p{margin:0; color:var(--dim); font-size:14.5px}
|
||||
.pri{font-family:var(--mono); font-size:10.5px; letter-spacing:.1em; text-transform:uppercase; padding:2px 8px; border-radius:5px; margin-left:9px; vertical-align:middle}
|
||||
.pri.hi{background:rgba(255,92,92,.16); color:var(--danger)}
|
||||
.pri.md{background:rgba(232,184,75,.16); color:var(--warn)}
|
||||
.pri.lo{background:rgba(138,144,156,.16); color:var(--dim)}
|
||||
|
||||
.stackgrid{display:grid; grid-template-columns:repeat(2,1fr); gap:14px; margin:22px 0}
|
||||
.scell{background:var(--card); border:1px solid var(--border); border-radius:12px; padding:16px 18px}
|
||||
.scell .sk{font-family:var(--mono); font-size:11px; letter-spacing:.12em; text-transform:uppercase; color:var(--faint); margin:0 0 6px}
|
||||
.scell .sv{font-size:15px; color:var(--text); font-weight:500}
|
||||
.scell .sv span{color:var(--dim); font-weight:400; font-size:13.5px}
|
||||
|
||||
.footer{border-top:1px solid var(--border); margin-top:80px; padding-top:30px; color:var(--faint); font-size:13.5px; font-family:var(--mono)}
|
||||
.footer b{color:var(--dim); font-weight:500}
|
||||
|
||||
@media(max-width:680px){
|
||||
.toc ol,.stackgrid{columns:1; grid-template-columns:1fr}
|
||||
.srow{grid-template-columns:1fr; gap:6px}
|
||||
.srow .sv{text-align:left}
|
||||
.pipe .stage{flex-basis:100%; border-right:0; border-bottom:1px solid var(--border)}
|
||||
body{font-size:16px}
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
.ha-img-placeholder{display:flex;align-items:center;justify-content:center;flex-direction:column;gap:6px;background:#f4f4f5;border:1px dashed #d4d4d8;border-radius:8px;color:#71717a;font-size:12px;font-family:system-ui,sans-serif;min-height:80px;padding:16px;box-sizing:border-box;animation:ha-img-pulse 1.5s ease-in-out infinite}
|
||||
.ha-img-placeholder.ha-failed{animation:none;opacity:.7}
|
||||
@keyframes ha-img-pulse{0%,100%{opacity:1}50%{opacity:.5}}
|
||||
@media(prefers-color-scheme:dark){.ha-img-placeholder{background:#27272a;border-color:#3f3f46;color:#a1a1aa}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
|
||||
<header class="hero">
|
||||
<p class="eyebrow">Architecture · Code Analysis · Engineering Verdict</p>
|
||||
<h1>Win Dictation: under the hood</h1>
|
||||
<p class="sub">A guided walk through a native Win32 C++ speech-to-text app — how it's built, why it's built that way, and an honest assessment of the code for anyone picking it up for the first time.</p>
|
||||
<div class="metarow">
|
||||
<span class="chip"><b>~3,400</b> lines C++ (app)</span>
|
||||
<span class="chip"><b>Win32</b> + GDI+ + SDL2 + whisper.cpp</span>
|
||||
<span class="chip"><b>Single .exe</b>, no runtime deps</span>
|
||||
<span class="chip"><b>Target</b> 2-core i5, CPU-only</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<nav class="toc">
|
||||
<h4>Contents</h4>
|
||||
<ol>
|
||||
<li><a href="#tldr">The verdict, up front</a></li>
|
||||
<li><a href="#stack">Stack at a glance</a></li>
|
||||
<li><a href="#arch">Architecture & data flow</a></li>
|
||||
<li><a href="#decision">The defining decision</a></li>
|
||||
<li><a href="#threads">Threading model</a></li>
|
||||
<li><a href="#map">Source map, file by file</a></li>
|
||||
<li><a href="#ui">Deep dive: the UI engine</a></li>
|
||||
<li><a href="#timing">Deep dive: the progress estimator</a></li>
|
||||
<li><a href="#transcriber">Deep dive: the transcriber</a></li>
|
||||
<li><a href="#persistence">History, downloads & persistence</a></li>
|
||||
<li><a href="#anatomy">Anatomy of one dictation</a></li>
|
||||
<li><a href="#strengths">What's done well</a></li>
|
||||
<li><a href="#weaknesses">What holds it back</a></li>
|
||||
<li><a href="#recs">Recommendations</a></li>
|
||||
<li><a href="#scorecard">Scorecard & final word</a></li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<!-- 1 -->
|
||||
<section id="tldr">
|
||||
<div class="sec-h"><span class="sec-n">01</span><h2>The verdict, up front</h2></div>
|
||||
<div class="verdict">
|
||||
<p class="vh">Bottom line</p>
|
||||
<p class="big">A genuinely strong, characterful single-purpose tool that punches well above hobby grade.</p>
|
||||
<p>The hard engineering — the architecture choice, the self-calibrating progress estimator, the seam-free single-surface renderer — is thoughtful and well-executed. The app does exactly one thing and does it well on hardware most tools would choke on.</p>
|
||||
<p>What holds it back is <strong>organizational debt, not algorithmic weakness</strong>: a 1,500-line <code>main.cpp</code>, a layer of vestigial child-window controls left over from an earlier design, and a pile of stale documentation that describes a GPU-streaming app this no longer is. None of it breaks the running product — but all of it raises the cost of the next person walking in.</p>
|
||||
</div>
|
||||
<p class="muted">The sections below back up every part of that judgement with specifics from the source.</p>
|
||||
</section>
|
||||
|
||||
<!-- 2 -->
|
||||
<section id="stack">
|
||||
<div class="sec-h"><span class="sec-n">02</span><h2>Stack at a glance</h2></div>
|
||||
<p class="lead">Deliberately lean. No UI framework, no managed runtime, no garbage collector — just the OS and three libraries.</p>
|
||||
<div class="stackgrid">
|
||||
<div class="scell"><p class="sk">Language</p><p class="sv">C++ <span>(MSVC, Release /O2 /GL /LTCG, AVX2/FMA/F16C)</span></p></div>
|
||||
<div class="scell"><p class="sk">UI</p><p class="sv">Raw Win32 + GDI+ <span>immediate-mode painted surface</span></p></div>
|
||||
<div class="scell"><p class="sk">Audio capture</p><p class="sv">SDL2 <span>16 kHz mono, F32</span></p></div>
|
||||
<div class="scell"><p class="sk">Inference</p><p class="sv">whisper.cpp <span>whisper_full, CPU backend</span></p></div>
|
||||
<div class="scell"><p class="sk">Networking</p><p class="sv">WinHTTP <span>model downloads, system proxy aware</span></p></div>
|
||||
<div class="scell"><p class="sk">Persistence</p><p class="sv">Plain INI + UTF-8 text files <span>no database</span></p></div>
|
||||
<div class="scell"><p class="sk">Build</p><p class="sv">CMake <span>+ a PowerShell convenience script</span></p></div>
|
||||
<div class="scell"><p class="sk">Footprint</p><p class="sv">One .exe + a few DLLs + model <span>tiny RAM, no install</span></p></div>
|
||||
</div>
|
||||
<p>The whole product is native code with no framework abstraction between it and the Win32 API. That's the source of both its biggest strength (a tiny, fast, dependency-light binary) and its biggest cost (everything is hand-rolled, including the widgets).</p>
|
||||
</section>
|
||||
|
||||
<!-- 3 -->
|
||||
<section id="arch">
|
||||
<div class="sec-h"><span class="sec-n">03</span><h2>Architecture & data flow</h2></div>
|
||||
<p class="lead">A linear pipeline with a single inference step. Audio in, text out, no streaming loop.</p>
|
||||
<div class="pipe">
|
||||
<div class="stage hot"><p class="si">trigger</p><p class="sn">Hotkey</p><p class="sd">Global <code>RegisterHotKey</code>. Captures the previously focused window.</p></div>
|
||||
<div class="stage"><p class="si">capture</p><p class="sn">SDL2 mic</p><p class="sd">16 kHz mono into an in-memory buffer. Near-zero CPU.</p></div>
|
||||
<div class="stage"><p class="si">buffer</p><p class="sn">PCM in RAM</p><p class="sd">Accumulated under a mutex; RMS energy tracked for the meter.</p></div>
|
||||
<div class="stage work"><p class="si">inference</p><p class="sn">whisper_full</p><p class="sd">One pass on a worker thread when you stop. Trim → transcribe → clean.</p></div>
|
||||
<div class="stage"><p class="si">deliver</p><p class="sn">Insert + paste</p><p class="sd">Text to caret, to clipboard, into the prior window.</p></div>
|
||||
</div>
|
||||
<p>Two side channels run alongside the main pipeline: a <strong>progress estimator</strong> that predicts and smooths the transcription countdown, and a <strong>timing model</strong> that learns this machine's speed and feeds back into the next prediction. Results return to the UI thread exclusively via <code>PostMessage</code>; shared flags are <code>std::atomic</code>.</p>
|
||||
<div class="note">
|
||||
<p class="nt">Mental model</p>
|
||||
<p>Think of it as a tape recorder with a transcription button, not a live captioner. The architecture has no per-frame transcription loop at all — which, on a 2-core CPU, is the whole point.</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 4 -->
|
||||
<section id="decision">
|
||||
<div class="sec-h"><span class="sec-n">04</span><h2>The defining decision</h2></div>
|
||||
<p class="lead">The single most important thing to understand: this app was rebuilt from a live-streaming design into a push-to-talk batch design — and that was the right call.</p>
|
||||
<p>An earlier version used the classic whisper.cpp streaming approach: a rolling 5–6 second window re-transcribed every ~0.4 seconds. That technique <em>assumes</em> spare cores. On the target machine — an Intel i5-7th-gen with two physical cores — the buffer backlogged, audio was re-transcribed, and the UI starved. The symptom looked like "the model is slow"; the real cause was an architecture that needed hardware the target didn't have.</p>
|
||||
<p>The fix wasn't a faster model. It was removing the streaming loop entirely:</p>
|
||||
<table class="tbl">
|
||||
<tr><th>Aspect</th><th>Old: streaming window</th><th>New: push-to-talk batch</th></tr>
|
||||
<tr><td>CPU while speaking</td><td class="r">Pinned — constant re-inference</td><td>Near idle — just buffering</td></tr>
|
||||
<tr><td>Inference calls</td><td class="r">Many per second</td><td>Exactly one, on stop</td></tr>
|
||||
<tr><td>Accuracy</td><td class="r">Lower — partial context windows</td><td>Higher — full clip, full context</td></tr>
|
||||
<tr><td>UI responsiveness</td><td class="r">Starved under load</td><td>Free until the single pass</td></tr>
|
||||
<tr><td>Predictability</td><td class="r">Variable lag</td><td>Predictable few-second wait</td></tr>
|
||||
</table>
|
||||
<p>This is textbook root-cause engineering: the team correctly diagnosed that the bottleneck was the <em>shape</em> of the work, not its size, and changed the shape. Everything else in the codebase — the batch worker, the progress estimator, the physical-core thread default — follows from this one decision.</p>
|
||||
</section>
|
||||
|
||||
<!-- 5 -->
|
||||
<section id="threads">
|
||||
<div class="sec-h"><span class="sec-n">05</span><h2>Threading model</h2></div>
|
||||
<p class="lead">Four threads, one rule: only the UI thread touches the UI. Everything else reports back by message.</p>
|
||||
<table class="tbl">
|
||||
<tr><th>Thread</th><th>Lifetime</th><th>Job</th></tr>
|
||||
<tr><td><b>UI thread</b></td><td class="r">Whole app</td><td>Message loop, all painting, the 16 ms animation timer and 50 ms update timer.</td></tr>
|
||||
<tr><td><b>Model preload</b></td><td class="r">Detached, once</td><td>Loads the Whisper context off the UI thread at startup so the window appears instantly.</td></tr>
|
||||
<tr><td><b>Transcribe worker</b></td><td class="r">Per clip</td><td>Runs <code>whisper_full</code>; posts <code>WM_APP_PROGRESS</code> during and <code>WM_APP_RESULT</code> when done.</td></tr>
|
||||
<tr><td><b>Downloader</b></td><td class="r">Per download</td><td>WinHTTP fetch on its own thread; posts <code>WM_APP_DLPROGRESS</code>.</td></tr>
|
||||
</table>
|
||||
<p>Cross-thread state is handled with discipline rather than locks where possible: <code>std::atomic</code> booleans (<code>m_recording</code>, <code>m_busy</code>, <code>m_abort</code>, <code>g_modelLoaded</code>, <code>g_modelOk</code>) gate state transitions, and the only shared buffer — the captured PCM — is protected by a dedicated mutex. The audio callback (driven by SDL's own thread) appends under that mutex; <code>stop_and_transcribe</code> swaps the buffer out under the same lock before handing it to the worker. That swap-not-copy handoff is a nice touch.</p>
|
||||
<pre><span class="c">// transcriber.cpp — physical cores, not logical, by design</span>
|
||||
<span class="k">int</span> Transcriber::<span class="f">default_threads</span>() {
|
||||
<span class="k">unsigned</span> hc = std::thread::<span class="f">hardware_concurrency</span>();
|
||||
<span class="k">if</span> (hc <= 2) <span class="k">return</span> (<span class="k">int</span>)std::<span class="f">max</span>(1u, hc);
|
||||
<span class="k">return</span> (<span class="k">int</span>)(hc / 2); <span class="c">// 4 logical → 2 worker threads</span>
|
||||
}</pre>
|
||||
<p>Defaulting to physical cores rather than <code>hardware_concurrency()</code> is the correct choice for compute-bound SIMD inference — hyperthreads contend for the same execution units and would only add scheduling overhead.</p>
|
||||
</section>
|
||||
|
||||
<!-- 6 -->
|
||||
<section id="map">
|
||||
<div class="sec-h"><span class="sec-n">06</span><h2>Source map, file by file</h2></div>
|
||||
<p class="lead">The app is small and mostly header-only outside the two big translation units. Here's where everything lives.</p>
|
||||
<table class="tbl">
|
||||
<tr><th>File</th><th>Role</th><th>Notes</th></tr>
|
||||
<tr><td><code>main.cpp</code></td><td>Window, painting, interaction, settings view, clipboard, paste, model selection, popups</td><td class="r">~1,500 lines. The monolith — see §13.</td></tr>
|
||||
<tr><td><code>transcriber.{h,cpp}</code></td><td>SDL capture, Whisper preload/inference, progress & abort callbacks</td><td class="r">Clean, well-scoped class. The model layer.</td></tr>
|
||||
<tr><td><code>timing.h</code></td><td>Per-model least-squares timing model + live progress estimator + INI persistence</td><td class="r">The standout module. See §08.</td></tr>
|
||||
<tr><td><code>history.h</code></td><td>Session text files, UTF-8 r/w with BOM, index, pruning to 100</td><td class="r">Self-contained, header-only.</td></tr>
|
||||
<tr><td><code>downloader.h</code></td><td>WinHTTP model downloader on a background thread</td><td class="r">.part + atomic rename, cancel, proxy-aware.</td></tr>
|
||||
<tr><td><code>stats.h</code></td><td>Lifetime usage totals + derived figures (wpm, real-time factor, time saved)</td><td class="r">INI-backed, header-only.</td></tr>
|
||||
<tr><td><code>settings.h</code></td><td>App settings read/write via <code>GetPrivateProfile*</code></td><td class="r">Simple and transparent.</td></tr>
|
||||
<tr><td><code>text_util.h</code> · <code>logging.h</code></td><td>Transcript concatenation; timestamped file log</td><td class="r">Tiny helpers.</td></tr>
|
||||
<tr><td><code>tests/test_core.cpp</code></td><td>Unit checks: append logic, bad-model handling, real-WAV transcription, progress monotonicity</td><td class="r">Modest but meaningful. Built as <code>test-core</code>.</td></tr>
|
||||
</table>
|
||||
<p>The decision to make most subsystems <strong>header-only and independent</strong> (<code>timing.h</code>, <code>stats.h</code>, <code>history.h</code>, <code>downloader.h</code>, <code>settings.h</code>) is a good one for a project this size: each is cohesive, individually readable, and free of cross-dependencies. The contrast with <code>main.cpp</code> — which absorbs everything else — is stark.</p>
|
||||
</section>
|
||||
|
||||
<!-- 7 -->
|
||||
<section id="ui">
|
||||
<div class="sec-h"><span class="sec-n">07</span><h2>Deep dive: the single-surface UI engine</h2></div>
|
||||
<p class="lead">There are no buttons. Everything you see is painted onto one double-buffered surface — and that's a deliberate fix, not a shortcut.</p>
|
||||
<p>The previous UI composited around nine separate themed child windows (buttons, statics, an edit). That produced thin hairline seams around every control — the hard-edged holes <code>WS_CLIPCHILDREN</code> punches per child, plus the edit's themed border. Rather than chase pixel borders, the rebuild eliminated the cause: <strong>collapse the controls into one painted region.</strong></p>
|
||||
<p>The model is a small immediate-mode system:</p>
|
||||
<ul>
|
||||
<li>A flat <code>Widget g_w[]</code> array — each entry is a <em>kind</em>, a rectangle, and <code>hover/pressed/anim</code> state. No HWNDs.</li>
|
||||
<li><code>LayoutWidgets()</code> positions them; <code>PaintSurface()</code> draws each into an off-screen DC with GDI+, then blits once (no flicker).</li>
|
||||
<li><code>HitTest()</code> maps a click point to a widget; <code>OnClick()</code> dispatches the action.</li>
|
||||
<li>An animation clock eases each widget's <code>anim</code> toward a target (hover 0.6, active 1.0) on a 16 ms timer that <em>stops itself</em> when nothing is moving — no idle CPU burn.</li>
|
||||
</ul>
|
||||
<p>Two "views" — Main and Settings — render onto the same surface, toggled by <code>SwitchView()</code>. Dropdowns (mic, history) are the one exception: they're real top-level <code>WS_POPUP</code> windows, because a surface-painted dropdown would render <em>behind</em> the transcript edit (a child HWND always paints above its parent's surface). That's a correct, well-reasoned exception.</p>
|
||||
<div class="note good">
|
||||
<p class="nt">A sign of maturity</p>
|
||||
<p>The popup code carries a comment never to open a <code>MessageBox</code> from inside it — because <code>WA_INACTIVE</code> self-destroys the popup mid-handler, causing a use-after-free. Recognising that class of Win32 lifetime bug, and the GDI+ "<code>GetHDC</code> locks the Graphics object" trap documented elsewhere, shows real depth.</p>
|
||||
</div>
|
||||
<p>The one real child window that survives is the transcript <code>EDIT</code> — kept because a hand-rolled text editor with selection, scrolling, IME and undo is genuinely not worth rebuilding. Pragmatic.</p>
|
||||
<h3>The cost of this approach</h3>
|
||||
<p>Custom-painted controls are invisible to screen readers and UI Automation, and the app explicitly hides focus rectangles. The transcript box is accessible; the buttons are not. For a personal productivity tool this is a defensible trade, but it's the kind of thing worth stating out loud.</p>
|
||||
</section>
|
||||
|
||||
<!-- 8 -->
|
||||
<section id="timing">
|
||||
<div class="sec-h"><span class="sec-n">08</span><h2>Deep dive: the progress estimator</h2></div>
|
||||
<p class="lead">The crown jewel. Most apps fake a progress bar; this one runs a small statistical model that learns your machine.</p>
|
||||
<p>Whisper only reports coarse progress (per 30-second chunk), so a naive bar jumps — 0, 34, 72, 100 — and a naive "time left" computed from stale percentages actually counts <em>up</em>. <code>timing.h</code> solves both. It has two parts.</p>
|
||||
<h3>1 — A learned timing model</h3>
|
||||
<p>Processing time is modelled as a linear function of audio length, <code>proc = a + b·audio</code>, fitted by <strong>decayed online least-squares</strong>. Each completed transcription feeds back a real sample; older samples decay (factor 0.97) so the model tracks the current machine state. Defaults are seeded per model family (tiny/base/small) so even the very first clip has a sane estimate, and the accumulators persist per-model in the INI.</p>
|
||||
<pre><span class="k">void</span> <span class="f">add_sample</span>(<span class="k">double</span> audio_sec, <span class="k">double</span> proc_sec) {
|
||||
<span class="k">const double</span> decay = <span class="n">0.97</span>;
|
||||
n*=decay; sx*=decay; sy*=decay; sxx*=decay; sxy*=decay;
|
||||
n+=<span class="n">1</span>; sx+=audio_sec; sy+=proc_sec;
|
||||
sxx+=audio_sec*audio_sec; sxy+=audio_sec*proc_sec;
|
||||
<span class="f">recompute</span>(); <span class="c">// closed-form slope/intercept</span>
|
||||
}</pre>
|
||||
<h3>2 — A live estimator that only counts down</h3>
|
||||
<p>On stop, <code>begin(predict)</code> seeds a predicted total. As Whisper reports chunk progress, <code>on_whisper()</code> folds it in as a <em>measurement</em> via an EMA (α = 0.5) — nudging the estimate without the jumpy jumps. Meanwhile <code>tick()</code> advances a displayed "remaining" value that is <strong>strictly monotonic downward</strong>, with a clamped catch-up rate so it can speed up but never lurch backward, easing to 95% and snapping to 100% only on the real result.</p>
|
||||
<pre><span class="k">void</span> <span class="f">tick</span>(<span class="k">double</span> dt, <span class="k">float</span>& out_frac, <span class="k">float</span>& out_remaining) {
|
||||
t += dt; disp_rem -= dt;
|
||||
<span class="k">double</span> raw_rem = std::<span class="f">max</span>(<span class="n">0.0</span>, T_hat - t);
|
||||
<span class="k">double</span> err = raw_rem - disp_rem;
|
||||
<span class="k">if</span> (err < <span class="n">0</span>) disp_rem += std::<span class="f">max</span>(err, -maxCatchUp*dt); <span class="c">// catch up, never jump back</span>
|
||||
<span class="k">double</span> frac = t/(t+disp_rem);
|
||||
<span class="k">if</span> (frac > <span class="n">0.95</span>) frac = <span class="n">0.95</span>; <span class="c">// park at 95% until done</span>
|
||||
out_frac = (<span class="k">float</span>)frac; out_remaining = (<span class="k">float</span>)disp_rem;
|
||||
}</pre>
|
||||
<p>This is more thought than most commercial apps put into a progress bar, and the test suite even asserts the progress is non-decreasing. It's the clearest signal in the codebase that someone cared about the <em>feel</em> of the product, not just its function.</p>
|
||||
</section>
|
||||
|
||||
<!-- 9 -->
|
||||
<section id="transcriber">
|
||||
<div class="sec-h"><span class="sec-n">09</span><h2>Deep dive: the transcriber</h2></div>
|
||||
<p class="lead">The cleanest class in the project — a tidy boundary between the OS/model and the rest of the app.</p>
|
||||
<p><code>Transcriber</code> owns the Whisper context and the SDL device, and exposes a small, sensible surface: <code>preload</code>, <code>reload</code>, <code>start_recording</code>, <code>stop_and_transcribe</code>, <code>cancel</code>, plus state queries and two callbacks (<code>result</code>, <code>progress</code>). Inference parameters are configured sensibly for dictation — greedy sampling, no timestamps, no prior context, blank/non-speech suppression, temperature 0 — and an <code>abort_callback</code> lets a long transcription be cancelled mid-flight.</p>
|
||||
<p>Two small details worth calling out:</p>
|
||||
<ul>
|
||||
<li><strong>Silence trimming.</strong> Before inference, leading/trailing silence is trimmed from the clip — cheaper and more accurate than transcribing dead air. (Note: this trims the <em>buffer</em>; it does not auto-stop recording — see the doc-drift note in §13.)</li>
|
||||
<li><strong>Output cleanup.</strong> <code>clean_text()</code> strips Whisper's <code>[BLANK_AUDIO]</code> / <code>[NOISE]</code> artifacts and trims whitespace, so the user never sees model noise.</li>
|
||||
</ul>
|
||||
<p>The class is also defensively coded: a missing model file makes <code>preload</code> return false cleanly (the test suite verifies this), <code>start_recording</code> bails if a device won't open, and clips under ~0.3 s short-circuit to an empty result rather than invoking the model.</p>
|
||||
</section>
|
||||
|
||||
<!-- 10 -->
|
||||
<section id="persistence">
|
||||
<div class="sec-h"><span class="sec-n">10</span><h2>History, downloads & persistence</h2></div>
|
||||
<p class="lead">No database, no registry sprawl — everything is a file next to the executable. Transparent and portable.</p>
|
||||
<h3>Session history</h3>
|
||||
<p>Each session is one UTF-8 text file in <span class="path">history\</span>, named by timestamp. The clever bit is <em>live</em> archiving: the first clip of a session creates the file; subsequent clips rewrite the <em>same</em> file with the full text. So a session is always one tidy, crash-safe file — not a scatter of fragments — and it appears in the History popup immediately. A <code>g_sessionPath</code> global plus a <code>FinalizeSession()</code> helper handle the edge cases (manual edits, typed-only sessions, loading an old entry without resurrecting it). The list is capped at 100 with automatic pruning.</p>
|
||||
<div class="note">
|
||||
<p class="nt">A real bug was fixed here</p>
|
||||
<p>An earlier version stamped every fresh transcription as "loaded from history," so the duplicate-guard silently skipped archiving — sessions never reached disk while the UI claimed "Saved." The fix (live archiving + a corrected guard) is documented and shows the team chasing subtle state bugs to ground.</p>
|
||||
</div>
|
||||
<h3>Model downloads</h3>
|
||||
<p>The downloader is more robust than it needed to be, in a good way: it streams to a <code>.part</code> file then does an atomic rename on success (no half-files), honors the system proxy, follows the Hugging Face → CDN redirects, supports cancellation, allows only one download at a time, and sweeps up stray <code>.part</code> files at startup.</p>
|
||||
<h3>Settings, timing & stats</h3>
|
||||
<p>All three live in a single <span class="path">win-dictation.ini</span> under different sections — app settings, per-model timing accumulators, and lifetime stats. Using the OS's own <code>GetPrivateProfile*</code> API means zero parsing code and a file a user can read and edit by hand. For an app of this scope, that's exactly the right level of machinery.</p>
|
||||
</section>
|
||||
|
||||
<!-- 11 -->
|
||||
<section id="anatomy">
|
||||
<div class="sec-h"><span class="sec-n">11</span><h2>Anatomy of one dictation</h2></div>
|
||||
<p class="lead">Following a single clip end-to-end ties the whole system together.</p>
|
||||
<ol>
|
||||
<li><code>WM_HOTKEY</code> fires → the app records <code>g_prevForeground</code> and the current selection (<code>EM_GETSEL</code>) so it knows where to paste and where to insert.</li>
|
||||
<li><code>g_tx.start_recording()</code> opens the SDL device; the audio callback appends PCM under the capture mutex and updates the RMS energy meter.</li>
|
||||
<li>The 50 ms UI timer animates the level meter and ticks the on-screen recording clock.</li>
|
||||
<li>Second <code>WM_HOTKEY</code> → <code>g_est.begin(g_timing.predict(len))</code> seeds the progress estimate; <code>g_tx.stop_and_transcribe()</code> swaps the buffer to a worker thread.</li>
|
||||
<li>The worker runs <code>run_inference()</code> → <code>whisper_full</code>. Whisper's progress callback posts <code>WM_APP_PROGRESS</code>; the estimator's <code>on_whisper()</code> EMA-folds it in.</li>
|
||||
<li>On completion the worker posts <code>WM_APP_RESULT</code>.</li>
|
||||
<li>The UI thread then, in order: snaps progress to 100%, records a real timing sample (<code>add_sample</code> + <code>SaveTiming</code>), updates lifetime stats, inserts the text at the saved caret with smart spacing via <code>EM_REPLACESEL</code> (undoable), archives the session, copies to the clipboard, and pastes into <code>g_prevForeground</code>.</li>
|
||||
</ol>
|
||||
<p>Every piece of the architecture shows up in that one trip: the atomics, the message hand-back, the estimator, the learned timing feedback loop, the editable transcript, the live history. It's a coherent design.</p>
|
||||
</section>
|
||||
|
||||
<!-- 12 -->
|
||||
<section id="strengths">
|
||||
<div class="sec-h"><span class="sec-n">12</span><h2>What's done well</h2></div>
|
||||
<div class="assess">
|
||||
<div class="ac pos"><div class="ah"><span class="dot"></span><h4>The architecture fits the hardware</h4></div><p>Push-to-talk batch over streaming is the correct response to a 2-core CPU, reached by genuine root-cause analysis rather than knob-twiddling.</p></div>
|
||||
<div class="ac pos"><div class="ah"><span class="dot"></span><h4>The progress estimator is exceptional</h4></div><p>Decayed online least-squares + EMA fusion + a strictly monotonic countdown is far beyond what the task demanded — and it shows in the feel.</p></div>
|
||||
<div class="ac pos"><div class="ah"><span class="dot"></span><h4>Seam-free UI by elimination, not patching</h4></div><p>Collapsing nine child windows into one painted, double-buffered, DPI-aware, self-throttling surface removed the problem at its source.</p></div>
|
||||
<div class="ac pos"><div class="ah"><span class="dot"></span><h4>Clean module boundaries (outside main)</h4></div><p>Header-only, dependency-free subsystems (timing, history, downloader, stats, settings) are each individually readable and testable.</p></div>
|
||||
<div class="ac pos"><div class="ah"><span class="dot"></span><h4>Robustness in the right places</h4></div><p>Atomic rename downloads, crash-safe live history, graceful missing-model handling, cancellable inference, single-instance mutex, model preload off the UI thread.</p></div>
|
||||
<div class="ac pos"><div class="ah"><span class="dot"></span><h4>Real product thoughtfulness</h4></div><p>Smart insertion spacing, undoable edits, auto-paste into the prior window, auto-hide, learned timing, friendly stats. These are details a careful builder adds.</p></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 13 -->
|
||||
<section id="weaknesses">
|
||||
<div class="sec-h"><span class="sec-n">13</span><h2>What holds it back</h2></div>
|
||||
<p class="lead">All fixable, and none of it affects the running app. But it's exactly what a newcomer trips over.</p>
|
||||
<div class="assess">
|
||||
<div class="ac neu"><div class="ah"><span class="dot"></span><h4><code>main.cpp</code> is a 1,500-line god object</h4></div><p>UI, layout, painting, the entire settings screen, clipboard, paste mechanics, model selection, the popup window class, and stats formatting all live in one translation unit with dozens of globals. It works, but it's the hardest part of the codebase to onboard into. Splitting the settings view, the popup, and the painting helpers into their own files would pay for itself quickly.</p></div>
|
||||
<div class="ac neu"><div class="ah"><span class="dot"></span><h4>Vestigial child windows & duplicate code paths</h4></div><p>Startup still creates ~9 owner-draw child controls (record, pin, copy, paste, clear, two selects, two statics) and then immediately hides all but the transcript edit. Their dead <code>WM_COMMAND</code> handlers duplicate the painted-widget <code>OnClick</code> logic — e.g. the Copy action exists in two near-identical places. Leftovers from the rebuild that should be deleted.</p><p class="ref">main.cpp — CreateWindow(...) blocks then ShowWindow(..., SW_HIDE)</p></div>
|
||||
<div class="ac neg"><div class="ah"><span class="dot"></span><h4>Documentation describes a different app</h4></div><p>This is the most actively misleading issue. <code>CUDA-SETUP.md</code>, <code>QUICK-REBUILD-GPU.md</code> and <code>FIXES-APPLIED.md</code> describe a streaming, VAD, ring-buffer, 24-thread, RTX 3090 design that no longer exists. <code>build.ps1</code> still hunts for CUDA and downloads <code>base.en</code> though the product is a CPU-only <code>tiny.en</code> app. <code>TESTING.md</code> references a <code>test-audio.exe</code> the CMake doesn't build (it builds <code>test-core</code>). A newcomer reading the docs would form a completely wrong mental model.</p></div>
|
||||
<div class="ac neg"><div class="ah"><span class="dot"></span><h4>The README claims a feature that isn't there</h4></div><p>Both <code>README.md</code> and <code>CHANGES.md</code> describe a "500 ms silence auto-end timer." The recording loop has no such logic — it only auto-stops at the 10-minute safety cap. (Silence is <em>trimmed</em> before inference, which is likely the source of the confusion.) Either implement it or remove the claim.</p><p class="ref">main.cpp WM_TIMER recording branch vs README "Audio Processing"</p></div>
|
||||
<div class="ac neu"><div class="ah"><span class="dot"></span><h4>Heavy reliance on global mutable state</h4></div><p>The UI is coordinated through dozens of file-scope globals (<code>g_*</code>), a mix of atomics and plain values. It's manageable at this size and the threading is disciplined, but it makes the code hard to reason about in isolation and easy to break with a careless edit.</p></div>
|
||||
<div class="ac neu"><div class="ah"><span class="dot"></span><h4>Build declares C++11 but uses C++17</h4></div><p><code>CMakeLists.txt</code> sets <code>CMAKE_CXX_STANDARD 11</code>, yet the code uses <code>std::size()</code> (C++17). It compiles only because MSVC's default is newer. Set the standard to 17 explicitly so the build is honest and portable.</p></div>
|
||||
<div class="ac neu"><div class="ah"><span class="dot"></span><h4>Minor: redundant color systems & no in-app hotkey editor</h4></div><p>Three overlapping palettes coexist (<code>CR_*</code> COLORREF, <code>T_*</code> GDI+ Color, <code>C_*</code> aliases). And changing the hotkey requires hand-editing the INI — a natural gap given the polished Settings screen already exists.</p></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 14 -->
|
||||
<section id="recs">
|
||||
<div class="sec-h"><span class="sec-n">14</span><h2>Recommendations</h2></div>
|
||||
<p class="lead">If the next session had a short to-do list, this would be it — ordered by payoff for effort.</p>
|
||||
<ol class="rec">
|
||||
<li><h4>Purge or archive the stale docs <span class="pri hi">high</span></h4><p>Delete or clearly mark <code>CUDA-SETUP.md</code>, <code>QUICK-REBUILD-GPU.md</code>, <code>FIXES-APPLIED.md</code>, <code>TESTING.md</code> and <code>DESIGN.md</code> as describing the retired streaming design. This is the single biggest improvement to onboarding, and it's nearly free.</p></li>
|
||||
<li><h4>Reconcile the README with reality <span class="pri hi">high</span></h4><p>Remove the "500 ms silence auto-end" claim (or implement it). Update the model table and build commands to match the CPU-only product.</p></li>
|
||||
<li><h4>Delete the vestigial child windows <span class="pri md">medium</span></h4><p>Remove the hidden owner-draw controls and their dead <code>WM_COMMAND</code> handlers so there's exactly one code path per action. De-duplicate Copy.</p></li>
|
||||
<li><h4>Break up <code>main.cpp</code> <span class="pri md">medium</span></h4><p>Lift the Settings view, the popup window, and the GDI+ drawing helpers into their own files. Even a mechanical split dramatically improves navigability.</p></li>
|
||||
<li><h4>Fix the build standard & align <code>build.ps1</code> <span class="pri md">medium</span></h4><p>Set <code>CMAKE_CXX_STANDARD 17</code>. Strip the CUDA detection from the build script and default it to fetching <code>tiny.en</code>.</p></li>
|
||||
<li><h4>Add an in-app hotkey picker <span class="pri lo">low</span></h4><p>The Settings surface already exists; surfacing the hotkey there closes an obvious UX gap and removes a troubleshooting step.</p></li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<!-- 15 -->
|
||||
<section id="scorecard">
|
||||
<div class="sec-h"><span class="sec-n">15</span><h2>Scorecard & final word</h2></div>
|
||||
<div class="score">
|
||||
<div class="srow"><span class="sl">Architecture & design</span><span class="sb"><span class="sf hi" style="width:92%"></span></span><span class="sv">9.2</span></div>
|
||||
<div class="srow"><span class="sl">Performance fit for target</span><span class="sb"><span class="sf hi" style="width:93%"></span></span><span class="sv">9.3</span></div>
|
||||
<div class="srow"><span class="sl">UX & polish</span><span class="sb"><span class="sf hi" style="width:87%"></span></span><span class="sv">8.7</span></div>
|
||||
<div class="srow"><span class="sl">Robustness & error handling</span><span class="sb"><span class="sf" style="width:75%"></span></span><span class="sv">7.5</span></div>
|
||||
<div class="srow"><span class="sl">Code organization</span><span class="sb"><span class="sf lo" style="width:55%"></span></span><span class="sv">5.5</span></div>
|
||||
<div class="srow"><span class="sl">Maintainability</span><span class="sb"><span class="sf lo" style="width:58%"></span></span><span class="sv">5.8</span></div>
|
||||
<div class="srow"><span class="sl">Testing</span><span class="sb"><span class="sf lo" style="width:48%"></span></span><span class="sv">4.8</span></div>
|
||||
<div class="srow"><span class="sl">Documentation accuracy</span><span class="sb"><span class="sf vlo" style="width:38%"></span></span><span class="sv">3.8</span></div>
|
||||
<div class="overall"><span class="num">7.1</span><span class="ot"><strong style="color:var(--text)">Strong, with cleanup debt.</strong><br>An impressive core wrapped in organizational and documentation drift. The engineering earns a high mark; the housekeeping pulls the average down.</span></div>
|
||||
</div>
|
||||
<div class="verdict" style="margin-top:30px">
|
||||
<p class="vh">Final word</p>
|
||||
<p>Win Dictation is a <strong>good codebase — at its core, an impressive one</strong>. The architectural judgement (batch over streaming), the standout progress estimator, and the seam-free renderer are the work of someone who diagnoses root causes and cares about how software feels. Those are the hard parts, and they're done right.</p>
|
||||
<p>What separates it from "great" is entirely recoverable: a monolithic main file, dead code from a prior design, and documentation that actively describes a different application. A focused day of cleanup — most of it deletion — would lift this from "strong for its niche" to "exemplary small-app code." The good news for anyone inheriting it: the bones are excellent, and the to-do list is short.</p>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<b>Win Dictation — Architecture & Engineering Review</b><br>
|
||||
Native Win32 C++ · GDI+ · SDL2 · whisper.cpp · CPU-only · target Intel i5-7th-gen (2C/4T)<br>
|
||||
Assessment based on a full read of the current source tree.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape' && window.parent !== window) {
|
||||
window.parent.postMessage({ type: 'close-fullscreen' }, '*');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<!-- broken-img-handler -->
|
||||
<script>
|
||||
(function(){
|
||||
if(window.__brokenImgHandler)return;
|
||||
window.__brokenImgHandler=true;
|
||||
var MAX=5,DELAYS=[2000,4000,8000,16000,32000];
|
||||
document.addEventListener('error',function(e){
|
||||
var img=e.target;
|
||||
if(!img||img.tagName!=='IMG')return;
|
||||
var liveSrc=img.getAttribute('src');
|
||||
var src=img.dataset.haOriginalSrc||liveSrc;
|
||||
if(!src)return;
|
||||
if(img.dataset.haOriginalSrc&&liveSrc&&liveSrc!==img.dataset.haOriginalSrc&&liveSrc.indexOf('_r=')<0){src=liveSrc;img.dataset.haOriginalSrc=src;img.dataset.haRetryCount='0'}
|
||||
else if(!img.dataset.haOriginalSrc){img.dataset.haOriginalSrc=src}
|
||||
var attempt=parseInt(img.dataset.haRetryCount||'0',10);
|
||||
if(img.dataset.haPhId){var old=document.getElementById(img.dataset.haPhId);if(old)old.remove()}
|
||||
var ph=document.createElement('div');
|
||||
ph.className='ha-img-placeholder'+(attempt>=MAX?' ha-failed':'');
|
||||
ph.id='ha-ph-'+Math.random().toString(36).slice(2,9);
|
||||
var w=img.getAttribute('width');var h=img.getAttribute('height');
|
||||
if(w)ph.style.width=w+(isNaN(Number(w))?'':'px');
|
||||
else if(img.style.width)ph.style.width=img.style.width;
|
||||
else if(img.width>1)ph.style.width=img.width+'px';
|
||||
if(h)ph.style.height=h+(isNaN(Number(h))?'':'px');
|
||||
else if(img.style.height)ph.style.height=img.style.height;
|
||||
else if(img.height>1)ph.style.height=img.height+'px';
|
||||
ph.textContent=attempt>=MAX?'Image unavailable':'Loading image\u2026';
|
||||
img.dataset.haPhId=ph.id;
|
||||
if(img.dataset.haOrigDisplay==null)img.dataset.haOrigDisplay=img.style.display||'';
|
||||
img.style.display='none';
|
||||
img.insertAdjacentElement('afterend',ph);
|
||||
if(attempt<MAX){
|
||||
img.dataset.haRetryCount=String(attempt+1);
|
||||
setTimeout(function(){
|
||||
if(!img.isConnected)return;
|
||||
if(img.dataset.haOriginalSrc!==src)return;
|
||||
if(img.complete&&img.naturalWidth>0)return;
|
||||
var curSrc=img.getAttribute('src');
|
||||
if(curSrc&&curSrc.indexOf(src)!==0)return;
|
||||
var fresh=src+(src.indexOf('?')>=0?'&':'?')+'_r='+(attempt+1)+'_'+Date.now();
|
||||
img.src=fresh;
|
||||
},DELAYS[attempt]);
|
||||
}
|
||||
},true);
|
||||
document.addEventListener('load',function(e){
|
||||
var img=e.target;
|
||||
if(!img||img.tagName!=='IMG')return;
|
||||
if(img.dataset.haPhId){
|
||||
var ph=document.getElementById(img.dataset.haPhId);
|
||||
if(ph)ph.remove();
|
||||
delete img.dataset.haPhId;
|
||||
img.style.display=img.dataset.haOrigDisplay||'';
|
||||
delete img.dataset.haOrigDisplay;
|
||||
delete img.dataset.haOriginalSrc;
|
||||
delete img.dataset.haRetryCount;
|
||||
}
|
||||
},true);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user