Skip to content

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.

Recording: Yogurt no longer asks to stop, or stops by itself, while it still hears people talking

Eric Brownrout66709fa3c388
diff --git a/app/e2e/autoStop.spec.ts b/app/e2e/autoStop.spec.ts
index 142f87c8..d6113061 100644
--- a/app/e2e/autoStop.spec.ts
+++ b/app/e2e/autoStop.spec.ts
@@ -41,12 +41,13 @@ async function callAndRecord(app: ElectronApplication, page: Page) {
await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', 'recording')
}
-test('the call ends: after the grace the recording stops by itself, with no question, and says so', async () => {
+test('the quiet call ends: after the grace the recording stops by itself, with no question, and says so', async () => {
const { app, page } = await launch({ env: { YOGURT_BACKGROUND: '1' } })
try {
await callAndRecord(app, page)
+ await fake(app, 'silence', 60_000)
await signals(app, { micApps: [], events: [event()] })
- // the grace is 4 s (CALL_GONE_MS)
+ // Already quiet for a minute; the app grace is still 4 s (CALL_GONE_MS).
await advance(app, 3_000)
await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', 'recording')
await advance(app, 1_500)
@@ -67,6 +68,7 @@ test('a blip shorter than the grace does nothing', async () => {
const { app, page } = await launch()
try {
await callAndRecord(app, page)
+ await fake(app, 'silence', 60_000)
await signals(app, { micApps: [], events: [event()] })
await advance(app, 2_000)
await signals(app, { micApps: [zoom], events: [event()] })
@@ -80,6 +82,7 @@ test('the grace can be shortened in fake mode', async () => {
const { app, page } = await launch({ env: { YOGURT_FAKE_CALL_GONE_MS: '1000' } })
try {
await callAndRecord(app, page)
+ await fake(app, 'silence', 60_000)
await signals(app, { micApps: [], events: [event()] })
await advance(app, 1_500)
await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', /^(stopped|done)$/)
@@ -96,6 +99,7 @@ test('switched off in Settings: it asks as before', async () => {
await expect(toggle).toHaveAttribute('aria-checked', 'false')
await expect.poll(() => JSON.parse(readFileSync(join(userData, 'settings.json'), 'utf8')).stopWhenCallEnds).toBe(false)
await callAndRecord(app, page)
+ await fake(app, 'silence', 60_000)
await signals(app, { micApps: [], events: [event()] })
await advance(app, 31_000)
await expect((await card(app)).getByTestId('prompt-heading')).toHaveText('Stop recording?')
@@ -164,6 +168,7 @@ test('FaceTime audio/video and handed-off calls offer a card for the shared mic
const id = await page.evaluate(() => window.yogurt.nav.current().then(route => route.slice('/note/'.length)))
expect(await page.evaluate(id => window.yogurt.meetings.get(id).then(m => m?.app), id)).toBe('FaceTime')
await signals(app, { micApps, events: [], runningApps: ['com.apple.FaceTime'] })
+ await fake(app, 'silence', 60_000)
await signals(app, { micApps: [], events: [], runningApps: ['com.apple.FaceTime'] })
await advance(app, 11000)
await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', /^(stopped|done)$/)
@@ -172,3 +177,20 @@ test('FaceTime audio/video and handed-off calls offer a card for the shared mic
expect(logs).toContain(`CALL gone meeting=${id} app=FaceTime idle_ms=`)
} finally { await app.close() }
})
+
+
+test('speech keeps recording after the app leaves the mic; only confirmed silence lets it stop', async () => {
+ const { app, page } = await launch()
+ try {
+ await callAndRecord(app, page)
+ await fake(app, 'silence', 0)
+ await signals(app, { micApps: [], events: [] })
+ await advance(app, 10 * 60_000)
+ await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', 'recording')
+ expect(cards(app)).toBe(0)
+ await fake(app, 'silence', 59_999)
+ await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', 'recording')
+ await fake(app, 'silence', 60_000)
+ await expect(page.getByTestId('note-state')).toHaveAttribute('data-state', /^(stopped|done)$/)
+ } finally { await app.close() }
+})
diff --git a/app/e2e/detect.spec.ts b/app/e2e/detect.spec.ts
index 9ebe14af..e014e967 100644
--- a/app/e2e/detect.spec.ts
+++ b/app/e2e/detect.spec.ts
@@ -127,7 +127,8 @@ test('when the call ends the card asks, and Stop stops the meeting; Keep going w
// still on the call: nothing asked
await advance(app, 20_000)
await signals(app, { micApps: [zoom], events: [event()] })
- // the mic is free for 31 s
+ // Already quiet for a minute; the app must also be off the mic for 30 s.
+ await app.evaluate(() => (globalThis as any).__fake__.silence(60_000))
await signals(app, { micApps: [], events: [event()] })
await advance(app, 31_000)
const p = await card(app)
@@ -161,7 +162,8 @@ test('the window is away: clicking the "Take notes?" notification starts the not
// the card closed with it
await expect.poll(() => app.windows().filter((w) => !w.isClosed() && w.url().includes('#prompt')).length).toBe(0)
expect(await notice()).toBeNull()
- // the call ends: the stop card and its notification
+ // the call ends quietly: the stop card and its notification
+ await app.evaluate(() => (globalThis as any).__fake__.silence(60_000))
await signals(app, { micApps: [], events: [event()] })
await advance(app, 31_000)
await expect.poll(notice).toMatchObject({ title: 'Stop recording?' })
diff --git a/app/src/main/asr/index.ts b/app/src/main/asr/index.ts
index d7de7a62..1f3545b7 100644
--- a/app/src/main/asr/index.ts
+++ b/app/src/main/asr/index.ts
@@ -1,6 +1,6 @@
import {previousSpeaker} from '../../shared/transcriptReplacement'
import { AUDIO_SPEAKER } from '../../shared/audioUpload'
-import { onCaptureStart, recordingFinished, type TranscribeWarn, type Track } from '../capture'
+import { onCaptureStart, recordingFinished, recordingPaused, type TranscribeWarn, type Track } from '../capture'
import { onMeetingStart, onMeetingStop } from '../meeting'
import { isFake } from '../paths'
import { feedRecording } from './backfill'
@@ -26,7 +26,9 @@ type Session = { complete?: () => boolean; pipeline: Pipeline | null; priorLines
failed?: boolean
replacement?: boolean
/** Apple's speech listens in this locale for the meeting (null: whisper only); off once whisper hears another language */
- speech?: string | null }
+ speech?: string | null
+ /** Live input only: saved-file transcription must never influence call detection. */
+ live?: { quietSince: number; frames: Partial<Record<Track, number>> } }
/**
* The saved transcript comes from whisper; Apple's words are the live view. Languages listed here are the ones where Apple's
@@ -89,6 +91,14 @@ type SessionStore = Pick<Store, 'updateMeeting'> & Partial<Pick<Store, 'segments
let server: WhisperServer | undefined
let serverKey: string | undefined
const sessions = new Map<string, Session>()
+/** Unknown, stale or paused input is not evidence that a conversation ended. */
+export function liveSilentMs(id: string, now = Date.now()): number {
+ const s = sessions.get(id), live = s?.live
+ if (!s?.pipeline || !live || recordingPaused(id)) return 0
+ if (['me', 'them'].some(track => now - (live.frames[track as Track] ?? -Infinity) > 3000)) return 0
+ return Math.max(0, now - live.quietSince)
+}
+
export type RecordedOptions = { signal?: AbortSignal; progress?: (ms: number) => void; fromMs?: Partial<Record<Track,number>>; save?: (segments: Omit<Segment,'id'>[]) => void }
type Recorded = (id: string, tracks: Partial<Record<Track, AsyncIterable<Float32Array>>>, stopped?: () => boolean, options?: RecordedOptions) => Promise<boolean>
let recorded: Recorded = async () => false
@@ -236,7 +246,13 @@ export function hookTranscription(p: {
pipeline: transcribe ? createPipeline({ meetingId: id, transcribe, save: (segs) => {
try { if(options?.save) options.save(segs); else p.store.addSegments(segs) } catch (e) { saveFailed = true; throw e }
if (segs.some(s => s.hidden)) p.refresh?.(id)
- }, emit: options?.save ? () => {} : p.send, emitPartial: options?.save ? undefined : p.sendPartial, holdMs: p.holdMs, extraWaitMs: p.extraWaitMs, onWarn: warnOnce,
+ }, emit: options?.save ? () => {} : seg => {
+ if (s.live && seg.text.trim()) s.live.quietSince = Date.now()
+ p.send(seg)
+ }, emitPartial: options?.save || !p.sendPartial ? undefined : part => {
+ if (s.live && part.text.trim()) s.live.quietSince = Date.now()
+ p.sendPartial?.(part)
+ }, holdMs: p.holdMs, extraWaitMs: p.extraWaitMs, onWarn: warnOnce,
nameOf: (a, b) => p.store.meeting?.(id)?.source === 'audio-file' ? AUDIO_SPEAKER : p.nameOf?.(id, a, b) ?? previousSpeaker(priorSegments,'them',a,b),
respell: (t) => { const m = p.store.meeting?.(id); return m ? respell(t, meetingWords(m)) : t } }) : null,
}
@@ -263,7 +279,15 @@ export function hookTranscription(p: {
// each capture of a meeting (a restarted recorder is a new one) feeds that meeting's session
const offCapture = onCaptureStart((c, meetingId) => {
const s = open(meetingId)
- c.on('pcm', (track, ms, samples) => s.pipeline?.push(track, ms, samples))
+ s.live = { quietSince: Date.now(), frames: {} }
+ c.on('pcm', (track, ms, samples) => {
+ if (!samples.length) return
+ s.pipeline?.push(track, ms, samples)
+ const now = Date.now(), live = s.live!
+ // A gap, restart or pause must earn a new quiet minute, not count missing audio as silence.
+ if (now - (live.frames[track] ?? -Infinity) > 3000 || recordingPaused(meetingId) || s.pipeline?.talking('me') || s.pipeline?.talking('them')) live.quietSince = now
+ live.frames[track] = now
+ })
// Apple's speech that never speaks up: the helper says so, or someone has talked for a while with no word from it
c.on('speech-off', () => speechOff(s, 'the helper could not run it'))
// Apple listening on one track only: whisper's own quick readings cover the other
@@ -274,10 +298,11 @@ export function hookTranscription(p: {
if (s.pipeline.talking('me') || s.pipeline.talking('them')) talkedPolls++
if (talkedPolls >= SPEECH_WATCH_POLLS) { clearInterval(watch); speechOff(s, 'no words came while people talked') }
}, 1000)
- c.on('ended', () => clearInterval(watch))
+ c.on('ended', () => { clearInterval(watch); if (s.live) s.live.frames = {} })
// Apple's words: the live view (whisper's line replaces them), or the saved line too where Apple measured as good
c.on('speech', (f) => {
heardSpeech = true
+ if (s.live && f.text.trim()) s.live.quietSince = Date.now()
if (!s.speech || !s.pipeline) return
const saves = APPLE_FINALS_LANGUAGES.has(s.speech.split('-')[0])
if (f.final && saves) s.pipeline.speechLines(f.track, [{ track: f.track, startMs: Math.round(f.startMs), endMs: Math.round(f.endMs), text: f.text }])
diff --git a/app/src/main/detect.ts b/app/src/main/detect.ts
index eea6b679..90cf311a 100644
--- a/app/src/main/detect.ts
+++ b/app/src/main/detect.ts
@@ -7,6 +7,8 @@ export type Prompt = { key: string; /** the event's title; empty with no event (
export type Dismissals = ReadonlySet<string>
const MIN = 60_000
+/** Require a full quiet minute before asking or stopping; a call app can release the mic mid-conversation. */
+export const CALL_SILENCE_MS = 60_000
type CallApp = { id: string; name: string; browser?: boolean }
// Apps that make calls. Browsers only count with a sign of a call (see decide).
@@ -122,18 +124,16 @@ export function decide(s: Signals, now: number, recent: Dismissals): Prompt | nu
return null
}
-/**
- * Has the meeting ended? micIdleMs: how long the meeting's app has not used the mic (0 while it does).
- * Also ended: the event is 5 minutes over and both tracks have been quiet for 60 s. This only asks; callGone is what stops by itself.
+/** Ask only when the bound call app has left the mic for 30 s and both tracks have been quiet for a minute.
+ * A calendar event ending is not evidence that the conversation ended.
*/
-export function ended(_s: Signals, micIdleMs: number, ctx?: { event: CalEvent | null; silentMs: number; now: number }): boolean {
- if (micIdleMs >= 30_000) return true
- return !!ctx?.event && ctx.now >= ctx.event.end + 5 * MIN && ctx.silentMs >= 60_000
+export function ended(micIdleMs: number, silentMs = 0): boolean {
+ return micIdleMs >= 30_000 && silentMs >= CALL_SILENCE_MS
}
/**
* How long the call app must be off the mic before a recording stops by itself: a new headset or Zoom's own mute let go
- * for a moment. Short, so hanging up ends the note within a few seconds; a call that drops for longer can be resumed.
+ * for a moment. This grace is separate from the quiet minute required before stopping.
*/
export const CALL_GONE_MS = 4_000
/** how often the call signals are read: more often while recording, so the end of a call is seen quickly */
@@ -141,9 +141,9 @@ export const watchEveryMs = (recording: boolean): number => (recording ? 1_500 :
/**
* Should the recording stop by itself? Only one tied to a call app (app) that was on the mic during this recording (seen),
- * once that app has let go of the mic for the grace. A recording that never observes a call, or a resumed note whose call is over, never.
+ * once that app has let go of the mic for the grace and both tracks have been quiet for a minute. A recording that never observes a call, or a resumed note whose call is over, never.
* The calendar never stops one: meetings run over.
*/
-export function callGone(o: { app: string | null; seen: boolean; micIdleMs: number; graceMs?: number }): boolean {
- return !!o.app && o.seen && o.micIdleMs >= (o.graceMs ?? CALL_GONE_MS)
+export function callGone(o: { app: string | null; seen: boolean; micIdleMs: number; silentMs: number; graceMs?: number }): boolean {
+ return !!o.app && o.seen && o.micIdleMs >= (o.graceMs ?? CALL_GONE_MS) && o.silentMs >= CALL_SILENCE_MS
}
diff --git a/app/src/main/fake.ts b/app/src/main/fake.ts
index 31793c56..fba31c15 100644
--- a/app/src/main/fake.ts
+++ b/app/src/main/fake.ts
@@ -142,6 +142,7 @@ export const fakeNow = () => Date.now() + skew
* The hook the end-to-end tests drive, reachable from the test as globalThis.__fake__. Installed only under YOGURT_FAKE=1.
* signals({ micApps, events }) pretend the Mac said this, then look at it right away
* advance(ms) move the clock forward
+ * silence(ms | null) confirmed live quiet time; null restores real audio observation
* widget() what the recording widget shows and where it sits
* go(route) show a page, as the card or widget would (e.g. /note/<id>)
* main() whether the main window was brought forward, is visible, and its route
@@ -160,12 +161,13 @@ export const fakeNow = () => Date.now() + skew
* chatMeetings() two finished meetings with transcripts and notes, indexed for chat across meetings (their ids)
* prompts() what whisper and the notes model were given so far
*/
-export function installFakeHooks(h: { signals(r: Reading): Promise<void>; advance(ms: number): Promise<void>; widget(): unknown; main(): unknown; go(route: string): void; crashCapture(): void; warn(code: string): void; bigMeeting(n: number): string; manyMeetings(o: number | { n: number; clean?: boolean }): void; calendarChanged(): void; tray(): string[]; trayClick(id: string): void; trayAccelerators(): Record<string, string | undefined>; permissions(): Promise<unknown>; notice(): unknown; noticeClick(): void; chatMeetings(): Promise<string[]> }) {
+export function installFakeHooks(h: { silence(ms: number | null): Promise<void>; signals(r: Reading): Promise<void>; advance(ms: number): Promise<void>; widget(): unknown; main(): unknown; go(route: string): void; crashCapture(): void; warn(code: string): void; bigMeeting(n: number): string; manyMeetings(o: number | { n: number; clean?: boolean }): void; calendarChanged(): void; tray(): string[]; trayClick(id: string): void; trayAccelerators(): Record<string, string | undefined>; permissions(): Promise<unknown>; notice(): unknown; noticeClick(): void; chatMeetings(): Promise<string[]> }) {
// kept: hooks other modules added before these
;(globalThis as Record<string, unknown>).__fake__ = {
...((globalThis as Record<string, unknown>).__fake__ as object | undefined),
audioMetadataRelease: () => { audioMetadataReleased = true; releaseAudioMetadata?.() },
signals: h.signals,
+ silence: h.silence,
advance: async (ms: number) => { skew += ms; await h.advance(ms) },
widget: h.widget,
main: h.main,
diff --git a/app/src/main/index.ts b/app/src/main/index.ts
index 22e5c081..b4343dec 100644
--- a/app/src/main/index.ts
+++ b/app/src/main/index.ts
@@ -57,7 +57,7 @@ import { isId, text, rewriteNote } from './ipcArgs'
import { hookMics } from './mics'
import { activeCapture, audioHelperPath, hookCapture, joinParts, onCaptureStart, onRecordingEvent, prepareAppend, recordingFinished, recordingPaused, recordingSettled, rejoinInterrupted, setRecordingPaused, settleRecording, tell, type WarnCode } from './capture'
import { createWidget } from './widget'
-import { hookTranscription, transcribeRecorded, onWhisperGpuOff, meetingLanguage, settleTranscription, speechLocaleFor, spokenChanged, transcriptionBacklogMs, stopTranscriptionServer, releaseIdleSpeech, transcriptFinished, transcriptPartials } from './asr'
+import { liveSilentMs, hookTranscription, transcribeRecorded, onWhisperGpuOff, meetingLanguage, settleTranscription, speechLocaleFor, spokenChanged, transcriptionBacklogMs, stopTranscriptionServer, releaseIdleSpeech, transcriptFinished, transcriptPartials } from './asr'
import { hookCallNames, type Watch } from './callNames'
import { helperWatch, killAllWatches } from './callNames/watch'
import { macFullName } from './user'
@@ -295,11 +295,13 @@ function startDetection() {
const signals = createSignals({ helper: runHelper, events: readCalendar })
refreshCalendarConsumers = () => signals.invalidateCalendar()
const now = isFake() ? fakeNow : Date.now
+ let fakeSilence: number | undefined
const watcher: Watcher = new Watcher({
read: (at) => signals.read(at), now, active: activeMeeting, bindApp: bindMeetingApp,
offer: (p) => prompts.offer(p), askStop: (m) => prompts.askStop(m), hide: () => prompts.hide(),
// the call ended: the same stop as the widget's Stop button, then say so
autoStop: (m) => { widget.callEnded(m.id); stopMeeting(m.id); prompts.stopped(m) },
+ silentMs: () => { if (isFake() && fakeSilence !== undefined) return fakeSilence; const m = activeMeeting(); return m ? liveSilentMs(m.id) : 0 },
autoStopOn: () => stopsWhenCallEnds(loadSettings(join(userDataDir(), 'settings.json'))),
// no "Take notes?" while onboarding is still on screen
ready: () => !onboardingShowing(),
@@ -423,13 +425,14 @@ function startDetection() {
refreshCalendarConsumers = () => { signals.invalidateCalendar(); void tray.refreshCalendar() }
setTrayVisible = tray.setVisible
trayShown = tray.shown
- // cheap, and only while Yogurt runs; more often while recording, so a call that ended stops within a few seconds
+ // cheap, and only while Yogurt runs; more often while recording, so the end of a quiet call is noticed promptly
let timer: NodeJS.Timeout | undefined
const watchLoop = () => { timer = setTimeout(() => { void watcher.tick().catch((e) => console.error('detect failed', e)).finally(watchLoop) }, watchEveryMs(!!activeMeeting())) }
watchLoop()
app.on('will-quit', () => clearTimeout(timer))
if (isFake()) {
installFakeHooks({
+ silence: async (ms) => { fakeSilence = ms ?? undefined; await watcher.tick() },
signals: async (r) => { signals.override(r); await watcher.tick() },
advance: () => watcher.tick(),
widget: () => widget.snapshot(),
diff --git a/app/src/main/watch.ts b/app/src/main/watch.ts
index 6150d47f..027f0edd 100644
--- a/app/src/main/watch.ts
+++ b/app/src/main/watch.ts
@@ -1,4 +1,3 @@
-import { matchesEvent } from './calendar'
import type { Meeting } from './store'
import { callAppName, callGone, decide, ended, type Prompt, type Signals } from './detect'
import type { Reading } from './detectSignals'
@@ -107,20 +106,20 @@ export class Watcher {
if (r.stopped) return
const onMic = !!m.app && s.micApps.some((a) => { const n = callAppName(a.bundleId, s.runningApps); return n && n === m.app })
if (onMic) r.seen = true
- // a meeting with no known app has no mic to watch: only the event and silence can end it
+ // Without a bound call app there is no mic-loss evidence to ask about.
const using = !m.app || onMic
if (using) r.lastMic = now
- if (!r.byHand && this.d.autoStop && this.d.autoStopOn?.() && callGone({ app: m.app, seen: r.seen, micIdleMs: now - r.lastMic, graceMs: this.d.graceMs })) {
- console.info(`CALL gone meeting=${m.id} app=${m.app} idle_ms=${now - r.lastMic}`)
+ const silentMs = this.d.silentMs?.() ?? 0
+ if (!r.byHand && this.d.autoStop && this.d.autoStopOn?.() && callGone({ app: m.app, seen: r.seen, micIdleMs: now - r.lastMic, silentMs, graceMs: this.d.graceMs })) {
+ console.info(`CALL gone meeting=${m.id} app=${m.app} idle_ms=${now - r.lastMic} silent_ms=${silentMs}`)
r.stopped = true
if (this.shown === 'stop') { this.shown = null; this.d.hide() }
this.d.autoStop(m)
return
}
- const event = s.events.find((e) => matchesEvent(e, m.eventId)) ?? null
- const over = ended(s, now - r.lastMic, { event, silentMs: this.d.silentMs?.() ?? 0, now })
+ const over = ended(now - r.lastMic, silentMs)
if (over && this.shown !== 'stop' && now >= r.snoozeUntil) {
- console.info(`CALL stop-card meeting=${m.id} app=${m.app ?? 'none'} reason=${now - r.lastMic >= 30_000 ? 'mic-idle' : 'event-ended-and-silent'} idle_ms=${now - r.lastMic}`)
+ console.info(`CALL stop-card meeting=${m.id} app=${m.app ?? 'none'} reason=mic-idle-and-silent idle_ms=${now - r.lastMic} silent_ms=${silentMs}`)
this.shown = 'stop'; this.d.askStop(m)
}
else if (!over && this.shown === 'stop') { this.shown = null; this.d.hide() }
diff --git a/app/test/detect.test.ts b/app/test/detect.test.ts
index ec25503f..2bf716c1 100644
--- a/app/test/detect.test.ts
+++ b/app/test/detect.test.ts
@@ -71,19 +71,14 @@ describe('decide', () => {
})
describe('ended', () => {
- it('true after 30 s without the mic, false at 29 s', () => {
- expect(ended(sig(), 30_000)).toBe(true)
- expect(ended(sig(), 29_000)).toBe(false)
+ it('asks after 30 s off the mic only when a quiet minute is confirmed', () => {
+ expect(ended(30_000, 60_000)).toBe(true)
+ expect(ended(30_000, 59_999)).toBe(false)
+ expect(ended(600_000)).toBe(false)
+ expect(ended(29_000, 60_000)).toBe(false)
})
- it('the event over by 5 minutes with 60 s of silence on both tracks', () => {
- const event = ev()
- const ctx = (silentMs: number, now: number) => ({ event, silentMs, now })
- expect(ended(sig(), 0, ctx(60_000, event.end + 5 * MIN))).toBe(true)
- expect(ended(sig(), 0, ctx(59_000, event.end + 5 * MIN))).toBe(false)
- expect(ended(sig(), 0, ctx(60_000, event.end + 4 * MIN))).toBe(false)
- })
- it('no event, no silence reading: only the mic counts', () => {
- expect(ended(sig(), 0, { event: null, silentMs: 600_000, now: NOW })).toBe(false)
+ it.each([60_000, 600_000])('quiet for %i ms cannot ask while the app still holds its mic', silentMs => {
+ expect(ended(0, silentMs)).toBe(false)
})
})
@@ -114,21 +109,25 @@ describe('browser tab titles', () => {
})
describe('callGone', () => {
- const call = { app: 'Zoom', seen: true, micIdleMs: 0 }
+ const call = { app: 'Zoom', seen: true, micIdleMs: 0, silentMs: 60_000 }
it('a call app that let go of the mic for the grace has ended; a blip has not', () => {
expect(CALL_GONE_MS).toBe(4_000)
expect(callGone({ ...call, micIdleMs: 4_000 })).toBe(true)
expect(callGone({ ...call, micIdleMs: 3_999 })).toBe(false)
})
- it('checks more often while recording, so a call that ended stops within about 4 to 5.5 s', () => {
+ it('checks every 1.5 s while recording, after both grace and silence thresholds', () => {
expect(watchEveryMs(true)).toBe(1_500)
expect(watchEveryMs(false)).toBe(3_000)
})
it('the grace can be shorter (fake mode)', () => {
expect(callGone({ ...call, micIdleMs: 500, graceMs: 500 })).toBe(true)
})
+ it('cannot auto-stop while speech continues, regardless of how long the app is gone', () => {
+ expect(callGone({ ...call, micIdleMs: 60 * MIN, silentMs: 0 })).toBe(false)
+ expect(callGone({ ...call, micIdleMs: 60 * MIN, silentMs: 59_999 })).toBe(false)
+ })
it('never for a recording started by hand with no call', () => {
- expect(callGone({ app: null, seen: true, micIdleMs: 60 * MIN })).toBe(false)
+ expect(callGone({ app: null, seen: true, micIdleMs: 60 * MIN, silentMs: 60_000 })).toBe(false)
})
it('never before the call app was seen on the mic this time (a resumed note after the call)', () => {
expect(callGone({ ...call, seen: false, micIdleMs: 60 * MIN })).toBe(false)
diff --git a/app/test/transcription.test.ts b/app/test/transcription.test.ts
index 0da881db..03f496f3 100644
--- a/app/test/transcription.test.ts
+++ b/app/test/transcription.test.ts
@@ -2,8 +2,8 @@ import { AUDIO_SPEAKER } from '../src/shared/audioUpload'
import { EventEmitter } from 'node:events'
import { PassThrough } from 'node:stream'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import { Capture, encodeFrame, hookCapture, recordingFinished, type CaptureProc } from '../src/main/capture'
-import { hookTranscription, transcribeRecorded, settleTranscription, speechLocaleFor, spokenChanged, stopTranscriptionServer, transcribing, releaseIdleSpeech } from '../src/main/asr'
+import { Capture, encodeFrame, hookCapture, setRecordingPaused, recordingFinished, type CaptureProc } from '../src/main/capture'
+import { liveSilentMs, hookTranscription, transcribeRecorded, settleTranscription, speechLocaleFor, spokenChanged, stopTranscriptionServer, transcribing, releaseIdleSpeech } from '../src/main/asr'
import type { Spoken } from '../src/shared/spoken'
import type { TranscriptPartial } from '../src/shared/types'
import { openStore, type Meeting, type Store } from '../src/main/store'
@@ -451,3 +451,52 @@ describe('a meeting recorded before the speech model was in (#30)', () => {
expect(store.meeting(m.id)?.transcriptionPending).toBe(true)
})
})
+
+
+describe('live silence for call detection', () => {
+ it('requires fresh input on both tracks and resets for either voice, pause, gaps and live words', async () => {
+ let now = 10_000, ms = 0
+ const time = vi.spyOn(Date, 'now').mockImplementation(() => now)
+ const r = rig('transcription-first', { transcriber: () => [] }), m = meeting()
+ r.begin(m)
+ const output = r.procs[0].proc.stdout as PassThrough
+ const frame = (voice?: 'me' | 'them', tracks = ['me', 'them'] as const) => {
+ now += 100; ms += 100
+ for (const track of tracks) output.write(encodeFrame({ t: 'pcm', track, ms, samples: voice === track ? tone(0.1) : new Float32Array(1600) }))
+ }
+ const quiet = (n: number) => { for (let i = 0; i < n; i++) frame() }
+ try {
+ expect(liveSilentMs(m.id)).toBe(0)
+ quiet(601)
+ expect(liveSilentMs(m.id)).toBe(60_000)
+ frame('me'); expect(liveSilentMs(m.id)).toBe(0)
+ quiet(620); expect(liveSilentMs(m.id)).toBeGreaterThanOrEqual(60_000)
+ frame('them'); expect(liveSilentMs(m.id)).toBe(0)
+ quiet(620)
+ expect(setRecordingPaused(m.id, true)).toBe(true)
+ quiet(620); expect(liveSilentMs(m.id)).toBe(0)
+ expect(setRecordingPaused(m.id, false)).toBe(true)
+ frame(); expect(liveSilentMs(m.id)).toBeLessThan(1000)
+ quiet(610); expect(liveSilentMs(m.id)).toBeGreaterThanOrEqual(60_000)
+ now += 3001; expect(liveSilentMs(m.id)).toBe(0)
+ frame(); expect(liveSilentMs(m.id)).toBe(0)
+ quiet(610)
+ output.write(encodeFrame({ t: 'speech', track: 'me', final: false, text: 'Still talking', startMs: ms, endMs: ms + 100 }))
+ expect(liveSilentMs(m.id)).toBe(0)
+ quiet(610)
+ // One missing track is unknown input, not a quiet conversation.
+ for (let i = 0; i < 31; i++) { now += 100; ms += 100; output.write(encodeFrame({ t: 'pcm', track: 'me', ms, samples: new Float32Array(1600) })) }
+ expect(liveSilentMs(m.id)).toBe(0)
+ frame(); expect(liveSilentMs(m.id)).toBe(0)
+ } finally { time.mockRestore(); await r.stop(m) }
+ expect(liveSilentMs(m.id)).toBe(0)
+ })
+ it('cannot claim silence without a speech pipeline, before capture, or for an unknown meeting', async () => {
+ const r = rig('transcription-first', { modelPath: () => undefined }), m = meeting()
+ expect(liveSilentMs(m.id)).toBe(0)
+ r.begin(m)
+ r.procs[0].say('me', 0)
+ expect(liveSilentMs(m.id, Date.now() + 60_000)).toBe(0)
+ await r.stop(m)
+ })
+})
diff --git a/app/test/watch.test.ts b/app/test/watch.test.ts
index 0b2cb0a4..78483523 100644
--- a/app/test/watch.test.ts
+++ b/app/test/watch.test.ts
@@ -18,6 +18,7 @@ const autoWatcher = () => new Watcher({
read: async () => reading, now: () => clock, active: () => active,
bindApp: (_id, app) => (active = { ...active!, app }),
offer: (p) => log.push('offer:' + p.key), askStop: () => log.push('stop'), hide: () => log.push('hide'),
+ silentMs: () => silent,
autoStop: (m) => log.push('auto:' + m.id), autoStopOn: () => auto,
})
@@ -121,7 +122,7 @@ describe('start cards', () => {
})
describe('stop nudge', () => {
- beforeEach(() => { active = meeting() })
+ beforeEach(() => { active = meeting(); silent = 60_000 })
it('asks once after 30 s without the mic, not at 29 s', async () => {
reading = { micApps: [zoom], events: [] }; await w.tick()
@@ -151,14 +152,17 @@ describe('stop nudge', () => {
clock += 31_000; await w.tick()
expect(log).toEqual(['stop'])
})
- it('the event over by 5 minutes with 60 s of silence asks even with the mic busy', async () => {
+ it('a linked event over by 5 minutes and a quiet minute cannot ask while the mic is held', async () => {
+ silent = 0
const e = ev({ start: clock - 40 * MIN, end: clock - 10 * MIN })
active = meeting({ eventId: 'e1' })
reading = { micApps: [zoom], events: [e] }
await w.tick()
expect(log).toEqual([])
- silent = 60_000; await w.tick()
- expect(log).toEqual(['stop'])
+ clock += MIN; silent = 60_000; await w.tick()
+ expect(log).toEqual([])
+ clock += 4 * MIN; silent = 5 * MIN; await w.tick()
+ expect(log).toEqual([])
})
it('a meeting with no app: the mic rule never fires', async () => {
active = meeting({ app: null })
@@ -166,19 +170,19 @@ describe('stop nudge', () => {
await w.tick(); clock += 10 * MIN; await w.tick()
expect(log).toEqual([])
})
- it('a meeting with no app still ends by the event rule', async () => {
+ it('an overdue event cannot ask about a quiet meeting with no bound app', async () => {
const e = ev({ start: clock - 40 * MIN, end: clock - 10 * MIN })
active = meeting({ app: null, eventId: 'e1' })
reading = { micApps: [], events: [e] }; silent = 60_000
- await w.tick()
- expect(log).toEqual(['stop'])
+ await w.tick(); clock += 10 * MIN; await w.tick()
+ expect(log).toEqual([])
})
})
describe('stops by itself when the call ends', () => {
- beforeEach(() => { active = meeting(); auto = true; w = autoWatcher() })
+ beforeEach(() => { active = meeting(); silent = 60_000; auto = true; w = autoWatcher() })
- it('the call app lets go of the mic for 4 s: stops once, with no question', async () => {
+ it('already quiet for a minute, the app lets go for 4 s: stops once, with no question', async () => {
reading = { micApps: [zoom], events: [] }; await w.tick()
reading = { micApps: [], events: [] }
clock += 3_000; await w.tick()
@@ -224,7 +228,8 @@ describe('stops by itself when the call ends', () => {
await w.tick(); clock += 10 * MIN; await w.tick()
expect(log.filter((l) => l.startsWith('auto'))).toEqual([])
})
- it('the calendar event ending never stops it', async () => {
+ it('the calendar event ending never stops it during speech', async () => {
+ silent = 0
const e = ev({ start: clock - 40 * MIN, end: clock - 10 * MIN })
active = meeting({ eventId: 'e1' })
reading = { micApps: [zoom], events: [e] }
@@ -242,7 +247,7 @@ describe('stops by itself when the call ends', () => {
describe('binding a call after any recording start', () => {
- beforeEach(() => { active = meeting({ app: null }); auto = true; w = autoWatcher() })
+ beforeEach(() => { active = meeting({ app: null }); silent = 60_000; auto = true; w = autoWatcher() })
// a recording started by hand (New note, Take notes on the agenda) is never stopped by itself: the call app letting go of
// the mic while joining (a browser's pre-join screen) stopped one mid-meeting. It asks, as before, after 30 s
it.each([zoom, { bundleId: 'us.zoom.CptHost', name: 'CptHost' }, { bundleId: 'com.apple.avconferenced', name: 'avconferenced' }])('binds $bundleId ten seconds after a start by hand, never stops it by itself, and asks after 30 s without the mic', async (mic) => {
@@ -288,7 +293,7 @@ describe('binding a call after any recording start', () => {
it('does not keep a FaceTime recording alive for the shared daemon after FaceTime exits', async () => {
- active = meeting({ app: 'FaceTime' }); auto = true; w = autoWatcher()
+ active = meeting({ app: 'FaceTime' }); silent = 60_000; auto = true; w = autoWatcher()
reading = { micApps: [{ bundleId: 'com.apple.avconferenced', name: 'avconferenced' }], events: [], runningApps: ['com.apple.FaceTime'] }
await w.tick()
reading.runningApps = []; clock += 10000; await w.tick()
@@ -313,3 +318,57 @@ describe('on a call', () => {
expect(w.onCall()).toBe(true)
})
})
+
+
+describe('speech protects a call whose app released the mic', () => {
+ it('continuous speech prevents cards even after multiple five-minute snoozes would have elapsed', async () => {
+ active = meeting(); reading.micApps = [zoom]; await w.tick()
+ reading.micApps = []
+ for (let i = 0; i < 20; i++) { clock += MIN; silent = 0; await w.tick() }
+ expect(log).toEqual([])
+ silent = 59_999; await w.tick(); expect(log).toEqual([])
+ silent = 60_000; await w.tick(); expect(log).toEqual(['stop'])
+ })
+ it('Keep going stays quiet through speech and asks again only after a quiet minute and the snooze', async () => {
+ active = meeting(); reading.micApps = [zoom]; await w.tick()
+ reading.micApps = []; clock += MIN; silent = MIN; await w.tick()
+ expect(log).toEqual(['stop'])
+ w.keepGoing()
+ for (let i = 0; i < 10; i++) { clock += MIN; silent = 0; await w.tick() }
+ expect(log).toEqual(['stop'])
+ clock += 59_999; silent = 59_999; await w.tick()
+ expect(log).toEqual(['stop'])
+ clock++; silent++; await w.tick()
+ expect(log).toEqual(['stop', 'stop'])
+ })
+ it('takes down an already-shown card when speech resumes, even if the app stays off the mic', async () => {
+ active = meeting(); reading.micApps = [zoom]; await w.tick()
+ reading.micApps = []; clock += MIN; silent = MIN; await w.tick()
+ silent = 0; await w.tick()
+ expect(log).toEqual(['stop', 'hide'])
+ })
+ it('auto-stop waits for silence, not just the four-second app grace', async () => {
+ active = meeting(); w = autoWatcher(); auto = true
+ reading.micApps = [zoom]; await w.tick()
+ reading.micApps = []
+ for (let i = 0; i < 10; i++) { clock += MIN; silent = 0; await w.tick() }
+ expect(log).toEqual([])
+ silent = 59_999; await w.tick(); expect(log).toEqual([])
+ silent = MIN; await w.tick(); expect(log).toEqual(['auto:m1'])
+ })
+ it('an open app without microphone use never binds a manually started meeting', async () => {
+ active = meeting({ app: null }); reading.runningApps = ['us.zoom.xos']
+ await w.tick(); clock += MIN; await w.tick()
+ expect(active.app).toBeNull()
+ expect(log).toEqual([])
+ })
+ it('missing silence evidence cannot ask or auto-stop', async () => {
+ active = meeting()
+ const x = new Watcher({ read: async () => reading, now: () => clock, active: () => active,
+ bindApp: () => undefined, offer: vi.fn(), askStop: () => log.push('stop'), hide: vi.fn(),
+ autoStop: () => log.push('auto'), autoStopOn: () => true })
+ reading.micApps = [zoom]; await x.tick()
+ reading.micApps = []; clock += 10 * MIN; await x.tick()
+ expect(log).toEqual([])
+ })
+})