Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.
TypeScript ai-meeting-assistantai-notetakerelectrongranola-alternativelinuxllama-cpplocal-ailocal-firstmacosmcpmeeting-minutesmeeting-notesoffline-firstopen-sourceprivacyspeech-to-texttranscriptionwhisperwhisper-cppwindows
Call names: a slow call window is no longer read as a stuck reader and started again every 6 s, and Windows reads only the Teams window that was the call while it still is one (#83)
christianmatb02758804e41
diff --git a/app/native/yogurt-system/src/call.rs b/app/native/yogurt-system/src/call.rsindex 8178c2f9..5a07c855 100644--- a/app/native/yogurt-system/src/call.rs+++ b/app/native/yogurt-system/src/call.rs@@ -74,6 +74,17 @@ pub fn has_word(title: &str, word: &str) -> bool {title.split(|c: char| !c.is_alphanumeric()).any(|w| w.eq_ignore_ascii_case(word))}+/// Which of the app's windows to read: the one that was the call last time, alone, while it is still open. Teams keeps+/// its big chat and calendar windows open beside the call, and reading every one each time made a German call's+/// reading take 10 s (#83). With no such window, all of them.+#[cfg_attr(not(windows), allow(dead_code))]+pub fn to_read<T>(mut windows: Vec<(u64, T)>, last: Option<u64>) -> (Vec<(u64, T)>, bool) {+ match last.and_then(|h| windows.iter().position(|w| w.0 == h)) {+ Some(i) => (vec![windows.swap_remove(i)], true),+ None => (windows, false),+ }+}+pub fn now_ms() -> u64 {SystemTime::now().duration_since(UNIX_EPOCH).map(|d| d.as_millis() as u64).unwrap_or(0)}@@ -136,6 +147,15 @@ mod tests {assert!(!is_call_tree(&json!({ "r": "frame", "k": [{ "r": "button", "t": "Leave chat (Ctrl+Shift+L)" }] })));}+ #[test]+ fn the_last_call_window_is_read_alone_while_it_is_open() {+ let wins = vec![(1u64, "Chat | Microsoft Teams"), (2, "Anna, Jonas | Microsoft Teams"), (3, "Calendar | Microsoft Teams")];+ assert_eq!(to_read(wins.clone(), Some(2)), (vec![(2, "Anna, Jonas | Microsoft Teams")], true));+ // closed, or none yet: every window, top first+ assert_eq!(to_read(wins.clone(), Some(9)), (wins.clone(), false));+ assert_eq!(to_read(wins.clone(), None), (wins, false));+ }+#[test]fn the_hang_up_id_is_a_call_in_any_language() {// Teams in Portuguese labels Leave "Sair": its page id stays "hangup-button", as the Mac reader matches (#83)diff --git a/app/native/yogurt-system/src/wincalls.rs b/app/native/yogurt-system/src/wincalls.rsindex a8b70c97..a425eabf 100644--- a/app/native/yogurt-system/src/wincalls.rs+++ b/app/native/yogurt-system/src/wincalls.rs@@ -16,7 +16,7 @@ use windows::Win32::UI::Accessibility::{UIA_HelpTextPropertyId, UIA_NamePropertyId,};-use crate::call::{call_window, is_call_tree, kind, now_ms, Kind};+use crate::call::{call_window, is_call_tree, kind, now_ms, to_read, Kind};use crate::parse;/// at most this many call windows of the app per reading@@ -134,6 +134,7 @@ pub fn watch(every_ms: u64, ids: &[String]) -> ! {let ids: Vec<String> = ids.iter().map(|id| id.to_lowercase()).collect();let mut uia: Option<Uia> = None;let mut complained = false;+ let mut last: Option<u64> = None;loop {let started = Instant::now();if uia.is_none() {@@ -148,7 +149,7 @@ pub fn watch(every_ms: u64, ids: &[String]) -> ! {}}let line = match &uia {- Some(u) => read_once(u, &ids),+ Some(u) => read_once(u, &ids, &mut last),None => json!({ "t": now_ms(), "error": "no-accessibility" }),};crate::out(line);@@ -158,33 +159,60 @@ pub fn watch(every_ms: u64, ids: &[String]) -> ! {}}-/// The first app asked about with a call window, and its call windows, top first-fn read_once(u: &Uia, ids: &[String]) -> Value {+/// The first app asked about with a call window, and its call windows, top first. `last` is the Teams window that was+/// the call: it is read alone while it still is one (call::to_read).+fn read_once(u: &Uia, ids: &[String], last: &mut Option<u64>) -> Value {let t = now_ms();let procs = crate::win::processes();let mut seen = false;- let mut app: Option<String> = None;- let mut windows = Vec::new();+ let mut mine = Vec::new();for (hwnd, pid, title) in crate::win::top_windows() {let Some(p) = procs.get(&pid) else { continue };let exe = parse::exe_id(&p.exe);let Some(id) = ids.iter().find(|id| **id == exe) else { continue };seen = true;- if windows.len() == MAX_WINDOWS || app.as_ref().is_some_and(|a| a != id) {+ if call_window(kind(id), &title) {+ mine.push((hwnd, (id.clone(), title)));+ }+ }+ let (first, alone) = to_read(mine.clone(), *last);+ let mut checked = None;+ if alone {+ let (hwnd, (id, title)) = &first[0];+ match u.tree(*hwnd) {+ Some(tree) if is_call_tree(&tree) => return json!({ "t": t, "app": id, "windows": [{ "title": title, "tree": tree }] }),+ // it did not answer in time: the other windows would be as slow, so this reading is skipped+ None => return json!({ "t": t, "error": "slow-call-window" }),+ Some(_) => {+ *last = None;+ checked = Some(*hwnd);+ }+ }+ }+ let mut app: Option<String> = None;+ let mut windows = Vec::new();+ for (hwnd, (id, title)) in mine {+ if windows.len() == MAX_WINDOWS || app.as_ref().is_some_and(|a| *a != id) {continue;}- let k = kind(id);- if !call_window(k, &title) {+ if checked == Some(hwnd) {continue;}+ let k = kind(&id);let Some(tree) = u.tree(hwnd) else { continue };// Teams's calendar and chat windows look like the call's: only a window with call controls is sent, so their- // text never reaches the JSON or the log- if k == Kind::Teams && !is_call_tree(&tree) {- continue;+ // text never reaches the JSON or the log. Teams has one call window: once found, it is the one read.+ if k == Kind::Teams {+ if !is_call_tree(&tree) {+ continue;+ }+ *last = Some(hwnd);}app = Some(id.clone());windows.push(json!({ "title": title, "tree": tree }));+ if k == Kind::Teams {+ break;+ }}match app {Some(app) => json!({ "t": t, "app": app, "windows": windows }),diff --git a/app/src/main/callNames/index.ts b/app/src/main/callNames/index.tsindex 27a5bded..5fb6dd0b 100644--- a/app/src/main/callNames/index.ts+++ b/app/src/main/callNames/index.ts@@ -49,15 +49,18 @@ export function kindFor(appId: string, windows: Array<{ title?: string }>, callAexport const WATCH_EVERY_MS = 400/** the apps mark the person talking about this late (Zoom: about 0.75 to 1.2 s after they start) */const APP_LAG_MS = 750-/** no reading for this long while recording: the reader is stuck (seen once, 11 minutes of Them), so it starts again */+/** no reading for this long while recording: the reader is stuck (seen once, 11 minutes of Them), so it starts again.+ * A slow window gets longer: three times the reader's own pace, and twice as long after each start, since the reader+ * waits as long as a reading took and a fresh one killed at 5 s never sends one (#83: a Teams reading took 10 s). */export const QUIET_MS = 5000+const MAX_QUIET_MS = 60_000/** at most this many fresh starts per meeting, so an app that never answers can't start readers forever */const MAX_RESTARTS = 20/** changes of who talks written to the log, per meeting (enough to check a real call, never a flood) */const LOGGED_CHANGES = 30type Sample = Omit<CallSample, 'ms'> & { t: number }-type Session = { app: string | null; ids: string[]; pids?: number[]; heardAt: number; restarts: number; samples: Sample[]; priorLines: Set<number>; watch?: { stop(): void }; everyApp: boolean; offset?: number; startedAt: number; pictured: boolean; errors: Set<string>; last: string; logged: number }+type Session = { app: string | null; ids: string[]; pids?: number[]; heardAt: number; quietMs: number; restarts: number; samples: Sample[]; priorLines: Set<number>; watch?: { stop(): void }; everyApp: boolean; offset?: number; startedAt: number; pictured: boolean; errors: Set<string>; last: string; logged: number }export function hookCallNames(p: {store: Pick<Store, 'meeting' | 'segments' | 'setSegmentSpeakers' | 'updateMeeting'>@@ -93,6 +96,7 @@ export function hookCallNames(p: {}const onLine = (id: string, s: Session, l: WatchLine) => {+ s.quietMs = Math.min(MAX_QUIET_MS, Math.max(QUIET_MS, 3 * (now() - s.heardAt)))s.heardAt = now()if (l.error || !l.app || !l.windows) {const why = l.error ?? 'nothing read'@@ -126,7 +130,7 @@ export function hookCallNames(p: {p.onStart((m) => {const ids = watchIds(m.app)- const s: Session = { app: m.app, ids, heardAt: now(), restarts: 0, everyApp: !m.app, samples: [], priorLines: new Set(p.store.segments(m.id, { hidden: true }).map((line) => line.id)), startedAt: m.resume ? m.resume.startedAt - m.resume.startMs : m.startedAt, pictured: false, errors: new Set(), last: '', logged: 0 }+ const s: Session = { app: m.app, ids, heardAt: now(), quietMs: QUIET_MS, restarts: 0, everyApp: !m.app, samples: [], priorLines: new Set(p.store.segments(m.id, { hidden: true }).map((line) => line.id)), startedAt: m.resume ? m.resume.startedAt - m.resume.startMs : m.startedAt, pictured: false, errors: new Set(), last: '', logged: 0 }sessions.set(m.id, s)if (!ids.length) { log(`call names: ${m.app} can't be read, the other side is Them`); return }begin(m.id, s)@@ -194,9 +198,10 @@ export function hookCallNames(p: {begin(id, s)continue}- if (!s.watch || !s.ids.length || now() - s.heardAt <= QUIET_MS || s.restarts >= MAX_RESTARTS) continue+ if (!s.watch || !s.ids.length || now() - s.heardAt <= s.quietMs || s.restarts >= MAX_RESTARTS) continuelog(`call names: the reader went quiet for ${Math.round((now() - s.heardAt) / 1000)} s; starting it again`)s.restarts+++ s.quietMs = Math.min(MAX_QUIET_MS, s.quietMs * 2)s.watch.stop(); s.watch = undefineds.heardAt = now()begin(id, s)diff --git a/app/test/callNames.test.ts b/app/test/callNames.test.tsindex e2ae0cfb..fc6fd8c1 100644--- a/app/test/callNames.test.ts+++ b/app/test/callNames.test.ts@@ -152,6 +152,32 @@ describe('hookCallNames', () => {expect(s.watched).toHaveLength(2)})+ it('a slow reader that still sends readings is never started again: it gets three times its own pace (#83)', () => {+ const s = setup()+ s.start()+ // a big window: the first reading takes 4 s, and the reader then reads every 8 s (it waits as long as a reading took)+ s.audio(0, 1_004_000); s.emit(zoomLine(1_004_000, ['Alex Morgan', 'Dana Smith'], 'Dana Smith'))+ for (let at = 1_006_000; at <= 1_060_000; at += 2_000) {+ s.audio(0, at)+ if ((at - 1_004_000) % 8_000 === 0) s.emit(zoomLine(at, ['Alex Morgan', 'Dana Smith'], 'Dana Smith'))+ s.hook.checkQuiet()+ }+ expect(s.watched).toHaveLength(1)+ expect(s.logs.some((l) => /went quiet/.test(l))).toBe(false)+ })++ it('a reader started again gets twice as long each time before the next start, so a first reading that takes 10 s lands (#83)', () => {+ const s = setup()+ s.start()+ const starts: number[] = []+ for (let at = 1_002_000; at <= 1_060_000; at += 2_000) {+ s.audio(0, at); s.hook.checkQuiet()+ if (s.watched.length > starts.length + 1) starts.push(at)+ }+ // 5 s, then 10 s, then 20 s of quiet; never every 6 s+ expect(starts).toEqual([1_006_000, 1_018_000, 1_040_000])+ })+it('a recording started by hand watches every call app until its app is known, then only that one (a Teams chat window cannot hide a Meet call, #72)', () => {const s = setup({ app: null })s.start()