From a94ba824d64e534d4bebdb9ba63e6573af69cb23 Mon Sep 17 00:00:00 2001 From: Win Dictation Dev Date: Thu, 11 Jun 2026 20:52:24 +1200 Subject: [PATCH] Docs refresh: add user manual & architecture review; update README with accurate details --- Architechture-and-dev-guide.md | 411 ------------- README.md | 103 ++-- .../FINDINGS-FIXES-TESTS.md | 0 .../FINDINGS-FIXES-TESTS2.md | 0 .../UI-and-progress-bar-rebuild-part-2.md | 0 .../UI-and-progress-bar-rebuild-part-3.md | 0 .../UI-and-progress-bar-rebuild.md | 0 .../Win-Dictation-features-01.md | 0 .../bug-fixes-and-visual-upgrade.md | 0 .../dev-task-list.md | 0 .../fix-history-dropdown.md | 0 old_text_files/hisory-delete-instructions.md | 366 +++++++++++ .../history-not-populating-fix.md | 0 .../popup-width-fix.md | 0 ...-rebuild-spec-fast-compact-push-to-talk.md | 0 screenshot.png | Bin 43602 -> 0 bytes src/main.cpp | 108 +++- ...ation-architecture-engineering-review.html | 520 ++++++++++++++++ win-dictation-user-manual.html | 567 ++++++++++++++++++ 19 files changed, 1609 insertions(+), 466 deletions(-) delete mode 100644 Architechture-and-dev-guide.md rename FINDINGS-FIXES-TESTS.md => old_text_files/FINDINGS-FIXES-TESTS.md (100%) rename FINDINGS-FIXES-TESTS2.md => old_text_files/FINDINGS-FIXES-TESTS2.md (100%) rename UI-and-progress-bar-rebuild-part-2.md => old_text_files/UI-and-progress-bar-rebuild-part-2.md (100%) rename UI-and-progress-bar-rebuild-part-3.md => old_text_files/UI-and-progress-bar-rebuild-part-3.md (100%) rename UI-and-progress-bar-rebuild.md => old_text_files/UI-and-progress-bar-rebuild.md (100%) rename Win-Dictation-features-01.md => old_text_files/Win-Dictation-features-01.md (100%) rename bug-fixes-and-visual-upgrade.md => old_text_files/bug-fixes-and-visual-upgrade.md (100%) rename dev-task-list.md => old_text_files/dev-task-list.md (100%) rename fix-history-dropdown.md => old_text_files/fix-history-dropdown.md (100%) create mode 100644 old_text_files/hisory-delete-instructions.md rename history-not-populating-fix.md => old_text_files/history-not-populating-fix.md (100%) rename popup-width-fix.md => old_text_files/popup-width-fix.md (100%) rename win-dictation-2-0-rebuild-spec-fast-compact-push-to-talk.md => old_text_files/win-dictation-2-0-rebuild-spec-fast-compact-push-to-talk.md (100%) delete mode 100644 screenshot.png create mode 100644 win-dictation-architecture-engineering-review.html create mode 100644 win-dictation-user-manual.html diff --git a/Architechture-and-dev-guide.md b/Architechture-and-dev-guide.md deleted file mode 100644 index 1fb4919..0000000 --- a/Architechture-and-dev-guide.md +++ /dev/null @@ -1,411 +0,0 @@ -# Win Dictation — Architecture Analysis & Dev Guide (Build 4) - -Two parts: - -- **Part A — Architecture analysis & recommendations.** Where the app stands now (post-fixes) and what's worth hardening. -- **Part B — Dev guide** for the two things you asked for: (1) removing the leftover Windows chrome (combo dropdown buttons, button hairlines, the line around *Pinned*), and (2) showing real transcription progress + a time estimate instead of a static "Transcribing…". - -Context: native C++ / Win32 + SDL2 + whisper.cpp, CPU-only (i5-7th-gen, 2c/4t). Companion docs: `MODERN-UI-AND-FIXES.md`, `FINDINGS-FIXES-TESTS.md`. - ---- - -# Part A — Architecture Analysis & Recommendations - -## A1. Current architecture (it's in good shape) - -``` -┌── UI thread (message loop) ───────────────┐ ┌── Audio thread (SDL callback) ──┐ -│ • window, hotkeys, tray, GDI+ paint │ │ • append f32 samples to │ -│ • owns Transcriber │◀────│ m_capture (mutex) │ -│ • marshals worker results via PostMessage│ │ • update VU energy (atomic) │ -└──────────────┬────────────────────────────┘ └─────────────────────────────────┘ - │ stop_and_transcribe() - ▼ -┌── Worker thread (one per utterance) ──────┐ -│ • run_inference(): whisper_full() ONCE │ -│ • PostMessage(WM_APP_RESULT, text) │ -└────────────────────────────────────────────┘ -``` - -State machine: **Idle → Recording → Transcribing → Idle**, with the model preloaded on a detached thread at startup. - -**What's genuinely good now:** -- **Clean thread boundaries.** Audio capture, inference, and UI never block each other; all cross-thread hand-offs are atomics or `PostMessage`. This is the right shape. -- **Batch (record-then-transcribe).** The correct model for dictation on a slow CPU — no real-time deadline, latency independent of clip length. -- **Core is decoupled and unit-testable** (`Transcriber` + `run_inference`/`transcribe_sync`, `text_util.h`). The UI is a thin shell over it. -- **Robust startup** (single-instance, honest `g_modelOk`, `g_initializing` guard, `m_cfg_mtx`) — the earlier crashes are designed out, not patched over. - -The remaining issues are **polish and hardening**, not structural. No rewrite needed. - -## A2. Recommendations (ranked by impact ÷ effort) - -| # | Recommendation | Why | Effort | -|---|---|---|---| -| 1 | **Transcription progress + ETA** (Part B2) | The #1 UX gap: a 1:40 clip shows a static "Transcribing…" with no sign of life. whisper.cpp already exposes a progress callback — wire it up. | S | -| 2 | **De-theme the stock controls** (Part B1.1) | The hairlines around the buttons / *Pinned* are themed-edge leftovers. `SetWindowTheme(h, L"", L"")` + `WS_CLIPCHILDREN` + hide-focus removes them. | S | -| 3 | **Replace the comboboxes with custom dropdowns** (Part B1.2) | A `CBS_OWNERDRAWFIXED` combo *cannot* hide its native dropdown button — that's the "second arrow" you see. The only clean fix is to not use a combobox. | M | -| 4 | **Persist settings** | Mic, model, pin, auto-paste, window position all reset every launch. A tiny INI (`WritePrivateProfileStringW`) or registry blob fixes it. | S | -| 5 | **Cancel/abort during transcription** | Pairs with #1 — if a long clip is wrong, let the user abort via `whisper_full_params.abort_callback`. | S | -| 6 | **Delete the stale `src/CMakeLists.txt`** | It references removed APIs (`init`, `is_using_gpu`) and a `test-audio` target the root build ignores. It's a trap for the next contributor. | XS | -| 7 | **Bound the capture buffer** | `m_capture` grows ~1.9 MB/30 s with no cap. Add a soft limit (e.g. auto-stop at 10 min) so a forgotten recording can't grow unbounded. | XS | -| 8 | **Configurable hotkeys + conflict check** | `Ctrl+Shift+Space`/`H` are hard-coded; `RegisterHotKey` failures are silently ignored. Surface a warning and allow remap. | M | -| 9 | **Lightweight logging** | A single rotating log line per session (model, threads, last error) makes field issues diagnosable without a debugger. | S | - -**Architectural note for the future:** the app leans on owner-drawing *stock* controls (buttons, combos). That's fine at this size, but every stock control fights you on chrome (edges, focus cues, dropdown buttons). If the UI grows, the higher-leverage move is a small set of **fully custom controls** (a `Button`, a `Select`, a `ProgressBar` you paint entirely in `WM_PAINT` and hit-test yourself) rather than more owner-draw patches. Part B1.2's custom dropdown is the first step down that path. - ---- - -# Part B — Dev Guide - -## B1. Remove the leftover Windows chrome - -There are **three** separate sources of "Windows-y" pixels, each with a different cause: - -| What you see | Cause | -|---|---| -| Thin light line around *Pinned*; vertical line left + horizontal line top of Copy/Paste/Clear | The visual-style **themed edge** drawn behind owner-draw buttons, plus **focus rectangles** | -| Two arrows / a boxy button on the mic + model selectors | A `CBS_OWNERDRAWFIXED` combo still lets the **system draw the dropdown button** and field border — owner-draw only covers the text/items | - -### B1.1 Kill the button hairlines + focus rectangles (quick, high-impact) - -Three changes, all small: - -**(a) De-theme the owner-draw controls.** `SetWindowTheme(h, L"", L"")` strips the UxTheme styling from a control so Windows stops painting its themed border/edge behind your `WM_DRAWITEM`. Add the header/lib and call it on every owner-draw control right after you create it: - -```cpp -#include -#pragma comment(lib, "uxtheme.lib") - -// after creating each owner-draw button (Record, Pin, Copy, Paste, Clear): -SetWindowTheme(hBtn, L"", L""); // remove themed edges -SetWindowSubclass(hBtn, BtnProc, 1, 0); -``` - -**(b) Stop the parent painting under the children.** Add `WS_CLIPCHILDREN` to the main window so its double-buffered `WM_PAINT` never bleeds a pixel into a child's rectangle: - -```cpp -hMainWnd = CreateWindowExW( - WS_EX_TOPMOST, - L"WhisperDictationClass", L"Dictation", - WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, // <- add WS_CLIPCHILDREN - CW_USEDEFAULT, CW_USEDEFAULT, 400, 340, - nullptr, nullptr, hInstance, nullptr); -``` - -**(c) Hide focus rectangles app-wide.** The dotted/thin rect that appears on whichever control has keyboard focus (often *Pinned* after you click it). Tell the UI-state machine to keep focus cues hidden — once, after the controls exist: - -```cpp -SendMessageW(hMainWnd, WM_CHANGEUISTATE, MAKEWPARAM(UIS_SET, UISF_HIDEFOCUS), 0); -``` - -After (a)+(b)+(c), the only remaining stock chrome is the combo dropdown button, handled next. - -### B1.2 Replace the comboboxes with a custom dropdown (removes the native button) - -A combobox always owns its dropdown button — you can't draw it away. Replace each combo with a **flat owner-draw "select" button** (you already draw exactly this look in `DrawCombo`) that opens a **custom dark popup window**. No native button, no field edge, fully on-theme. - -**Data model** (replace `g_modelComboPaths` usage as needed; keep a label list + selection per selector): - -```cpp -std::vector g_audioItems; int g_audioSel = 0; -std::vector g_modelItems; int g_modelSel = 0; // parallel to g_modelComboPaths -``` -Populate these in `RefreshAudioDevices` / `RefreshModelList` instead of `CB_ADDSTRING`. Create `ID_SEL_AUDIO` / `ID_SEL_MODEL` as `BS_OWNERDRAW` buttons (not comboboxes) and draw them with a field renderer: - -```cpp -void DrawSelect(LPDRAWITEMSTRUCT d, const std::wstring& text) { - Graphics g(d->hDC); g.SetSmoothingMode(SmoothingModeAntiAlias); - Rect rc(d->rcItem.left, d->rcItem.top, d->rcItem.right-d->rcItem.left, d->rcItem.bottom-d->rcItem.top); - SolidBrush bg(C_BG); g.FillRectangle(&bg, rc); - Rect field = rc; field.Inflate(-1,-1); - bool hover = GetWindowLongPtr(d->hwndItem, GWLP_USERDATA) != 0; - FillRound(g, hover ? C_SURFACEHI : C_SURFACE, field, 9); - StrokeRound(g, C_BORDER, field, 9, 1.0f); - Font f(d->hDC, g_fUI); - RectF tb((REAL)field.X+10, (REAL)field.Y, (REAL)(field.Width-28), (REAL)field.Height); - DrawTextC(g, text.c_str(), f, C_TEXT, tb, StringAlignmentNear, StringAlignmentCenter); - int cx = field.GetRight()-16, cy = field.Y + field.Height/2; // our chevron, the only one now - Pen pen(C_TEXTDIM, 1.6f); - g.DrawLine(&pen, cx-4, cy-2, cx, cy+2); g.DrawLine(&pen, cx, cy+2, cx+4, cy-2); -} -// in WM_DRAWITEM: -// case ID_SEL_AUDIO: DrawSelect(d, g_audioItems.empty()?L"No devices":g_audioItems[g_audioSel]); return TRUE; -// case ID_SEL_MODEL: DrawSelect(d, g_modelItems.empty()?L"—":g_modelItems[g_modelSel]); return TRUE; -``` - -**The popup window** — a small borderless top-level you paint yourself; closes on pick or focus loss: - -```cpp -struct PopupState { std::vector items; int sel; int hot; HWND owner; int ctrlId; }; -static PopupState g_pop; - -LRESULT CALLBACK PopupProc(HWND h, UINT m, WPARAM w, LPARAM l) { - switch (m) { - case WM_MOUSEMOVE: { - int row = GET_Y_LPARAM(l) / 30; - if (row != g_pop.hot) { g_pop.hot = row; InvalidateRect(h, nullptr, FALSE); } - TRACKMOUSEEVENT t{ sizeof(t), TME_LEAVE, h, 0 }; TrackMouseEvent(&t); - return 0; - } - case WM_MOUSELEAVE: g_pop.hot = -1; InvalidateRect(h, nullptr, FALSE); return 0; - case WM_LBUTTONUP: { - int row = GET_Y_LPARAM(l) / 30; - if (row >= 0 && row < (int)g_pop.items.size()) - PostMessageW(g_pop.owner, WM_APP_SELECT, (WPARAM)g_pop.ctrlId, (LPARAM)row); - DestroyWindow(h); return 0; - } - case WM_KILLFOCUS: DestroyWindow(h); return 0; - case WM_ERASEBKGND: return 1; - case WM_PAINT: { - PAINTSTRUCT ps; HDC hdc = BeginPaint(h, &ps); - RECT rc; GetClientRect(h, &rc); - HDC mem = CreateCompatibleDC(hdc); - HBITMAP bmp = CreateCompatibleBitmap(hdc, rc.right, rc.bottom); - HBITMAP old = (HBITMAP)SelectObject(mem, bmp); - { - Graphics g(mem); g.SetSmoothingMode(SmoothingModeAntiAlias); - Rect all(0,0,rc.right,rc.bottom); - FillRound(g, C_SURFACE, all, 10); StrokeRound(g, C_BORDER, all, 10, 1.0f); - Font f(mem, g_fUI); - for (int i = 0; i < (int)g_pop.items.size(); ++i) { - Rect row(3, i*30+3, rc.right-6, 28); - if (i == g_pop.hot) FillRound(g, C_SURFACEHI, row, 7); - RectF tb((REAL)row.X+9,(REAL)row.Y,(REAL)row.Width-12,(REAL)row.Height); - DrawTextC(g, g_pop.items[i].c_str(), f, (i==g_pop.sel)?C_ACCENT:C_TEXT, - tb, StringAlignmentNear, StringAlignmentCenter); - } - } - BitBlt(hdc,0,0,rc.right,rc.bottom,mem,0,0,SRCCOPY); - SelectObject(mem, old); DeleteObject(bmp); DeleteDC(mem); - EndPaint(h, &ps); return 0; - } - } - return DefWindowProc(h, m, w, l); -} - -void ShowSelectPopup(HWND owner, int ctrlId, const std::vector& items, int sel) { - static bool reg = false; - if (!reg) { WNDCLASSEXW wc{ sizeof(wc) }; wc.lpfnWndProc = PopupProc; wc.hInstance = hInst; - wc.hCursor = LoadCursor(nullptr, IDC_ARROW); wc.lpszClassName = L"DictPopup"; - RegisterClassExW(&wc); reg = true; } - g_pop = { items, sel, -1, owner, ctrlId }; - RECT rc; GetWindowRect(GetDlgItem(owner, ctrlId), &rc); - int h = (int)items.size()*30 + 6, wdt = rc.right - rc.left; - HWND p = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, L"DictPopup", L"", - WS_POPUP, rc.left, rc.bottom+2, wdt, h, owner, nullptr, hInst, nullptr); - int corner = DWMWCP_ROUND; DwmSetWindowAttribute(p, DWMWA_WINDOW_CORNER_PREFERENCE, &corner, sizeof(corner)); - ShowWindow(p, SW_SHOWNA); SetForegroundWindow(p); SetFocus(p); -} -``` - -Wire it up: clicking a selector opens the popup; the popup posts the chosen row back: - -```cpp -// WM_COMMAND: -case ID_SEL_AUDIO: ShowSelectPopup(hWnd, ID_SEL_AUDIO, g_audioItems, g_audioSel); break; -case ID_SEL_MODEL: ShowSelectPopup(hWnd, ID_SEL_MODEL, g_modelItems, g_modelSel); break; - -// new message handler: -case WM_APP_SELECT: { // #define WM_APP_SELECT (WM_USER + 5) - int ctrlId = (int)wParam, idx = (int)lParam; - if (ctrlId == ID_SEL_AUDIO) { g_audioSel = idx; g_config.capture_id = idx; } - else if (ctrlId == ID_SEL_MODEL && idx < (int)g_modelComboPaths.size()) { - g_modelSel = idx; - g_config.model_path = exe_dir() + "\\" + g_modelComboPaths[idx]; - g_modelLoaded = false; g_modelOk = false; SetStatus(hWnd, L"Loading model…"); - std::thread([]{ bool ok=g_tx.reload(g_config); g_modelOk=ok; g_modelLoaded=true; }).detach(); - } - InvalidateRect(GetDlgItem(hWnd, ctrlId), nullptr, FALSE); -} break; -``` - -You can now delete the `CBS_*`/`WM_MEASUREITEM`/`DrawCombo` combo code and the `WM_CTLCOLORLISTBOX` handler. The selectors are now pixel-identical to your other controls with exactly one (your) chevron. - -> Lighter alternative if you don't want a popup window yet: keep the combos but call `SetWindowTheme(hCombo, L"", L"")` — it flattens the dropdown button to a plain square. It's *less* boxy but the button is still there, so the popup-window route above is the real fix. - ---- - -## B2. Transcription progress + time estimate - -You don't have to guess the timing — **whisper.cpp reports real progress.** `whisper_full_params` has a `progress_callback` that fires repeatedly during inference with an `int` 0–100 (fraction of the audio processed). Feed that to a determinate progress bar + a live ETA, so "Transcribing…" becomes "Transcribing 1:40 of audio · 45% · ~9s left". - -### B2.1 transcriber — expose progress + audio length - -`transcriber.h` (public): - -```cpp -using ProgressCb = std::function; // 0..100 -void set_progress_callback(ProgressCb cb) { m_on_progress = std::move(cb); } -float audio_seconds() const { return m_audio_seconds.load(); } -void request_cancel() { m_abort = true; } // optional (B2.4) -``` -`transcriber.h` (private): - -```cpp -ProgressCb m_on_progress; -std::atomic m_audio_seconds{0.0f}; -std::atomic m_abort{false}; -static void s_progress(struct whisper_context*, struct whisper_state*, int p, void* ud); -static bool s_abort(void* ud); -``` - -`transcriber.cpp` — the static trampolines and the `run_inference` hook: - -```cpp -void Transcriber::s_progress(whisper_context*, whisper_state*, int p, void* ud) { - auto* self = static_cast(ud); - if (self && self->m_on_progress) self->m_on_progress(p); -} -bool Transcriber::s_abort(void* ud) { - auto* self = static_cast(ud); - return self && self->m_abort.load(); -} - -std::string Transcriber::run_inference(std::vector& audio) { - if (!m_ctx) return ""; - m_abort = false; - if (m_cfg.trim_silence) trim_silence(audio); - m_audio_seconds = (float)(audio.size() / (double)WHISPER_SAMPLE_RATE); // for the UI - - whisper_full_params wp = whisper_full_default_params(WHISPER_SAMPLING_GREEDY); - wp.print_progress = false; wp.print_realtime = false; wp.print_timestamps = false; - wp.no_timestamps = true; wp.translate = false; - wp.language = m_cfg.language.c_str(); - wp.n_threads = m_cfg.n_threads; - wp.no_context = true; wp.suppress_blank = true; wp.suppress_nst = true; wp.temperature = 0.0f; - wp.progress_callback = &Transcriber::s_progress; // <- live progress - wp.progress_callback_user_data = this; - wp.abort_callback = &Transcriber::s_abort; // <- optional cancel - wp.abort_callback_user_data = this; - - std::string out; - if (whisper_full(m_ctx, wp, audio.data(), (int)audio.size()) == 0) { - int n = whisper_full_n_segments(m_ctx); - for (int i = 0; i < n; ++i) { const char* t = whisper_full_get_segment_text(m_ctx, i); if (t) out += t; } - out = clean_text(out); - } - return out; -} -``` - -> If your `whisper.h` predates `abort_callback`, drop those two lines — `progress_callback` has been in whisper.cpp far longer and is what matters here. - -### B2.2 main.cpp — progress state + ETA - -```cpp -#define WM_APP_PROGRESS (WM_USER + 6) -std::atomic g_progress{0}; -DWORD g_busyStart = 0; - -// at startup, next to set_result_callback: -g_tx.set_progress_callback([](int p){ PostMessage(hMainWnd, WM_APP_PROGRESS, (WPARAM)p, 0); }); -``` - -Start the clock when transcription begins (HK_TOGGLE stop branch): - -```cpp -} else { // was recording -> stop - g_busyStart = GetTickCount(); - g_progress = 0; - g_tx.stop_and_transcribe(); - SetStatus(hWnd, L"Transcribing…"); -} -``` - -Receive progress and repaint the bar: - -```cpp -case WM_APP_PROGRESS: - g_progress = (int)wParam; - InvalidateRect(hWnd, &g_vuRect, FALSE); - return 0; -``` - -ETA text (replace the `is_busy()` branch in `UpdateStatus`): - -```cpp -} else if (g_tx.is_busy()) { - int p = g_progress.load(); - float total = g_tx.audio_seconds(); - float elapsed = (GetTickCount() - g_busyStart) / 1000.0f; - int mm = (int)total / 60, ss = (int)total % 60; - if (p >= 3) { - float est = elapsed * 100.0f / p; // projected total - float remain = est - elapsed; if (remain < 0) remain = 0; - swprintf_s(buf, L"Transcribing %d:%02d • %d%% • ~%ds left", mm, ss, p, (int)(remain + 0.5f)); - } else { - swprintf_s(buf, L"Transcribing %d:%02d of audio…", mm, ss); - } - SetStatus(hwnd, buf); -} -``` - -### B2.3 Reuse the VU strip as a determinate progress bar - -While recording the strip shows the VU; while transcribing it shows progress. Add a renderer and branch in `WM_PAINT`: - -```cpp -void DrawProgress(Graphics& g, const RECT& r, float frac) { - Rect track(r.left, r.top, r.right - r.left, r.bottom - r.top); - FillRound(g, C_SURFACEHI, track, 4); - frac = frac < 0 ? 0 : (frac > 1 ? 1 : frac); - int w = (int)((r.right - r.left) * frac); - if (w > 0) { Rect fill(r.left, r.top, w, r.bottom - r.top); FillRound(g, C_ACCENT, fill, 4); } -} -``` -```cpp -// in WM_PAINT, where you currently call DrawVU: -if (g_tx.is_busy()) DrawProgress(g, g_vuRect, g_progress.load() / 100.0f); -else DrawVU(g, g_vuRect, g_energy); -``` - -Keep it ticking between callbacks so the ETA counts down smoothly — in `WM_TIMER`, add: - -```cpp -else if (g_tx.is_busy()) { - InvalidateRect(hWnd, &g_vuRect, FALSE); // (UpdateStatus already runs each tick below) -} -``` - -That's it: a moving bar, a percentage, and a shrinking "~Ns left" — the user can see it's alive and roughly how long is left. The estimate self-corrects as real progress arrives (the first few percent are rougher; it tightens quickly). - -### B2.4 (Optional) Cancel a long transcription - -You added `request_cancel()` + the abort callback in B2.1. Hook it so that pressing the button **while busy** aborts instead of being ignored, and treat the empty result as "Cancelled": - -```cpp -// top of the HK_TOGGLE handler: -if (g_tx.is_busy()) { g_tx.request_cancel(); SetStatus(hWnd, L"Cancelling…"); break; } -``` -`whisper_full` returns promptly with no/aborted segments → your existing `WM_APP_RESULT` empty-string path shows "No speech detected"; change that label to "Cancelled" when a cancel was requested if you want to distinguish them. - ---- - -## B3. Build & test - -- **New link deps:** `uxtheme.lib` (added via `#pragma comment` in B1.1). GDI+ is already linked. -- **New files:** none required for B2; B1.2 adds the popup window proc inside `main.cpp` (no new translation unit). -- **Rebuild:** `cmake --build build --config Release` as usual. - -**Verify:** -- [ ] No hairline around *Pinned*; no left/top lines on Copy/Paste/Clear; focus no longer draws a dotted rect. -- [ ] Mic + model selectors show a single (your) chevron, open a dark rounded popup, and selecting reloads the model / switches device. -- [ ] Record a ~1–2 min clip → the strip fills as a progress bar, the status shows `%` and a shrinking `~Ns left`, and it completes (no static "Transcribing…"). -- [ ] (If added) pressing the button mid-transcription cancels promptly. - -**Headless regression (extends `tests/test_core.cpp` from `FINDINGS-FIXES-TESTS.md`):** -- Set a progress callback that records the max value seen; assert it reaches ~100 for `samples/jfk.wav`, and that callbacks arrive in non-decreasing order. This locks in that progress reporting keeps working across whisper.cpp upgrades. - -```cpp -int last = -1, maxp = 0; bool monotonic = true; -t.set_progress_callback([&](int p){ if (p < last) monotonic = false; last = p; if (p > maxp) maxp = p; }); -t.transcribe_sync(audio); -CHECK(monotonic, "progress is non-decreasing"); -CHECK(maxp >= 95, "progress reaches ~100%"); -``` - ---- - -*Apply order: B1.1 (5 min, instant visual win) → B2 (progress, the big UX gain) → B1.2 (custom dropdowns) → optional B2.4 cancel. Each is independent and safe to ship on its own.* - - diff --git a/README.md b/README.md index 2400644..150b9bd 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ -# Win Dictation - AI Voice to Text for Windows +# Win Dictation — Voice to Text for Windows -A push-to-talk speech-to-text utility for Windows using OpenAI's Whisper model. Record, transcribe, and paste with a single hotkey. - -![Win Dictation Screenshot](screenshot.png) +A push-to-talk speech-to-text utility for Windows. Press a hotkey, speak, and your words land in whatever app you were just using — fully offline, powered by Whisper. ## Quick Download @@ -12,12 +10,18 @@ Extract the ZIP file and run `win-dictation.exe`. The release includes all requi --- +## Documentation + +- **[User Manual](win-dictation-user-manual.html)** — How to use every feature +- **[Architecture & Engineering Review](win-dictation-architecture-engineering-review.html)** — Deep dive into the codebase for developers + +--- + ## Features ### Performance - **Physical-core threading**: Uses one thread per physical core for efficient batch transcription -- **CPU-only**: Optimised for the target Intel i5-7th-gen 2-core/4-thread machine -- **Smart model selection**: Auto-selects tiny.en for CPU-only, base.en when GPU is present +- **CPU-only**: Optimised for ordinary laptops — no GPU required - **Self-calibrating progress**: Learns transcription speed per model and machine, delivering a smooth countdown ### User Interface @@ -28,23 +32,25 @@ Extract the ZIP file and run `win-dictation.exe`. The release includes all requi ### Audio Processing - **Push-to-talk**: Press Ctrl+Shift+Space, speak, press again to transcribe -- **500ms auto-end**: Stops recording after 500ms of silence - **Multiple microphones**: Select from all available input devices -- **16kHz sample rate**: Optimised for Whisper +- **16 kHz sample rate**: Optimised for Whisper +- **Silence trimming**: Leading and trailing silence is trimmed before transcription -## Usage +## Quick Start + +1. Launch `win-dictation.exe` +2. Click into wherever you want text, then press `Ctrl+Shift+Space` +3. Speak, then press `Ctrl+Shift+Space` again +4. Your words appear in the app you were using + +Full instructions in the [User Manual](win-dictation-user-manual.html). ### Controls -- **Record**: Click the Record pill or press `Ctrl+Shift+Space` +- **Record/Stop**: Click the pill or press `Ctrl+Shift+Space` +- **Hide window**: `Ctrl+Shift+H` - **Pin**: Keep window always-on-top -- **Copy / Paste / Clear**: Text actions -- **Model / Mic**: Select from popup menus -- **Hide**: `Ctrl+Shift+H` hides the window - -### Indicators -- **Level**: Live audio energy during recording -- **Progress bar**: Smooth, counting-down estimate during transcription -- **Status**: Thread count at idle, elapsed time during recording +- **Copy / Paste / Clear**: Text actions below the transcript +- **Model / Mic / History**: Select from popup menus ## Building from Source @@ -52,13 +58,13 @@ Extract the ZIP file and run `win-dictation.exe`. The release includes all requi - **Windows 10/11** - **CMake** 3.5+ -- **Visual Studio 2022/2026** with C++ workload +- **Visual Studio 2022** with C++ workload - **SDL2** (included in deps/) ### Build Steps ```powershell -cmake -S . -B build -G "Visual Studio 18 2026" \ +cmake -S . -B build -G "Visual Studio 17 2022" ^ -DSDL2_DIR="deps/SDL2-2.28.5/cmake" cmake --build build --config Release ``` @@ -73,36 +79,45 @@ The executable will be at `build\bin\Release\win-dictation.exe`. Hotkey → SDL Capture → Stop → Batch whisper_full → Text → Auto-paste ``` -1. **SDL audio capture**: 16kHz mono recording into memory -2. **Stop-and-transcribe**: Press stop or hit max length (600s), then one `whisper_full` call -3. **Progress estimation**: Linear model fitted per machine/model, fused with whisper's chunk progress -4. **Text output**: Appended to transcript, copied to clipboard, optionally auto-pasted +1. **SDL audio capture**: 16 kHz mono recording into memory. CPU stays near idle while recording. +2. **Stop-and-transcribe**: One `whisper_full` call processes the full clip at once. +3. **Progress estimation**: Decayed online least-squares model per machine/model, fused with whisper's chunk progress into a strictly monotonic countdown. +4. **Text output**: Inserted at cursor with smart spacing, copied to clipboard, and optionally auto-pasted into the window you came from. -### Model +### Models -Place `.bin` files in `models/` next to the executable. The app auto-detects available models: +Place `.bin` files in `models/` next to the executable, or download them from the Settings screen in-app: -| Model | Size | Params | Best for | -|-------|------|--------|----------| -| tiny.en | 75 MB | 39M | CPU-only systems | -| base.en | 140 MB | 74M | GPU-accelerated systems | +| Model | Size | Best for | +|-------|------|----------| +| tiny.en | ~75 MB | Fastest — everyday dictation | +| tiny.en-q8_0 | ~42 MB | Same speed, smaller file | +| base.en-q5_1 | ~59 MB | Good accuracy bump for little cost | +| base.en | ~142 MB | More accurate; still reasonable on two cores | +| small.en-q5_1 | ~182 MB | Accurate, but slower | +| small.en | ~466 MB | Most accurate — and slowest | ## Project Structure ``` win-dictation/ -├── src/ # Application source -│ ├── main.cpp # UI and message handling -│ ├── transcriber.* # Recording and transcription -│ ├── timing.h # Progress estimation engine -│ ├── settings.h # INI persistence -│ ├── text_util.h # Transcript helpers -│ └── logging.h # Log utilities -├── whisper/ # Whisper.cpp library -├── ggml/ # GGML tensor library -├── models/ # Whisper model files -├── release/ # Pre-built package -└── CMakeLists.txt # Build configuration +├── src/ # Application source +│ ├── main.cpp # Window, painting, interaction, settings, clipboard, popups +│ ├── transcriber.* # SDL capture, Whisper preload/inference, progress callbacks +│ ├── timing.h # Learned timing model + live progress estimator +│ ├── history.h # Session text files, index, pruning +│ ├── downloader.h # WinHTTP model downloader (background thread) +│ ├── stats.h # Lifetime usage totals + derived figures +│ ├── settings.h # INI persistence +│ ├── text_util.h # Transcript concatenation helpers +│ ├── logging.h # Timestamped file log +│ └── tests/ # Unit tests (test-core.exe) +├── whisper/ # Whisper.cpp library +├── ggml/ # GGML tensor library +├── models/ # Whisper model files +├── history/ # Saved dictation sessions +├── release/ # Pre-built package +└── CMakeLists.txt # Build configuration ``` ## License @@ -111,5 +126,7 @@ MIT — follows [whisper.cpp](https://github.com/ggerganov/whisper.cpp). ## Resources +- [User Manual](win-dictation-user-manual.html) +- [Architecture & Engineering Review](win-dictation-architecture-engineering-review.html) - [Whisper.cpp](https://github.com/ggerganov/whisper.cpp) -- [Model Download](https://huggingface.co/ggerganov/whisper.cpp) +- [Model Downloads](https://huggingface.co/ggerganov/whisper.cpp) diff --git a/FINDINGS-FIXES-TESTS.md b/old_text_files/FINDINGS-FIXES-TESTS.md similarity index 100% rename from FINDINGS-FIXES-TESTS.md rename to old_text_files/FINDINGS-FIXES-TESTS.md diff --git a/FINDINGS-FIXES-TESTS2.md b/old_text_files/FINDINGS-FIXES-TESTS2.md similarity index 100% rename from FINDINGS-FIXES-TESTS2.md rename to old_text_files/FINDINGS-FIXES-TESTS2.md diff --git a/UI-and-progress-bar-rebuild-part-2.md b/old_text_files/UI-and-progress-bar-rebuild-part-2.md similarity index 100% rename from UI-and-progress-bar-rebuild-part-2.md rename to old_text_files/UI-and-progress-bar-rebuild-part-2.md diff --git a/UI-and-progress-bar-rebuild-part-3.md b/old_text_files/UI-and-progress-bar-rebuild-part-3.md similarity index 100% rename from UI-and-progress-bar-rebuild-part-3.md rename to old_text_files/UI-and-progress-bar-rebuild-part-3.md diff --git a/UI-and-progress-bar-rebuild.md b/old_text_files/UI-and-progress-bar-rebuild.md similarity index 100% rename from UI-and-progress-bar-rebuild.md rename to old_text_files/UI-and-progress-bar-rebuild.md diff --git a/Win-Dictation-features-01.md b/old_text_files/Win-Dictation-features-01.md similarity index 100% rename from Win-Dictation-features-01.md rename to old_text_files/Win-Dictation-features-01.md diff --git a/bug-fixes-and-visual-upgrade.md b/old_text_files/bug-fixes-and-visual-upgrade.md similarity index 100% rename from bug-fixes-and-visual-upgrade.md rename to old_text_files/bug-fixes-and-visual-upgrade.md diff --git a/dev-task-list.md b/old_text_files/dev-task-list.md similarity index 100% rename from dev-task-list.md rename to old_text_files/dev-task-list.md diff --git a/fix-history-dropdown.md b/old_text_files/fix-history-dropdown.md similarity index 100% rename from fix-history-dropdown.md rename to old_text_files/fix-history-dropdown.md diff --git a/old_text_files/hisory-delete-instructions.md b/old_text_files/hisory-delete-instructions.md new file mode 100644 index 0000000..f872d9d --- /dev/null +++ b/old_text_files/hisory-delete-instructions.md @@ -0,0 +1,366 @@ +# Fix 06 — Delete individual history entries from the popup (✕ on hover) + +**Builds on:** Fix-03/04 (popup) and **Fix-05 (live session archiving) — apply Fix-05 first.** +One block below references `g_sessionPath` from Fix-05; it is clearly marked in case you +must build without it. +**Files touched:** `src/main.cpp` only. `history.h` unchanged. +**Estimated effort:** 45–60 minutes including testing. + +--- + +## 1. What we're building + +- Hovering a row in the **History** popup reveals a small `✕` at the row's right edge. +- Clicking the `✕` deletes that entry's file from `history\` and refreshes the list + **in place — the popup stays open**, so you can clean out several entries in one go. +- Clicking anywhere else on the row still loads the entry (unchanged behaviour). +- The `Delete` key also deletes the hovered row (the popup already owns keyboard focus). +- The **microphone popup is untouched** — it shares the same code, so the feature is + gated by a `canDelete` flag that is only true for `ID_SEL_HISTORY`. + +### Design decisions (so the dev doesn't relitigate them) + +1. **Popup stays open after a delete.** Closing after each delete would make cleaning + up 10–50 entries miserable. The list, scrollbar, and popup height all refresh in + place; deleting the last entry closes the popup. +2. **No confirmation dialog — and this is load-bearing, not laziness.** The popup + destroys itself on `WM_ACTIVATE / WA_INACTIVE` (that's the click-away-to-close + behaviour). A `MessageBox` shown from inside `PopupProc` would *deactivate the + popup, destroy it mid-handler, and then resume the handler with a dead `HWND`* — + undefined behaviour. **Never open a modal dialog from `PopupProc`.** If a safety + net is wanted later, use the soft-delete variant in §8 instead. +3. **Deleting the LIVE session's entry detaches the session** (see §7) so Clear/exit + don't instantly resurrect the file you just deleted. + +--- + +## 2. Step 1 — Extend `PopupState` + +Find the `PopupState` struct and add the two marked fields: + +```cpp +struct PopupState { + std::vector items; + int sel = -1; + int hot = -1; + HWND owner = nullptr; + int ctrlId = 0; + int scroll = 0; + int visRows = 0; + int rowH = 30; + int pad = 3; + int wheelAccum = 0; + bool canDelete = false; // NEW: rows show a ✕ delete button (history popup only) + int hotX = -1; // NEW: ABSOLUTE index of the row whose ✕ is hovered, -1 = none +}; +``` + +(`g_pop = PopupState{};` in `ShowSelectPopup` already resets the new fields each open — +no extra reset code needed.) + +## 3. Step 2 — Three small helpers + +Paste these **between `PopupRowFromY` and `PopupProc`** (they must be above `PopupProc`; +`PopupRowFromY` itself is unchanged): + +```cpp +// The ✕ hit square for a VISIBLE row (0..visRows-1), in popup client coords. +// Sits at the right edge of the row, inside the scrollbar gutter if present. +static Rect PopupDeleteRect(const RECT& rc, int visIdx) { + int n = (int)g_pop.items.size(); + bool hasBar = n > g_pop.visRows; + int barW = std::max(3, (int)(4 * g_dpiScale)); + int rowW = rc.right - 2 * g_pop.pad - (hasBar ? barW + g_pop.pad : 0); + int xW = g_pop.rowH; // square zone, one row tall + return Rect(g_pop.pad + rowW - xW, g_pop.pad + visIdx * g_pop.rowH, xW, g_pop.rowH - 2); +} + +// Recompute hot row + hovered-✕ from the current cursor position. Used after +// scrolling and after a delete (the list moved under a stationary cursor). +static void PopupRefreshHotFromCursor(HWND h) { + POINT pt; GetCursorPos(&pt); ScreenToClient(h, &pt); + int row = PopupRowFromY(pt.y); + int hx = -1; + if (g_pop.canDelete && row >= 0) { + RECT rc; GetClientRect(h, &rc); + if (PopupDeleteRect(rc, row - g_pop.scroll).Contains(pt.x, pt.y)) hx = row; + } + g_pop.hot = row; g_pop.hotX = hx; +} + +// Delete the history file behind ABSOLUTE row `row`, then refresh the popup +// in place. The popup stays open so several entries can be deleted in a row. +static void PopupDeleteRow(HWND h, int row) { + if (row < 0 || row >= (int)g_history.size()) return; + std::wstring path = g_history[row].path; + bool ok = DeleteFileW(path.c_str()) != FALSE; + + // ---- Requires Fix-05 (g_sessionPath). Omit this block ONLY if building + // ---- without Fix-05, and apply it when Fix-05 lands. + if (ok && path == g_sessionPath) { + // The LIVE session's file was deleted: detach the session so Clear/exit + // don't immediately re-archive the same text. If the user dictates MORE, + // a new file is created — history always mirrors the transcript box. + g_sessionPath.clear(); + g_lastLoadedText = GetEditText(g_pop.owner); + } + // ---- end Fix-05-dependent block + + g_history = LoadHistoryIndex(); // re-scan the folder + g_pop.items.clear(); + g_pop.items.reserve(g_history.size()); + for (const auto& e : g_history) g_pop.items.push_back(e.label); + + SetStatus(g_pop.owner, ok ? L"Deleted" : L"Delete failed"); + + int n = (int)g_pop.items.size(); + if (n == 0) { DestroyWindow(h); return; } // nothing left to show + + // Shrink the popup when fewer rows remain than were visible. It opens + // upward, so keep the BOTTOM edge fixed and move the top edge down. + if (n < g_pop.visRows) { + g_pop.visRows = n; + int newH = n * g_pop.rowH + 2 * g_pop.pad; + RECT wr; GetWindowRect(h, &wr); + SetWindowPos(h, nullptr, wr.left, wr.bottom - newH, + wr.right - wr.left, newH, SWP_NOZORDER | SWP_NOACTIVATE); + } + int maxScroll = std::max(0, n - g_pop.visRows); + g_pop.scroll = std::min(g_pop.scroll, maxScroll); + + PopupRefreshHotFromCursor(h); + InvalidateRect(h, nullptr, FALSE); +} +``` + +Why this is safe to do from `PopupProc`: everything here runs on the UI thread, +`g_history` / `g_sessionPath` / `g_lastLoadedText` are main-thread globals declared +earlier in the file, and `GetEditText` / `SetStatus` / `LoadHistoryIndex` are all +declared above the popup code already. Indices stay valid because `g_pop.items` is +rebuilt 1:1 from the freshly reloaded `g_history` — the existing `WM_APP_SELECT` +handler keeps working unchanged. + +## 4. Step 3 — Replace `PopupProc` (entire function) + +Replace the whole `LRESULT CALLBACK PopupProc(...)` with the version below. Changes vs +Fix-04: ✕ hover tracking in `WM_MOUSEMOVE`, `WM_MOUSEWHEEL` now uses +`PopupRefreshHotFromCursor`, `WM_KEYDOWN` gains `VK_DELETE`, `WM_LBUTTONUP` routes +✕-clicks to `PopupDeleteRow` (and does NOT close), and `WM_PAINT` draws the ✕ and +reserves label space for it. Everything else is byte-for-byte the Fix-04 code. + +```cpp +LRESULT CALLBACK PopupProc(HWND h, UINT m, WPARAM w, LPARAM l) { + switch (m) { + case WM_MOUSEMOVE: { + int row = PopupRowFromY(GET_Y_LPARAM(l)); + int hx = -1; + if (g_pop.canDelete && row >= 0) { + RECT rc; GetClientRect(h, &rc); + if (PopupDeleteRect(rc, row - g_pop.scroll).Contains(GET_X_LPARAM(l), GET_Y_LPARAM(l))) + hx = row; + } + if (row != g_pop.hot || hx != g_pop.hotX) { + g_pop.hot = row; g_pop.hotX = hx; + InvalidateRect(h, nullptr, FALSE); + } + TRACKMOUSEEVENT t{ sizeof(t), TME_LEAVE, h, 0 }; TrackMouseEvent(&t); + return 0; + } + case WM_MOUSELEAVE: + g_pop.hot = -1; g_pop.hotX = -1; InvalidateRect(h, nullptr, FALSE); + return 0; + case WM_MOUSEWHEEL: { + int maxScroll = (int)g_pop.items.size() - g_pop.visRows; + if (maxScroll <= 0) return 0; + g_pop.wheelAccum += GET_WHEEL_DELTA_WPARAM(w); + int steps = g_pop.wheelAccum / WHEEL_DELTA; + if (steps != 0) { + g_pop.wheelAccum -= steps * WHEEL_DELTA; + g_pop.scroll -= steps * 3; + g_pop.scroll = std::max(0, std::min(g_pop.scroll, maxScroll)); + PopupRefreshHotFromCursor(h); + InvalidateRect(h, nullptr, FALSE); + } + return 0; + } + case WM_KEYDOWN: + if (w == VK_ESCAPE) DestroyWindow(h); + else if (w == VK_DELETE && g_pop.canDelete && g_pop.hot >= 0) + PopupDeleteRow(h, g_pop.hot); + return 0; + case WM_LBUTTONUP: { + int row = PopupRowFromY(GET_Y_LPARAM(l)); + if (g_pop.canDelete && row >= 0) { + RECT rc; GetClientRect(h, &rc); + if (PopupDeleteRect(rc, row - g_pop.scroll).Contains(GET_X_LPARAM(l), GET_Y_LPARAM(l))) { + PopupDeleteRow(h, row); // delete — popup STAYS OPEN + return 0; + } + } + if (row >= 0) + PostMessageW(g_pop.owner, WM_APP_SELECT, (WPARAM)g_pop.ctrlId, (LPARAM)row); + DestroyWindow(h); + return 0; + } + case WM_ACTIVATE: + if (LOWORD(w) == WA_INACTIVE) DestroyWindow(h); + return 0; + case WM_ERASEBKGND: return 1; + case WM_PAINT: { + PAINTSTRUCT ps; HDC hdc = BeginPaint(h, &ps); + RECT rc; GetClientRect(h, &rc); + HDC mem = CreateCompatibleDC(hdc); + HBITMAP bmp = CreateCompatibleBitmap(hdc, rc.right, rc.bottom); + HBITMAP old = (HBITMAP)SelectObject(mem, bmp); + { + Graphics g(mem); + g.SetSmoothingMode(SmoothingModeAntiAlias); + g.SetTextRenderingHint(TextRenderingHintClearTypeGridFit); + Rect all(0, 0, rc.right, rc.bottom); + FillRound(g, T_CARD, all, 10); + StrokeRound(g, T_FAINT, all, 10, 1.0f); + int n = (int)g_pop.items.size(); + bool hasBar = n > g_pop.visRows; + int barW = std::max(3, (int)(4 * g_dpiScale)); + int rowW = rc.right - 2 * g_pop.pad - (hasBar ? barW + g_pop.pad : 0); + int reserve = g_pop.canDelete ? g_pop.rowH : 0; // keep labels clear of the ✕ zone + int last = std::min(n, g_pop.scroll + g_pop.visRows); + for (int i = g_pop.scroll; i < last; ++i) { + int vis = i - g_pop.scroll; + Rect row(g_pop.pad, g_pop.pad + vis * g_pop.rowH, rowW, g_pop.rowH - 2); + if (i == g_pop.hot) FillRound(g, T_CARD_HI, row, 7); + RectF tb((REAL)row.X + 9, (REAL)row.Y, (REAL)(row.Width - 12 - reserve), (REAL)row.Height); + DrawTextC(g, g_pop.items[i].c_str(), *g_gpUI, + (i == g_pop.sel) ? T_ACCENT : T_TEXT, + tb, StringAlignmentNear, StringAlignmentCenter); + if (g_pop.canDelete && i == g_pop.hot) { // ✕ only on the hovered row + Rect xr = PopupDeleteRect(rc, vis); + if (i == g_pop.hotX) FillRound(g, T_CARD_LO, xr, 6); + RectF xb((REAL)xr.X, (REAL)xr.Y, (REAL)xr.Width, (REAL)xr.Height); + DrawTextC(g, L"✕", *g_gpUI, + (i == g_pop.hotX) ? T_DANGER : T_FAINT, + xb, StringAlignmentCenter, StringAlignmentCenter); + } + } + if (hasBar) { + int trackH = rc.bottom - 2 * g_pop.pad; + int thumbH = std::max((int)(20 * g_dpiScale), trackH * g_pop.visRows / n); + int maxScroll = n - g_pop.visRows; + int thumbY = g_pop.pad + (trackH - thumbH) * g_pop.scroll / maxScroll; + Rect thumb(rc.right - g_pop.pad - barW, thumbY, barW, thumbH); + FillRound(g, T_DIM, thumb, barW / 2); + } + } + BitBlt(hdc, 0, 0, rc.right, rc.bottom, mem, 0, 0, SRCCOPY); + SelectObject(mem, old); DeleteObject(bmp); DeleteDC(mem); + EndPaint(h, &ps); + return 0; + } + } + return DefWindowProc(h, m, w, l); +} +``` + +Visual spec, matching the app's design language: the ✕ (`✕`) appears only on the +hovered row, drawn in `T_FAINT`; when the cursor is over the ✕ itself it turns +`T_DANGER` red on a subtle `T_CARD_LO` chip. Labels always reserve the ✕ column in the +history popup so text doesn't shift when hover reveals the button. + +## 5. Step 4 — Enable it for the History popup only + +In `ShowSelectPopup`, find: + +```cpp + g_pop.ctrlId = ctrlId; +``` + +Add one line directly below it: + +```cpp + g_pop.ctrlId = ctrlId; + g_pop.canDelete = (ctrlId == ID_SEL_HISTORY); // ✕ delete buttons: history only +``` + +That's the entire gating — the mic popup keeps `canDelete == false` and renders/behaves +exactly as before. + +## 6. No other changes + +- `OnClick` (History / SelAudio cases), `ShowSelectPopup`'s sizing/placement, + `WM_APP_SELECT`, `history.h` — all untouched. +- No new message IDs, no new globals beyond the two `PopupState` fields. + +## 7. Interaction with the live session (Fix-05) — read this + +Fix-05 keeps the current dictation session mirrored to a history file +(`g_sessionPath`). If the user deletes THAT entry from the popup: + +- Without special handling, `FinalizeSession` would re-archive the box text on the next + Clear/exit — the file the user just deleted would instantly come back. +- The marked block in `PopupDeleteRow` prevents that: it clears `g_sessionPath` and sets + `g_lastLoadedText` to the current box text, so Clear/exit treat the box content as + "already accounted for" and do NOT re-archive it. (This is the same guard mechanism + Fix-05 documented — used deliberately here, because the user explicitly said + "forget this".) +- **Documented behaviour, not a bug:** if the user deletes the live entry and then + dictates *more*, a NEW history file is created containing the box's full text — + history always mirrors the transcript box. To make a session vanish completely: + delete the entry, then Clear. + +## 8. Optional variant — soft delete (trash folder) + +If you ever want an undo path, change ONE line in `PopupDeleteRow`. Replace: + +```cpp + bool ok = DeleteFileW(path.c_str()) != FALSE; +``` + +with: + +```cpp + std::wstring trashDir = HistoryDir() + L"\\trash"; + CreateDirectoryW(trashDir.c_str(), nullptr); + std::wstring dest = trashDir + path.substr(path.find_last_of(L'\\')); + bool ok = MoveFileExW(path.c_str(), dest.c_str(), MOVEFILE_REPLACE_EXISTING) != FALSE; +``` + +`LoadHistoryIndex` only scans `history\*.txt` (not subfolders), so trashed entries +disappear from the popup but remain recoverable by hand. Not wired to any UI — purely a +safety net. Skip this for v1 unless asked. + +## 9. Build & test checklist + +1. **Reveal:** open History, move the mouse down the rows — a faint ✕ appears at the + right edge of the hovered row only; it turns red when the cursor reaches it. +2. **Delete:** click a ✕ → the row disappears, the file is gone from the `history\` + folder, status shows "Deleted", and the **popup stays open**. +3. **Multi-delete:** delete 3–4 entries in a row without the popup closing; hover + highlight stays correct after each (the list shifts under the cursor). +4. **Row click still loads:** clicking a row anywhere left of the ✕ loads the entry and + closes the popup, exactly as before. +5. **Scrollbar transition:** with 9+ entries, delete down to 8 → the scrollbar + disappears and rows widen slightly; scrolled state stays sane (no blank gaps). +6. **Shrink:** with ≤7 entries left, delete more — the popup gets shorter with its + bottom edge fixed just above the selects row (it shrinks downward-in-place, never + floats away). +7. **Last entry:** deleting the final entry closes the popup; clicking History again + shows "No history yet". +8. **Delete key:** hover a row, press `Delete` → same as clicking its ✕. +9. **Live session:** dictate (entry appears per Fix-05) → open History → delete that + entry → press Clear → status "Cleared" and the entry does NOT come back. Then + dictate again → a new entry appears (documented in §7). +10. **Mic popup regression:** the Microphone popup shows NO ✕, full-width labels, + selection works — completely unchanged. +11. **Esc / click-away:** still close the popup; no delete is triggered. +12. **DPI 125/150%:** ✕ hit zone lines up with the drawn glyph. + +## 10. Do NOT touch / do NOT add + +- **Do NOT add a `MessageBox` confirmation inside `PopupProc`** — the popup destroys + itself on deactivation (`WM_ACTIVATE`/`WA_INACTIVE`), so a modal dialog kills the + popup mid-handler and the code resumes with a destroyed `HWND`. If confirmation is + ever required, use the §8 trash variant or build it into the popup's own surface. +- `PopupRowFromY`, `ShowSelectPopup` (besides the one-line flag), `history.h`, + `WM_APP_SELECT`, `FinalizeSession` — unchanged. +- `g_pop.sel` needs no remapping on delete: the history popup always opens with + `sel = -1`, and the mic popup (which uses `sel`) can't delete. diff --git a/history-not-populating-fix.md b/old_text_files/history-not-populating-fix.md similarity index 100% rename from history-not-populating-fix.md rename to old_text_files/history-not-populating-fix.md diff --git a/popup-width-fix.md b/old_text_files/popup-width-fix.md similarity index 100% rename from popup-width-fix.md rename to old_text_files/popup-width-fix.md diff --git a/win-dictation-2-0-rebuild-spec-fast-compact-push-to-talk.md b/old_text_files/win-dictation-2-0-rebuild-spec-fast-compact-push-to-talk.md similarity index 100% rename from win-dictation-2-0-rebuild-spec-fast-compact-push-to-talk.md rename to old_text_files/win-dictation-2-0-rebuild-spec-fast-compact-push-to-talk.md diff --git a/screenshot.png b/screenshot.png deleted file mode 100644 index 329d5ef353a32a90e7177763bfe4157eff47c6e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 43602 zcmeFYcTkhx_AjiWAS$3Dy{Uj8NbfZQN-t8RcLb#OP7)ObMT+!Jqzed0?@f>zi1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ilnxCIRV)!tV=%o9CX%eJFsiex58%}R?}=oY)g1bOSLn`q>AR*J)hzDQ%d(ib zVSI{d!VIF*ks`SsQ2K?;xtLEi=~WdzF4uXDmFI=YxeFmU-6727hpyf>UY+2H)7r5P$8T;}C_eP9o(sD g_pop.visRows; + int barW = std::max(3, (int)(4 * g_dpiScale)); + int rowW = rc.right - 2 * g_pop.pad - (hasBar ? barW + g_pop.pad : 0); + int xW = g_pop.rowH; + return Rect(g_pop.pad + rowW - xW, g_pop.pad + visIdx * g_pop.rowH, xW, g_pop.rowH - 2); +} + +static void PopupRefreshHotFromCursor(HWND h) { + POINT pt; GetCursorPos(&pt); ScreenToClient(h, &pt); + int row = PopupRowFromY(pt.y); + int hx = -1; + if (g_pop.canDelete && row >= 0) { + RECT rc; GetClientRect(h, &rc); + if (PopupDeleteRect(rc, row - g_pop.scroll).Contains(pt.x, pt.y)) hx = row; + } + g_pop.hot = row; g_pop.hotX = hx; +} + +static void PopupDeleteRow(HWND h, int row) { + if (row < 0 || row >= (int)g_history.size()) return; + std::wstring path = g_history[row].path; + bool ok = DeleteFileW(path.c_str()) != FALSE; + + if (ok && path == g_sessionPath) { + g_sessionPath.clear(); + g_lastLoadedText = GetEditText(g_pop.owner); + } + + g_history = LoadHistoryIndex(); + g_pop.items.clear(); + g_pop.items.reserve(g_history.size()); + for (const auto& e : g_history) g_pop.items.push_back(e.label); + + SetStatus(g_pop.owner, ok ? L"Deleted" : L"Delete failed"); + + int n = (int)g_pop.items.size(); + if (n == 0) { DestroyWindow(h); return; } + + if (n < g_pop.visRows) { + g_pop.visRows = n; + int newH = n * g_pop.rowH + 2 * g_pop.pad; + RECT wr; GetWindowRect(h, &wr); + SetWindowPos(h, nullptr, wr.left, wr.bottom - newH, + wr.right - wr.left, newH, SWP_NOZORDER | SWP_NOACTIVATE); + } + int maxScroll = std::max(0, n - g_pop.visRows); + g_pop.scroll = std::min(g_pop.scroll, maxScroll); + + PopupRefreshHotFromCursor(h); + InvalidateRect(h, nullptr, FALSE); +} + LRESULT CALLBACK PopupProc(HWND h, UINT m, WPARAM w, LPARAM l) { switch (m) { case WM_MOUSEMOVE: { int row = PopupRowFromY(GET_Y_LPARAM(l)); - if (row != g_pop.hot) { g_pop.hot = row; InvalidateRect(h, nullptr, FALSE); } + int hx = -1; + if (g_pop.canDelete && row >= 0) { + RECT rc; GetClientRect(h, &rc); + if (PopupDeleteRect(rc, row - g_pop.scroll).Contains(GET_X_LPARAM(l), GET_Y_LPARAM(l))) + hx = row; + } + if (row != g_pop.hot || hx != g_pop.hotX) { + g_pop.hot = row; g_pop.hotX = hx; + InvalidateRect(h, nullptr, FALSE); + } TRACKMOUSEEVENT t{ sizeof(t), TME_LEAVE, h, 0 }; TrackMouseEvent(&t); return 0; } case WM_MOUSELEAVE: - g_pop.hot = -1; InvalidateRect(h, nullptr, FALSE); + g_pop.hot = -1; g_pop.hotX = -1; InvalidateRect(h, nullptr, FALSE); return 0; case WM_MOUSEWHEEL: { int maxScroll = (int)g_pop.items.size() - g_pop.visRows; @@ -679,17 +744,25 @@ LRESULT CALLBACK PopupProc(HWND h, UINT m, WPARAM w, LPARAM l) { g_pop.wheelAccum -= steps * WHEEL_DELTA; g_pop.scroll -= steps * 3; g_pop.scroll = std::max(0, std::min(g_pop.scroll, maxScroll)); - POINT pt; GetCursorPos(&pt); ScreenToClient(h, &pt); - g_pop.hot = PopupRowFromY(pt.y); + PopupRefreshHotFromCursor(h); InvalidateRect(h, nullptr, FALSE); } return 0; } case WM_KEYDOWN: if (w == VK_ESCAPE) DestroyWindow(h); + else if (w == VK_DELETE && g_pop.canDelete && g_pop.hot >= 0) + PopupDeleteRow(h, g_pop.hot); return 0; case WM_LBUTTONUP: { int row = PopupRowFromY(GET_Y_LPARAM(l)); + if (g_pop.canDelete && row >= 0) { + RECT rc; GetClientRect(h, &rc); + if (PopupDeleteRect(rc, row - g_pop.scroll).Contains(GET_X_LPARAM(l), GET_Y_LPARAM(l))) { + PopupDeleteRow(h, row); + return 0; + } + } if (row >= 0) PostMessageW(g_pop.owner, WM_APP_SELECT, (WPARAM)g_pop.ctrlId, (LPARAM)row); DestroyWindow(h); @@ -712,21 +785,31 @@ LRESULT CALLBACK PopupProc(HWND h, UINT m, WPARAM w, LPARAM l) { Rect all(0, 0, rc.right, rc.bottom); FillRound(g, T_CARD, all, 10); StrokeRound(g, T_FAINT, all, 10, 1.0f); - - int n = (int)g_pop.items.size(); - bool hasBar = n > g_pop.visRows; - int barW = std::max(3, (int)(4 * g_dpiScale)); - int rowW = rc.right - 2 * g_pop.pad - (hasBar ? barW + g_pop.pad : 0); - int last = std::min(n, g_pop.scroll + g_pop.visRows); - + int n = (int)g_pop.items.size(); + bool hasBar = n > g_pop.visRows; + int barW = std::max(3, (int)(4 * g_dpiScale)); + int rowW = rc.right - 2 * g_pop.pad - (hasBar ? barW + g_pop.pad : 0); + int reserve = g_pop.canDelete ? g_pop.rowH : 0; + int last = std::min(n, g_pop.scroll + g_pop.visRows); for (int i = g_pop.scroll; i < last; ++i) { int vis = i - g_pop.scroll; Rect row(g_pop.pad, g_pop.pad + vis * g_pop.rowH, rowW, g_pop.rowH - 2); if (i == g_pop.hot) FillRound(g, T_CARD_HI, row, 7); - RectF tb((REAL)row.X + 9, (REAL)row.Y, (REAL)row.Width - 12, (REAL)row.Height); + RectF tb((REAL)row.X + 9, (REAL)row.Y, (REAL)(row.Width - 12 - reserve), (REAL)row.Height); DrawTextC(g, g_pop.items[i].c_str(), *g_gpUI, (i == g_pop.sel) ? T_ACCENT : T_TEXT, tb, StringAlignmentNear, StringAlignmentCenter); + if (g_pop.canDelete && i == g_pop.hot) { + Rect xr = PopupDeleteRect(rc, vis); + if (i == g_pop.hotX) FillRound(g, T_CARD_LO, xr, 6); + Color xc = (i == g_pop.hotX) ? T_DANGER : T_FAINT; + Pen xpen(xc, 1.8f); + int xpad = std::max(6, (int)(8 * g_dpiScale)); + g.DrawLine(&xpen, xr.X + xpad, xr.Y + xpad, + xr.X + xr.Width - xpad, xr.Y + xr.Height - xpad); + g.DrawLine(&xpen, xr.X + xr.Width - xpad, xr.Y + xpad, + xr.X + xpad, xr.Y + xr.Height - xpad); + } } if (hasBar) { int trackH = rc.bottom - 2 * g_pop.pad; @@ -785,6 +868,7 @@ void ShowSelectPopup(HWND owner, int ctrlId, const std::vector& it g_pop.sel = sel; g_pop.owner = owner; g_pop.ctrlId = ctrlId; + g_pop.canDelete = (ctrlId == ID_SEL_HISTORY); g_pop.visRows = visRows; g_pop.rowH = rowH; g_pop.pad = pad; diff --git a/win-dictation-architecture-engineering-review.html b/win-dictation-architecture-engineering-review.html new file mode 100644 index 0000000..46249d8 --- /dev/null +++ b/win-dictation-architecture-engineering-review.html @@ -0,0 +1,520 @@ + + + + + +Win Dictation — Architecture & Engineering Review + + + + + + + +
    + +
    +

    Architecture · Code Analysis · Engineering Verdict

    +

    Win Dictation: under the hood

    +

    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.

    +
    + ~3,400 lines C++ (app) + Win32 + GDI+ + SDL2 + whisper.cpp + Single .exe, no runtime deps + Target 2-core i5, CPU-only +
    +
    + + + + +
    +
    01

    The verdict, up front

    +
    +

    Bottom line

    +

    A genuinely strong, characterful single-purpose tool that punches well above hobby grade.

    +

    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.

    +

    What holds it back is organizational debt, not algorithmic weakness: a 1,500-line main.cpp, 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.

    +
    +

    The sections below back up every part of that judgement with specifics from the source.

    +
    + + +
    +
    02

    Stack at a glance

    +

    Deliberately lean. No UI framework, no managed runtime, no garbage collector — just the OS and three libraries.

    +
    +

    Language

    C++ (MSVC, Release /O2 /GL /LTCG, AVX2/FMA/F16C)

    +

    UI

    Raw Win32 + GDI+ immediate-mode painted surface

    +

    Audio capture

    SDL2 16 kHz mono, F32

    +

    Inference

    whisper.cpp whisper_full, CPU backend

    +

    Networking

    WinHTTP model downloads, system proxy aware

    +

    Persistence

    Plain INI + UTF-8 text files no database

    +

    Build

    CMake + a PowerShell convenience script

    +

    Footprint

    One .exe + a few DLLs + model tiny RAM, no install

    +
    +

    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).

    +
    + + +
    +
    03

    Architecture & data flow

    +

    A linear pipeline with a single inference step. Audio in, text out, no streaming loop.

    +
    +

    trigger

    Hotkey

    Global RegisterHotKey. Captures the previously focused window.

    +

    capture

    SDL2 mic

    16 kHz mono into an in-memory buffer. Near-zero CPU.

    +

    buffer

    PCM in RAM

    Accumulated under a mutex; RMS energy tracked for the meter.

    +

    inference

    whisper_full

    One pass on a worker thread when you stop. Trim → transcribe → clean.

    +

    deliver

    Insert + paste

    Text to caret, to clipboard, into the prior window.

    +
    +

    Two side channels run alongside the main pipeline: a progress estimator that predicts and smooths the transcription countdown, and a timing model that learns this machine's speed and feeds back into the next prediction. Results return to the UI thread exclusively via PostMessage; shared flags are std::atomic.

    +
    +

    Mental model

    +

    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.

    +
    +
    + + +
    +
    04

    The defining decision

    +

    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.

    +

    An earlier version used the classic whisper.cpp streaming approach: a rolling 5–6 second window re-transcribed every ~0.4 seconds. That technique assumes 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.

    +

    The fix wasn't a faster model. It was removing the streaming loop entirely:

    + + + + + + + +
    AspectOld: streaming windowNew: push-to-talk batch
    CPU while speakingPinned — constant re-inferenceNear idle — just buffering
    Inference callsMany per secondExactly one, on stop
    AccuracyLower — partial context windowsHigher — full clip, full context
    UI responsivenessStarved under loadFree until the single pass
    PredictabilityVariable lagPredictable few-second wait
    +

    This is textbook root-cause engineering: the team correctly diagnosed that the bottleneck was the shape 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.

    +
    + + +
    +
    05

    Threading model

    +

    Four threads, one rule: only the UI thread touches the UI. Everything else reports back by message.

    + + + + + + +
    ThreadLifetimeJob
    UI threadWhole appMessage loop, all painting, the 16 ms animation timer and 50 ms update timer.
    Model preloadDetached, onceLoads the Whisper context off the UI thread at startup so the window appears instantly.
    Transcribe workerPer clipRuns whisper_full; posts WM_APP_PROGRESS during and WM_APP_RESULT when done.
    DownloaderPer downloadWinHTTP fetch on its own thread; posts WM_APP_DLPROGRESS.
    +

    Cross-thread state is handled with discipline rather than locks where possible: std::atomic booleans (m_recording, m_busy, m_abort, g_modelLoaded, g_modelOk) 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; stop_and_transcribe swaps the buffer out under the same lock before handing it to the worker. That swap-not-copy handoff is a nice touch.

    +
    // transcriber.cpp — physical cores, not logical, by design
    +int Transcriber::default_threads() {
    +    unsigned hc = std::thread::hardware_concurrency();
    +    if (hc <= 2) return (int)std::max(1u, hc);
    +    return (int)(hc / 2);   // 4 logical → 2 worker threads
    +}
    +

    Defaulting to physical cores rather than hardware_concurrency() is the correct choice for compute-bound SIMD inference — hyperthreads contend for the same execution units and would only add scheduling overhead.

    +
    + + +
    +
    06

    Source map, file by file

    +

    The app is small and mostly header-only outside the two big translation units. Here's where everything lives.

    + + + + + + + + + + + +
    FileRoleNotes
    main.cppWindow, painting, interaction, settings view, clipboard, paste, model selection, popups~1,500 lines. The monolith — see §13.
    transcriber.{h,cpp}SDL capture, Whisper preload/inference, progress & abort callbacksClean, well-scoped class. The model layer.
    timing.hPer-model least-squares timing model + live progress estimator + INI persistenceThe standout module. See §08.
    history.hSession text files, UTF-8 r/w with BOM, index, pruning to 100Self-contained, header-only.
    downloader.hWinHTTP model downloader on a background thread.part + atomic rename, cancel, proxy-aware.
    stats.hLifetime usage totals + derived figures (wpm, real-time factor, time saved)INI-backed, header-only.
    settings.hApp settings read/write via GetPrivateProfile*Simple and transparent.
    text_util.h · logging.hTranscript concatenation; timestamped file logTiny helpers.
    tests/test_core.cppUnit checks: append logic, bad-model handling, real-WAV transcription, progress monotonicityModest but meaningful. Built as test-core.
    +

    The decision to make most subsystems header-only and independent (timing.h, stats.h, history.h, downloader.h, settings.h) is a good one for a project this size: each is cohesive, individually readable, and free of cross-dependencies. The contrast with main.cpp — which absorbs everything else — is stark.

    +
    + + +
    +
    07

    Deep dive: the single-surface UI engine

    +

    There are no buttons. Everything you see is painted onto one double-buffered surface — and that's a deliberate fix, not a shortcut.

    +

    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 WS_CLIPCHILDREN punches per child, plus the edit's themed border. Rather than chase pixel borders, the rebuild eliminated the cause: collapse the controls into one painted region.

    +

    The model is a small immediate-mode system:

    +
      +
    • A flat Widget g_w[] array — each entry is a kind, a rectangle, and hover/pressed/anim state. No HWNDs.
    • +
    • LayoutWidgets() positions them; PaintSurface() draws each into an off-screen DC with GDI+, then blits once (no flicker).
    • +
    • HitTest() maps a click point to a widget; OnClick() dispatches the action.
    • +
    • An animation clock eases each widget's anim toward a target (hover 0.6, active 1.0) on a 16 ms timer that stops itself when nothing is moving — no idle CPU burn.
    • +
    +

    Two "views" — Main and Settings — render onto the same surface, toggled by SwitchView(). Dropdowns (mic, history) are the one exception: they're real top-level WS_POPUP windows, because a surface-painted dropdown would render behind the transcript edit (a child HWND always paints above its parent's surface). That's a correct, well-reasoned exception.

    +
    +

    A sign of maturity

    +

    The popup code carries a comment never to open a MessageBox from inside it — because WA_INACTIVE self-destroys the popup mid-handler, causing a use-after-free. Recognising that class of Win32 lifetime bug, and the GDI+ "GetHDC locks the Graphics object" trap documented elsewhere, shows real depth.

    +
    +

    The one real child window that survives is the transcript EDIT — kept because a hand-rolled text editor with selection, scrolling, IME and undo is genuinely not worth rebuilding. Pragmatic.

    +

    The cost of this approach

    +

    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.

    +
    + + +
    +
    08

    Deep dive: the progress estimator

    +

    The crown jewel. Most apps fake a progress bar; this one runs a small statistical model that learns your machine.

    +

    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 up. timing.h solves both. It has two parts.

    +

    1 — A learned timing model

    +

    Processing time is modelled as a linear function of audio length, proc = a + b·audio, fitted by decayed online least-squares. 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.

    +
    void add_sample(double audio_sec, double proc_sec) {
    +    const double decay = 0.97;
    +    n*=decay; sx*=decay; sy*=decay; sxx*=decay; sxy*=decay;
    +    n+=1; sx+=audio_sec; sy+=proc_sec;
    +    sxx+=audio_sec*audio_sec; sxy+=audio_sec*proc_sec;
    +    recompute();   // closed-form slope/intercept
    +}
    +

    2 — A live estimator that only counts down

    +

    On stop, begin(predict) seeds a predicted total. As Whisper reports chunk progress, on_whisper() folds it in as a measurement via an EMA (α = 0.5) — nudging the estimate without the jumpy jumps. Meanwhile tick() advances a displayed "remaining" value that is strictly monotonic downward, 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.

    +
    void tick(double dt, float& out_frac, float& out_remaining) {
    +    t += dt; disp_rem -= dt;
    +    double raw_rem = std::max(0.0, T_hat - t);
    +    double err = raw_rem - disp_rem;
    +    if (err < 0) disp_rem += std::max(err, -maxCatchUp*dt);  // catch up, never jump back
    +    double frac = t/(t+disp_rem);
    +    if (frac > 0.95) frac = 0.95;   // park at 95% until done
    +    out_frac = (float)frac; out_remaining = (float)disp_rem;
    +}
    +

    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 feel of the product, not just its function.

    +
    + + +
    +
    09

    Deep dive: the transcriber

    +

    The cleanest class in the project — a tidy boundary between the OS/model and the rest of the app.

    +

    Transcriber owns the Whisper context and the SDL device, and exposes a small, sensible surface: preload, reload, start_recording, stop_and_transcribe, cancel, plus state queries and two callbacks (result, progress). Inference parameters are configured sensibly for dictation — greedy sampling, no timestamps, no prior context, blank/non-speech suppression, temperature 0 — and an abort_callback lets a long transcription be cancelled mid-flight.

    +

    Two small details worth calling out:

    +
      +
    • Silence trimming. Before inference, leading/trailing silence is trimmed from the clip — cheaper and more accurate than transcribing dead air. (Note: this trims the buffer; it does not auto-stop recording — see the doc-drift note in §13.)
    • +
    • Output cleanup. clean_text() strips Whisper's [BLANK_AUDIO] / [NOISE] artifacts and trims whitespace, so the user never sees model noise.
    • +
    +

    The class is also defensively coded: a missing model file makes preload return false cleanly (the test suite verifies this), start_recording bails if a device won't open, and clips under ~0.3 s short-circuit to an empty result rather than invoking the model.

    +
    + + +
    +
    10

    History, downloads & persistence

    +

    No database, no registry sprawl — everything is a file next to the executable. Transparent and portable.

    +

    Session history

    +

    Each session is one UTF-8 text file in history\, named by timestamp. The clever bit is live archiving: the first clip of a session creates the file; subsequent clips rewrite the same 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 g_sessionPath global plus a FinalizeSession() 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.

    +
    +

    A real bug was fixed here

    +

    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.

    +
    +

    Model downloads

    +

    The downloader is more robust than it needed to be, in a good way: it streams to a .part 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 .part files at startup.

    +

    Settings, timing & stats

    +

    All three live in a single win-dictation.ini under different sections — app settings, per-model timing accumulators, and lifetime stats. Using the OS's own GetPrivateProfile* 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.

    +
    + + +
    +
    11

    Anatomy of one dictation

    +

    Following a single clip end-to-end ties the whole system together.

    +
      +
    1. WM_HOTKEY fires → the app records g_prevForeground and the current selection (EM_GETSEL) so it knows where to paste and where to insert.
    2. +
    3. g_tx.start_recording() opens the SDL device; the audio callback appends PCM under the capture mutex and updates the RMS energy meter.
    4. +
    5. The 50 ms UI timer animates the level meter and ticks the on-screen recording clock.
    6. +
    7. Second WM_HOTKEYg_est.begin(g_timing.predict(len)) seeds the progress estimate; g_tx.stop_and_transcribe() swaps the buffer to a worker thread.
    8. +
    9. The worker runs run_inference()whisper_full. Whisper's progress callback posts WM_APP_PROGRESS; the estimator's on_whisper() EMA-folds it in.
    10. +
    11. On completion the worker posts WM_APP_RESULT.
    12. +
    13. The UI thread then, in order: snaps progress to 100%, records a real timing sample (add_sample + SaveTiming), updates lifetime stats, inserts the text at the saved caret with smart spacing via EM_REPLACESEL (undoable), archives the session, copies to the clipboard, and pastes into g_prevForeground.
    14. +
    +

    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.

    +
    + + +
    +
    12

    What's done well

    +
    +

    The architecture fits the hardware

    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.

    +

    The progress estimator is exceptional

    Decayed online least-squares + EMA fusion + a strictly monotonic countdown is far beyond what the task demanded — and it shows in the feel.

    +

    Seam-free UI by elimination, not patching

    Collapsing nine child windows into one painted, double-buffered, DPI-aware, self-throttling surface removed the problem at its source.

    +

    Clean module boundaries (outside main)

    Header-only, dependency-free subsystems (timing, history, downloader, stats, settings) are each individually readable and testable.

    +

    Robustness in the right places

    Atomic rename downloads, crash-safe live history, graceful missing-model handling, cancellable inference, single-instance mutex, model preload off the UI thread.

    +

    Real product thoughtfulness

    Smart insertion spacing, undoable edits, auto-paste into the prior window, auto-hide, learned timing, friendly stats. These are details a careful builder adds.

    +
    +
    + + +
    +
    13

    What holds it back

    +

    All fixable, and none of it affects the running app. But it's exactly what a newcomer trips over.

    +
    +

    main.cpp is a 1,500-line god object

    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.

    +

    Vestigial child windows & duplicate code paths

    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 WM_COMMAND handlers duplicate the painted-widget OnClick logic — e.g. the Copy action exists in two near-identical places. Leftovers from the rebuild that should be deleted.

    main.cpp — CreateWindow(...) blocks then ShowWindow(..., SW_HIDE)

    +

    Documentation describes a different app

    This is the most actively misleading issue. CUDA-SETUP.md, QUICK-REBUILD-GPU.md and FIXES-APPLIED.md describe a streaming, VAD, ring-buffer, 24-thread, RTX 3090 design that no longer exists. build.ps1 still hunts for CUDA and downloads base.en though the product is a CPU-only tiny.en app. TESTING.md references a test-audio.exe the CMake doesn't build (it builds test-core). A newcomer reading the docs would form a completely wrong mental model.

    +

    The README claims a feature that isn't there

    Both README.md and CHANGES.md 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 trimmed before inference, which is likely the source of the confusion.) Either implement it or remove the claim.

    main.cpp WM_TIMER recording branch vs README "Audio Processing"

    +

    Heavy reliance on global mutable state

    The UI is coordinated through dozens of file-scope globals (g_*), 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.

    +

    Build declares C++11 but uses C++17

    CMakeLists.txt sets CMAKE_CXX_STANDARD 11, yet the code uses std::size() (C++17). It compiles only because MSVC's default is newer. Set the standard to 17 explicitly so the build is honest and portable.

    +

    Minor: redundant color systems & no in-app hotkey editor

    Three overlapping palettes coexist (CR_* COLORREF, T_* GDI+ Color, C_* aliases). And changing the hotkey requires hand-editing the INI — a natural gap given the polished Settings screen already exists.

    +
    +
    + + +
    +
    14

    Recommendations

    +

    If the next session had a short to-do list, this would be it — ordered by payoff for effort.

    +
      +
    1. Purge or archive the stale docs high

      Delete or clearly mark CUDA-SETUP.md, QUICK-REBUILD-GPU.md, FIXES-APPLIED.md, TESTING.md and DESIGN.md as describing the retired streaming design. This is the single biggest improvement to onboarding, and it's nearly free.

    2. +
    3. Reconcile the README with reality high

      Remove the "500 ms silence auto-end" claim (or implement it). Update the model table and build commands to match the CPU-only product.

    4. +
    5. Delete the vestigial child windows medium

      Remove the hidden owner-draw controls and their dead WM_COMMAND handlers so there's exactly one code path per action. De-duplicate Copy.

    6. +
    7. Break up main.cpp medium

      Lift the Settings view, the popup window, and the GDI+ drawing helpers into their own files. Even a mechanical split dramatically improves navigability.

    8. +
    9. Fix the build standard & align build.ps1 medium

      Set CMAKE_CXX_STANDARD 17. Strip the CUDA detection from the build script and default it to fetching tiny.en.

    10. +
    11. Add an in-app hotkey picker low

      The Settings surface already exists; surfacing the hotkey there closes an obvious UX gap and removes a troubleshooting step.

    12. +
    +
    + + +
    +
    15

    Scorecard & final word

    +
    +
    Architecture & design9.2
    +
    Performance fit for target9.3
    +
    UX & polish8.7
    +
    Robustness & error handling7.5
    +
    Code organization5.5
    +
    Maintainability5.8
    +
    Testing4.8
    +
    Documentation accuracy3.8
    +
    7.1Strong, with cleanup debt.
    An impressive core wrapped in organizational and documentation drift. The engineering earns a high mark; the housekeeping pulls the average down.
    +
    +
    +

    Final word

    +

    Win Dictation is a good codebase — at its core, an impressive one. 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.

    +

    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.

    +
    + +
    + +
    + + + + + diff --git a/win-dictation-user-manual.html b/win-dictation-user-manual.html new file mode 100644 index 0000000..1f213cc --- /dev/null +++ b/win-dictation-user-manual.html @@ -0,0 +1,567 @@ + + + + + +Win Dictation — User Manual + + + + + + + +
    + + +
    +

    User Manual · v3

    +
    +
    + +
    +

    Win Dictation

    +
    +

    A push-to-talk speech-to-text utility for Windows. Press a hotkey, speak, and your words land in whatever app you were just using — fully offline, powered by Whisper.

    +
    + Offline · runs on your machine + Hotkey Ctrl+Shift+Space + CPU-only · no GPU required + Whisper · tiny.en → small.en +
    +
    + + + + + +
    +
    01

    What Win Dictation is

    +

    A small, focused desktop tool that turns your voice into text anywhere on Windows — no browser, no cloud, no account.

    +

    Win Dictation sits quietly in your system tray. When you want to dictate, you press a global hotkey, speak a sentence or a paragraph, then press the hotkey again. A second or two later the transcribed text is copied to your clipboard and — by default — automatically pasted into whatever window you were using: your email, a chat box, a code editor, a document.

    +

    Everything happens on your computer. The audio never leaves the machine; transcription runs locally using whisper.cpp, a compact build of OpenAI's Whisper model. That means it works on a plane, behind a firewall, or anywhere with no internet at all.

    +
    +

    Built for modest hardware

    +

    This build is tuned for an ordinary CPU-only laptop — the kind with two physical cores and no graphics card. It uses a fast, lightweight model by default and keeps your processor nearly idle while you speak, only working hard for a brief moment after you stop.

    +
    +
    + + +
    +
    02

    Quick start in 60 seconds

    +

    Three steps. No setup, no sign-in.

    +
      +
    1. +

      Launch win-dictation.exe

      +

      The window opens and a microphone icon appears in your system tray. Wait a moment for the status line to change from “Loading model…” to “Ready”.

      +
    2. +
    3. +

      Click into wherever you want the text, then press Ctrl+Shift+Space

      +

      Put your cursor in the email, chat box, or document first. Then hit the hotkey. The Record button turns red and a green level meter shows it’s hearing you.

      +
    4. +
    5. +

      Speak, then press the hotkey again

      +

      Talk naturally. When you’re done, press Ctrl+Shift+Space once more. A short progress bar runs, and your words appear — pasted straight into the app you were using.

      +
    6. +
    +
    +

    That's the whole loop

    +

    Press to start, speak, press to finish. The text is on your clipboard and dropped into your previous window. You never have to click back into Win Dictation.

    +
    +
    + + +
    +
    03

    The interface, explained

    +

    The whole app is a single window. Here is every control on it.

    + +
    +
    +
    Dictation— ▢ ✕
    +
    +
    +
    Record1
    +
    2
    +
    3
    +
    +
    Ready  •  2 threads4
    +
    Win-dictate is a desktop, whisper powered, speech to text application!5
    +
    +
    Microphone (Realtek Audio)6
    +
    History7
    +
    +
    CopyPasteClear8
    +
    +
    +
    + +
    +
    1Record / StopThe big pill. Click to start; it turns red and reads “Stop” while recording. Same as the hotkey.
    +
    2PinKeeps the window always on top. Blue when active. On by default.
    +
    3Settings (cog)Opens the Settings screen for choosing and downloading models, and viewing your stats.
    +
    4Status lineShows “Ready” and the thread count when idle, a timer while recording, and a live countdown while transcribing.
    +
    5Transcript boxWhere text appears. You can edit it freely — click in and type, fix, or delete.
    +
    6Microphone selectorChoose which input device to record from. Opens a dropdown of all your mics.
    +
    7HistoryOpens a list of past dictation sessions you can reload — or delete individually.
    +
    8Copy · Paste · ClearCopy the transcript, paste it into your last window, or clear the box (saving it to history first).
    +
    + +

    The status line is your dashboard

    +

    That one line of dim text under the Record button tells you everything about the app's state:

    + + + + + + + + +
    You seeIt means
    Loading model…Starting up — the speech model is being read into memory. Wait a second.
    Ready · 2 threadsIdle and ready to record. The number is how many CPU threads it will use.
    Recording 0:14Listening. The timer counts how long you've been speaking. A green level meter pulses with your voice.
    Transcribing 0:14 · 62% · 3s leftWorking on your audio. The bar fills and the countdown ticks down to zero.
    Pasted / CopiedDone. Your text went to the clipboard (and into your previous window if auto-paste is on).
    No speech detectedThe clip was silent or too short to transcribe. Nothing was added.
    +
    + + +
    +
    04

    How dictation works

    +

    Win Dictation is push-to-talk, not live streaming. You record a whole clip, then it transcribes the whole thing at once.

    +

    This is a deliberate design choice. Instead of trying to transcribe word-by-word as you speak (which pins a CPU at 100% and stutters on a modest laptop), Win Dictation simply records your audio cheaply while you talk, then does one fast transcription pass the moment you stop. The result is calmer, more accurate, and far lighter on your battery.

    + +

    What happens when you record

    +
      +
    1. You press the hotkey. The app remembers which window you were in, and where your text cursor was sitting inside the transcript box.
    2. +
    3. It records. Audio is captured at 16 kHz and held in memory. CPU use stays near zero. The level meter shows it's hearing you.
    4. +
    5. You press the hotkey again. Recording stops. Silence at the start and end of your clip is trimmed away automatically.
    6. +
    7. It transcribes. The full clip is run through Whisper once. The progress bar shows a smooth, self-calibrating estimate of how long it will take.
    8. +
    9. The text lands. It's inserted at your cursor (with smart spacing so words don't run together), copied to the clipboard, and pasted into your previous window.
    10. +
    + +
    +

    There is no “stop on silence”

    +

    Recording continues until you press the hotkey again (or click Stop). Pausing to think won't end the session — take your time. The only automatic stop is a safety cap at 10 minutes per clip.

    +
    + +

    The transcript box is editable

    +

    Unlike many dictation tools, the text area is fully editable. Click anywhere in it to fix a misheard word, delete a stray sentence, or type manually. When you dictate again, the new text is inserted at your cursor — so you can build up a document piece by piece, placing each new chunk exactly where you want it.

    +
    + + +
    +
    05

    Keyboard & hotkeys

    +

    Two global shortcuts work from anywhere in Windows, even when the window is hidden.

    +
    Ctrl+Shift+Space
    Start / stop recording. The core hotkey. Press once to begin, once more to transcribe. If a transcription is already running, pressing it again cancels it.
    +
    Ctrl+Shift+H
    Hide the window. Tucks Win Dictation away to the tray (and cancels any recording in progress). The hotkeys still work while hidden.
    +
    Esc (in a dropdown)
    Closes an open Microphone or History popup without choosing anything.
    +
    Delete (in History)
    Deletes the history entry you're hovering over.
    +
    +

    If the hotkey doesn't work

    +

    You may see Hotkey in use — edit win-dictation.ini. That means another program already grabbed Ctrl+Shift+Space. You can change it by editing the hkMods and hkVk values in the win-dictation.ini file (see the FAQ).

    +
    +
    + + +
    +
    06

    Auto-paste & the active window

    +

    The feature that makes Win Dictation feel invisible: it types into other apps for you.

    +

    When you trigger recording, the app notes which window had focus a moment before. After transcription, if Auto-paste is enabled (it is by default), it brings that window back to the front and pastes your text there automatically. You dictate, and the words appear in your email — you never touch Win Dictation's own window.

    +

    If you'd rather paste manually, turn auto-paste off in the tray menu. The text is always still copied to your clipboard, and the Paste button will send it to your last window on demand.

    +
    +

    Pair it with Auto-hide

    +

    Turn on Auto-hide (tray menu) and the window disappears the instant it pastes. Combined with the global hotkey, dictation becomes a pure overlay: tap, speak, tap, and your words flow into whatever you're doing.

    +
    +
    + + +
    +
    07

    History & sessions

    +

    Every dictation session is saved automatically, so you never lose a transcript.

    +

    A session is everything you dictate between clears. As soon as you finish your first clip, Win Dictation writes it to a timestamped text file. Each additional clip in that session updates the same file — so one session is one tidy file, kept up to date as you go.

    + +

    Browsing and reloading

    +

    Click the History selector to open the list. Each entry shows its date, time, and a short preview of the text. Click one to load it back into the transcript box. The most recent sessions are at the top, and up to 100 sessions are kept (older ones are pruned automatically).

    + +

    Deleting entries

    +

    Hover over any history row and a small appears on its right edge — click it to delete that session's file. You can also press Delete on the hovered row. The list stays open after each delete so you can tidy up several at once. The window even shrinks to fit as the list gets shorter.

    +
    +

    Deletion is permanent

    +

    Removing a history entry deletes its text file from disk immediately — there is no confirmation prompt and no undo. The files themselves live in a history\ folder next to the program, if you ever want to back them up.

    +
    +
    + + +
    +
    08

    Models & the Settings screen

    +

    A model is the AI that turns sound into words. Bigger models are more accurate but slower. Click the cog to manage them.

    +

    The Settings screen lists every model Win Dictation can use. Each row shows the model's name, file size, and a short hint. Installed models have a filled radio button you can select; ones you don't have yet show a Download button that fetches them directly from Hugging Face with a live progress percentage.

    + + + + + + + + + +
    ModelSizeCharacter
    tiny.en~75 MBThe default. Quick and light — ideal for this CPU.fastest
    tiny.en-q8_0~42 MBSame speed, smaller file (compressed).fastest
    base.en-q5_1~59 MBA noticeable accuracy bump for little cost.good balance
    base.en~142 MBMore accurate; still reasonable on two cores.balance
    small.en-q5_1~182 MBAccurate, but slow on this machine.slow here
    small.en~466 MBThe most accurate offered — and the slowest.slowest
    + +

    Choosing a model

    +
      +
    1. Open Settings (the cog), and find the model you want.
    2. +
    3. If it isn't installed, click Download and wait for it to reach 100%. You can cancel mid-download, and only one downloads at a time.
    4. +
    5. Click the model's row to select it (the dot fills in).
    6. +
    7. Click Save. The app reloads with the new model and remembers your choice. Back or Cancel discards any change.
    8. +
    +
    +

    A good rule of thumb

    +

    Stick with tiny.en or base.en-q5_1 for everyday use on a two-core laptop. Step up to base.en if you want better accuracy and don't mind waiting a beat longer. The small models are best reserved for short, important clips where accuracy matters most.

    +
    + +

    The progress bar learns your machine

    +

    You'll notice the transcription countdown is unusually accurate. That's because Win Dictation measures how fast your specific computer is with each model and remembers it. The more you use a model, the better its time estimates become — the bar counts steadily down rather than jumping around.

    +
    + + +
    +
    09

    System tray & options

    +

    Win Dictation lives in the tray. Right-click its icon for the quick options menu.

    +
    +

    Auto-paste

    Paste transcribed text into your previous window automatically. On by default.

    +

    Always on top

    Keep the window above other apps. Mirrors the Pin button. On by default.

    +

    Auto-hide

    Hide the window automatically right after it pastes. Off by default.

    +

    Exit

    Fully quits the app. Closing the window only hides it to the tray — use this to stop it entirely.

    +
    +

    Double-clicking the tray icon brings the window back. Closing the window with the doesn't quit — it just hides, so the hotkey keeps working in the background. Your window position, pinned state, and these toggles are all remembered between launches.

    +
    + + +
    +
    10

    Your statistics

    +

    Scroll down in Settings to see a running tally of your dictation habits.

    +

    Win Dictation quietly keeps lifetime totals and turns them into friendly figures:

    +
      +
    • Total audio dictated and the number of clips.
    • +
    • Word count, plus your average speaking pace in words per minute.
    • +
    • Total processing time and your machine's real-time factor (e.g. “4× real-time” means it transcribes four seconds of audio every second).
    • +
    • Your longest single clip.
    • +
    • An estimate of the time you've saved versus typing at 40 wpm.
    • +
    +

    These numbers are stored locally and are just for your own curiosity — nothing is reported anywhere.

    +
    + + +
    +
    11

    Tips for best results

    +
    +

    Click first, then dictate

    Put your text cursor in the destination app before pressing the hotkey, so auto-paste knows where to send the words.

    +

    Speak in natural phrases

    Whisper transcribes best with full sentences and natural rhythm. You don't need to over-enunciate or pause between words.

    +

    Pick the right mic

    If accuracy is poor, check the Microphone selector — a headset or dedicated mic beats a distant laptop mic in a noisy room.

    +

    Match model to task

    Quick chat replies? tiny.en. A careful paragraph of prose? Try base.en for fewer corrections.

    +

    Edit in place

    Fix the odd misheard word right in the transcript box, then Copy — faster than re-recording the whole thing.

    +

    Let it warm up

    The very first transcription after launch can be a touch slower as the model settles into memory. It's quick from then on.

    +
    +
    + + +
    +
    12

    Troubleshooting

    + + + + + + + + + +
    SymptomWhat to do
    “Model not found”The selected .bin model file is missing. Open Settings and download a model (start with tiny.en), or place a .bin file in the models\ folder next to the program and restart.
    “Hotkey in use”Another app owns Ctrl+Shift+Space. Change the hotkey in win-dictation.ini, or close the conflicting app. You can still record by clicking the Record button.
    “Microphone error”The chosen input device couldn't be opened. Pick a different mic from the selector, make sure it isn't in use by another app, and check Windows mic permissions.
    “No speech detected”The clip was silent, too quiet, or under ~0.3 seconds. Check the level meter moves when you talk, and confirm the right mic is selected.
    Text pasted into the wrong placeAuto-paste targets whatever window was focused just before you pressed the hotkey. Click into your destination first. If in doubt, turn auto-paste off and use the Paste button deliberately.
    Transcription feels slowYou're likely on a larger model. Switch to tiny.en or base.en-q5_1 in Settings. The small models are inherently slow on a two-core CPU.
    Window vanishedIt hid to the tray. Double-click the tray icon, press Ctrl+Shift+H, or right-click the tray icon → Show Window.
    +
    + + +
    +
    13

    FAQ & where things live

    + +

    Does my voice get sent anywhere?

    +

    No. All recording and transcription happen on your computer. The only time the app reaches the internet is when you click Download to fetch a model file.

    + +

    Can it run completely offline?

    +

    Yes — once you have at least one model installed, no internet is needed ever again.

    + +

    What languages does it support?

    +

    This build is tuned for English (the .en models). It's optimised for accuracy and speed in English on modest hardware.

    + +

    Where are my files kept?

    +

    Everything sits next to win-dictation.exe:

    + + + + + + +
    LocationWhat's there
    models\Your downloaded .bin speech models.
    history\One text file per dictation session.
    win-dictation.iniYour settings, hotkey, window position, learned timing, and statistics.
    win-dictation.logA simple timestamped activity log, handy if something misbehaves.
    + +

    How do I change the hotkey?

    +

    Open win-dictation.ini in any text editor and edit the hkMods and hkVk values under [app] (they're standard Windows key codes), then restart the app. A built-in settings option for this is a natural future addition.

    + +

    Why is it called “push-to-talk” if I'm not holding a button?

    +

    It's toggle-style push-to-talk: one press starts, another stops. You're not transcribing live as you speak — you capture a clip, then it's processed. This is what keeps it fast and light on a CPU-only machine.

    + + +
    + +
    + + + + +