Skip to content

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

Fix meeting detection not resetting after meeting ends

Gabriel Stein72b2600cd910
diff --git a/src/helpers/audioActivityDetector.js b/src/helpers/audioActivityDetector.js
index 4514ae1cf..d32bc954d 100644
--- a/src/helpers/audioActivityDetector.js
+++ b/src/helpers/audioActivityDetector.js
@@ -11,6 +11,7 @@ const CHECK_INTERVAL_MS = process.platform === "win32" ? 15 * 1000 : 3 * 1000;
const SUSTAINED_THRESHOLD_CHECKS = 2;
const SUSTAINED_EVENT_DRIVEN_MS = 2 * 1000;
const COOLDOWN_MS = 5 * 60 * 1000;
+const INACTIVE_RESET_MS = 60 * 1000;
const EXEC_OPTS = { timeout: 5000, encoding: "utf8" };
class AudioActivityDetector extends EventEmitter {
@@ -29,6 +30,7 @@ class AudioActivityDetector extends EventEmitter {
this._sustainedTimer = null;
this._running = false;
this._eventDriven = false;
+ this._resetTimer = null;
}
setUserRecording(active) {
@@ -69,6 +71,7 @@ class AudioActivityDetector extends EventEmitter {
this._running = false;
this._killListenerProcess();
this._clearSustainedTimer();
+ this._clearResetTimer();
if (this.checkInterval) {
clearInterval(this.checkInterval);
this.checkInterval = null;
@@ -82,6 +85,7 @@ class AudioActivityDetector extends EventEmitter {
this.lastDismissedAt = Date.now();
this._reset();
this._clearSustainedTimer();
+ this._clearResetTimer();
debugLogger.info(
"Audio detection dismissed, cooldown started",
{ cooldownMs: COOLDOWN_MS },
@@ -102,6 +106,7 @@ class AudioActivityDetector extends EventEmitter {
this.hasPrompted = false;
this._activeMicPids.clear();
this._activeSources = 0;
+ this._clearResetTimer();
}
_clearSustainedTimer() {
@@ -111,6 +116,22 @@ class AudioActivityDetector extends EventEmitter {
}
}
+ _startResetTimer() {
+ this._clearResetTimer();
+ this._resetTimer = setTimeout(() => {
+ this._resetTimer = null;
+ this.hasPrompted = false;
+ debugLogger.debug("hasPrompted reset after sustained inactivity", {}, "meeting");
+ }, INACTIVE_RESET_MS);
+ }
+
+ _clearResetTimer() {
+ if (this._resetTimer) {
+ clearTimeout(this._resetTimer);
+ this._resetTimer = null;
+ }
+ }
+
_killListenerProcess() {
if (this._listenerProcess) {
try {
@@ -335,11 +356,12 @@ class AudioActivityDetector extends EventEmitter {
_onMicStateChanged(active) {
if (this._userRecording) return;
if (this.lastDismissedAt && Date.now() - this.lastDismissedAt < COOLDOWN_MS) return;
- if (this.hasPrompted) return;
debugLogger.debug("Mic state changed (event-driven)", { active }, "meeting");
if (active) {
+ this._clearResetTimer();
+ if (this.hasPrompted) return;
if (!this.audioActiveStart) this.audioActiveStart = Date.now();
if (!this._sustainedTimer) {
@@ -362,6 +384,7 @@ class AudioActivityDetector extends EventEmitter {
} else {
this._clearSustainedTimer();
this.audioActiveStart = null;
+ if (this.hasPrompted) this._startResetTimer();
}
}
@@ -377,7 +400,6 @@ class AudioActivityDetector extends EventEmitter {
async _check() {
if (this._checking) return;
if (this.lastDismissedAt && Date.now() - this.lastDismissedAt < COOLDOWN_MS) return;
- if (this.hasPrompted) return;
if (this._userRecording) return;
this._checking = true;
@@ -390,10 +412,11 @@ class AudioActivityDetector extends EventEmitter {
);
if (active) {
+ this._clearResetTimer();
this.consecutiveChecks++;
if (!this.audioActiveStart) this.audioActiveStart = Date.now();
- if (this.consecutiveChecks >= SUSTAINED_THRESHOLD_CHECKS) {
+ if (!this.hasPrompted && this.consecutiveChecks >= SUSTAINED_THRESHOLD_CHECKS) {
this.hasPrompted = true;
const now = Date.now();
const durationMs = now - this.audioActiveStart;
@@ -414,6 +437,7 @@ class AudioActivityDetector extends EventEmitter {
}
this.consecutiveChecks = 0;
this.audioActiveStart = null;
+ if (this.hasPrompted) this._startResetTimer();
}
} finally {
this._checking = false;