Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

chore: add CI workflow, remove old mic-check, update CLAUDE.md

Gabriel Stein3c7d5dbe8735
diff --git a/.github/workflows/build-windows-mic-listener.yml b/.github/workflows/build-windows-mic-listener.yml
new file mode 100644
index 000000000..1b30fc226
--- /dev/null
+++ b/.github/workflows/build-windows-mic-listener.yml
@@ -0,0 +1,73 @@
+name: Build Windows Mic Listener
+
+on:
+ push:
+ paths:
+ - 'resources/windows-mic-listener.c'
+ - '.github/workflows/build-windows-mic-listener.yml'
+ branches:
+ - main
+ workflow_dispatch:
+ inputs:
+ version:
+ description: 'Version tag (e.g., 1.0.0)'
+ required: false
+ default: '1.0.0'
+ type: string
+
+permissions:
+ contents: write
+
+jobs:
+ build:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Setup MSVC
+ uses: microsoft/setup-msbuild@v2
+
+ - name: Setup MSVC environment
+ uses: ilammy/msvc-dev-cmd@v1
+
+ - name: Compile Windows Mic Listener
+ run: |
+ cl /O2 /nologo resources/windows-mic-listener.c /Fe:windows-mic-listener.exe ole32.lib oleaut32.lib
+ shell: cmd
+
+ - name: Verify binary
+ run: |
+ if (Test-Path "windows-mic-listener.exe") {
+ Write-Host "Binary built successfully"
+ Get-Item "windows-mic-listener.exe" | Select-Object Name, Length
+ } else {
+ Write-Error "Binary not found"
+ exit 1
+ }
+ shell: pwsh
+
+ - name: Create zip archive
+ run: |
+ Compress-Archive -Path windows-mic-listener.exe -DestinationPath windows-mic-listener-win32-x64.zip
+ shell: pwsh
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: windows-mic-listener
+ path: windows-mic-listener-win32-x64.zip
+
+ - name: Create or update release
+ uses: softprops/action-gh-release@v2
+ with:
+ tag_name: windows-mic-listener-v${{ inputs.version || '1.0.0' }}
+ name: Windows Mic Listener v${{ inputs.version || '1.0.0' }}
+ body: |
+ Prebuilt Windows mic listener binary for event-driven microphone detection.
+
+ Uses WASAPI IAudioSessionManager2 to monitor capture sessions.
+ Supports --exclude-pid to filter out OpenWhispr's own mic usage.
+ files: windows-mic-listener-win32-x64.zip
+ make_latest: false
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/CLAUDE.md b/CLAUDE.md
index 075254c29..509fa37a9 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -42,8 +42,10 @@ OpenWhispr is an Electron-based desktop dictation application that uses whisper.
### Native Resources (resources/)
- **windows-key-listener.c**: C source for Windows low-level keyboard hook (Push-to-Talk)
+- **windows-mic-listener.c**: C source for WASAPI mic session monitor (event-driven mic detection)
+- **macos-mic-listener.swift**: Swift source for CoreAudio mic property listener (event-driven mic detection)
- **globe-listener.swift**: Swift source for macOS Globe/Fn key detection
-- **bin/**: Directory for compiled native binaries (whisper-cpp, nircmd, key listeners)
+- **bin/**: Directory for compiled native binaries (whisper-cpp, nircmd, key/mic listeners)
### Helper Modules (src/helpers/)
@@ -73,6 +75,23 @@ OpenWhispr is an Electron-based desktop dictation application that uses whisper.
- Supports compound hotkeys (e.g., `Ctrl+Shift+F11`, `CommandOrControl+Space`)
- Emits `key-down` and `key-up` events for push-to-talk functionality
- Graceful fallback if binary unavailable
+- **meetingDetectionEngine.js**: Orchestrates meeting detection from all sources
+ - Gates notifications during recording (tap-to-talk and push-to-talk)
+ - Post-recording cooldown (2.5s) before showing queued notifications
+ - Priority-based coalescing (process > audio) — one notification, not three
+- **meetingProcessDetector.js**: Detects running meeting apps
+ - macOS: Event-driven via `systemPreferences.subscribeWorkspaceNotification` (zero CPU)
+ - Windows/Linux: Shared `processListCache` polling (30s interval)
+- **audioActivityDetector.js**: Detects microphone usage for unscheduled meetings
+ - macOS: Event-driven via `macos-mic-listener` binary (CoreAudio property listeners)
+ - Windows: Event-driven via `windows-mic-listener.exe` (WASAPI sessions, self-PID exclusion)
+ - Linux: Event-driven via `pactl subscribe` (PulseAudio source-output events)
+ - All platforms: Graceful fallback to polling if native approach fails
+- **processListCache.js**: Shared singleton process list cache (5s TTL, `ps-list` npm)
+- **googleCalendarManager.js**: Google Calendar sync with exponential backoff
+ - 10s socket timeout on API requests
+ - Backoff: 2min → 4min → 8min → cap 30min on consecutive failures
+ - Reset to normal interval on success
- **menuManager.js**: Application menu management
- **tray.js**: System tray icon and menu
- **whisper.js**: Local whisper.cpp integration and model management
@@ -141,8 +160,10 @@ OpenWhispr is an Electron-based desktop dictation application that uses whisper.
- **download-llama-server.js**: Downloads llama.cpp server for local LLM inference
- **download-nircmd.js**: Downloads nircmd.exe for Windows clipboard operations
- **download-windows-key-listener.js**: Downloads prebuilt Windows key listener binary
+- **download-windows-mic-listener.js**: Downloads prebuilt Windows mic listener binary
- **download-sherpa-onnx.js**: Downloads sherpa-onnx binaries for Parakeet support
- **build-globe-listener.js**: Compiles macOS Globe key listener from Swift source
+- **build-macos-mic-listener.js**: Compiles macOS mic listener from Swift source
- **build-windows-key-listener.js**: Compiles Windows key listener (for local development)
- **run-electron.js**: Development script to launch Electron with proper environment
- **lib/download-utils.js**: Shared utilities for downloading and extracting files
@@ -396,6 +417,42 @@ On GNOME Wayland, Electron's `globalShortcut` API doesn't work due to Wayland's
- GNOME format: `<Alt>r`, `<Control><Shift>space`
- Backtick (`) → `grave` in GNOME keysym format
+### 15. Meeting Detection (Event-Driven)
+
+Detects meetings via three independent sources, orchestrated by `MeetingDetectionEngine`:
+
+**Architecture**:
+- `MeetingDetectionEngine` listens to events from `MeetingProcessDetector` and `AudioActivityDetector`
+- `GoogleCalendarManager` provides calendar context (imminent events, active meetings)
+- All three sources feed into a unified notification pipeline
+
+**Process Detection** (known meeting apps — Zoom, Teams, Webex, FaceTime):
+- macOS: `systemPreferences.subscribeWorkspaceNotification` — zero CPU, instant detection
+- Windows/Linux: `processListCache` shared polling (30s interval, `ps-list` npm)
+
+**Microphone Detection** (unscheduled/browser meetings like Google Meet):
+- macOS: `macos-mic-listener` binary — CoreAudio `kAudioDevicePropertyDeviceIsRunningSomewhere` property listeners with hot-plug support
+- Windows: `windows-mic-listener.exe` — WASAPI `IAudioSessionManager2` session monitoring, `--exclude-pid` for self-mic exclusion
+- Linux: `pactl subscribe` — PulseAudio source-output events
+- All platforms: Graceful fallback to polling if native binary/command unavailable
+
+**UX Rules**:
+- During recording (tap-to-talk or push-to-talk): ALL notifications suppressed
+- After recording: 2.5s cooldown before showing queued notifications
+- Multiple signals coalesced: process > audio priority, one notification shown
+- Calendar-aware: if imminent calendar event exists, notification shows event name
+- Active calendar meeting recording: all detections suppressed
+
+**Binary Distribution**:
+- macOS: Compiled from Swift source via `scripts/build-macos-mic-listener.js` during `compile:native`
+- Windows: Prebuilt binary downloaded via `scripts/download-windows-mic-listener.js` during `prebuild:win`
+- CI workflow: `.github/workflows/build-windows-mic-listener.yml` auto-builds on push to main
+
+**Calendar Sync Resilience**:
+- 10s socket timeout on all Google Calendar API requests
+- Exponential backoff on consecutive failures: 2min → 4min → 8min → cap 30min
+- Reset to normal 2min interval on any successful sync
+
## Development Guidelines
### Internationalization (i18n) — REQUIRED
@@ -443,6 +500,9 @@ const { t } = useTranslation();
- [ ] Verify Windows Push-to-Talk with compound hotkeys
- [ ] Test GNOME Wayland hotkeys (if on GNOME + Wayland)
- [ ] Verify activation mode selector is hidden on GNOME Wayland
+- [ ] Verify meeting detection works with event-driven mode (check debug logs for "event-driven")
+- [ ] Test meeting notification suppression during recording
+- [ ] Test post-recording cooldown (notifications shouldn't flash immediately)
### Common Issues and Solutions
@@ -479,6 +539,13 @@ const { t } = useTranslation();
- To compile locally: install Visual Studio Build Tools or MinGW-w64
- CI workflow (`.github/workflows/build-windows-key-listener.yml`) auto-builds on push to main
+6. **Meeting Detection Not Working**:
+ - Check debug logs for "event-driven" vs "polling" mode
+ - macOS: Verify `macos-mic-listener` binary exists in `resources/bin/` (compiled during `npm run compile:native`)
+ - Windows: Verify `windows-mic-listener.exe` exists in `resources/bin/` (downloaded during `prebuild:win`)
+ - Linux: Verify `pactl` is installed (`pulseaudio-utils` or `pipewire-pulse` package)
+ - If event-driven binary is missing, detection falls back to polling automatically
+
### Platform-Specific Notes
**macOS**:
@@ -540,6 +607,9 @@ const { t } = useTranslation();
- Temporary file cleanup
- Memory usage with large models
- Process timeout protection (5 minutes)
+- Meeting detection uses event-driven OS APIs (near-zero CPU) with polling fallback
+- Process list cache shared between detectors to avoid duplicate `tasklist`/`pgrep` calls
+- Google Calendar sync uses exponential backoff to avoid hammering API on network failures
## Security Considerations
diff --git a/electron-builder.json b/electron-builder.json
index ce156485e..3c8f44efe 100644
--- a/electron-builder.json
+++ b/electron-builder.json
@@ -88,7 +88,7 @@
"src/assets/**/*",
"resources/bin/macos-globe-listener",
"resources/bin/macos-fast-paste",
- "resources/bin/macos-mic-check",
+ "resources/bin/macos-mic-listener",
"resources/bin/macos-text-monitor",
"resources/bin/linux-fast-paste",
"resources/bin/linux-text-monitor",
@@ -101,6 +101,7 @@
"llama-server-*",
"sherpa-onnx-*",
"windows-key-listener*",
+ "windows-mic-listener*",
"windows-text-monitor*",
"windows-fast-paste*",
"*.dylib",
diff --git a/resources/bin/macos-mic-check b/resources/bin/macos-mic-check
deleted file mode 100755
index 8f06c85da..000000000
Binary files a/resources/bin/macos-mic-check and /dev/null differ
diff --git a/resources/macos-mic-check.swift b/resources/macos-mic-check.swift
deleted file mode 100644
index 213bd8422..000000000
--- a/resources/macos-mic-check.swift
+++ /dev/null
@@ -1,27 +0,0 @@
-import CoreAudio
-import Foundation
-
-var systemObject = AudioObjectID(kAudioObjectSystemObject)
-var address = AudioObjectPropertyAddress(
- mSelector: kAudioHardwarePropertyDefaultInputDevice,
- mScope: kAudioObjectPropertyScopeGlobal,
- mElement: kAudioObjectPropertyElementMain
-)
-var deviceID = AudioDeviceID()
-var size = UInt32(MemoryLayout<AudioDeviceID>.size)
-
-let status = AudioObjectGetPropertyData(systemObject, &address, 0, nil, &size, &deviceID)
-guard status == noErr else { print("false"); exit(0) }
-
-var isRunning: UInt32 = 0
-var runningAddress = AudioObjectPropertyAddress(
- mSelector: kAudioDevicePropertyDeviceIsRunningSomewhere,
- mScope: kAudioObjectPropertyScopeInput,
- mElement: kAudioObjectPropertyElementMain
-)
-var runningSize = UInt32(MemoryLayout<UInt32>.size)
-
-let runStatus = AudioObjectGetPropertyData(deviceID, &runningAddress, 0, nil, &runningSize, &isRunning)
-guard runStatus == noErr else { print("false"); exit(0) }
-
-print(isRunning > 0 ? "true" : "false")
diff --git a/resources/macos-mic-listener.swift b/resources/macos-mic-listener.swift
index de54e9bf4..9154e374a 100644
--- a/resources/macos-mic-listener.swift
+++ b/resources/macos-mic-listener.swift
@@ -4,8 +4,6 @@
* Long-running process that monitors microphone usage via CoreAudio property listeners.
* Outputs MIC_ACTIVE / MIC_INACTIVE state transitions to stdout.
*
- * Replaces the fire-and-forget macos-mic-check.swift with an event-driven approach.
- *
* Compile: swiftc -O macos-mic-listener.swift -o macos-mic-listener -framework CoreAudio -framework Foundation
*/
diff --git a/src/helpers/audioActivityDetector.js b/src/helpers/audioActivityDetector.js
index 916c1bd24..5ab8f6f42 100644
--- a/src/helpers/audioActivityDetector.js
+++ b/src/helpers/audioActivityDetector.js
@@ -1,4 +1,4 @@
-const { exec, execFile, spawn } = require("child_process");
+const { exec, spawn } = require("child_process");
const { promisify } = require("util");
const path = require("path");
const fs = require("fs");
@@ -6,7 +6,6 @@ const EventEmitter = require("events");
const debugLogger = require("./debugLogger");
const execAsync = promisify(exec);
-const execFileAsync = promisify(execFile);
const CHECK_INTERVAL_MS = process.platform === "win32" ? 15 * 1000 : 5 * 1000;
const SUSTAINED_THRESHOLD_CHECKS = process.platform === "win32" ? 2 : 3;
@@ -22,7 +21,6 @@ class AudioActivityDetector extends EventEmitter {
this.audioActiveStart = null;
this.hasPrompted = false;
this.lastDismissedAt = null;
- this._micCheckBinary = null;
this._userRecording = false;
this._checking = false;
this._listenerProcess = null;
@@ -357,20 +355,10 @@ class AudioActivityDetector extends EventEmitter {
// ---------------------------------------------------------------------------
_startPolling() {
- if (process.platform === "darwin") this._resolveMicCheckBinary();
this._check();
this.checkInterval = setInterval(() => this._check(), CHECK_INTERVAL_MS);
}
- _resolveMicCheckBinary() {
- const resolved = this._resolveBinary("macos-mic-check");
- if (resolved) {
- this._micCheckBinary = resolved;
- } else {
- debugLogger.warn("macos-mic-check binary not found, falling back to ioreg", {}, "meeting");
- }
- }
-
async _check() {
if (this._checking) return;
if (this.lastDismissedAt && Date.now() - this.lastDismissedAt < COOLDOWN_MS) return;
@@ -431,22 +419,6 @@ class AudioActivityDetector extends EventEmitter {
}
async _checkDarwin() {
- if (this._micCheckBinary) {
- try {
- const { stdout } = await execFileAsync(this._micCheckBinary, [], {
- timeout: 3000,
- encoding: "utf8",
- });
- return stdout.trim() === "true";
- } catch (err) {
- debugLogger.debug(
- "mic-check binary failed, falling back",
- { error: err.message },
- "meeting"
- );
- }
- }
-
try {
const { stdout } = await execAsync(
"ioreg -l -w 0 | grep '\"IOAudioEngineState\" = 1'",