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.

Speech: when whisper-server goes down partway through a meeting, the rest is transcribed from the saved recording afterwards, from where its lines end; a saved recording is never read while its live transcript is still being finished, and a waiting label left on a meeting that is done is cleared (#127)

christianmat8cfe1c4bbae4
diff --git a/app/src/main/asr/index.ts b/app/src/main/asr/index.ts
index 1f3545b7..6bc16574 100644
--- a/app/src/main/asr/index.ts
+++ b/app/src/main/asr/index.ts
@@ -24,6 +24,8 @@ import type { Chunk } from './chunker'
type Session = { complete?: () => boolean; pipeline: Pipeline | null; priorLines: Set<number>; done?: Promise<void>; store?: SessionStore; refresh?: (id: string) => void
/** a saved recording that could not be read to the end (transcribeRecorded): the meeting keeps waiting */
failed?: boolean
+ /** a live meeting whose speech engine was there: a transcript left incomplete is queued for its saved recording */
+ liveEngine?: 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
@@ -123,6 +125,9 @@ export const SERVER_IDLE_MS = 10 * 60_000
let idleTimer: NodeJS.Timeout | undefined
let idleMs = SERVER_IDLE_MS
+/** a live meeting's transcript came out incomplete and its saved recording is queued (savedTranscription picks it up) */
+let queuedListener: ((id: string) => void) | undefined
+
/** whisper-server left the graphics card during a meeting (Windows and Linux) */
let gpuOffListener: (() => void) | undefined
export function onWhisperGpuOff(cb: () => void) { gpuOffListener = cb }
@@ -183,8 +188,11 @@ export function hookTranscription(p: {
speech?: { host: SpeechHost; binary: string; ui: () => string; last: () => string | null; locales?: () => Promise<SpeechLocales>; install?: (locale: string) => Promise<boolean> }
/** the spoken language picked in Settings or the note (English only when left out) */
spoken?: () => Spoken
+ /** a live transcript came out incomplete (whisper-server died, #127): its saved recording waits to be transcribed */
+ queued?: (meetingId: string) => void
}): () => void {
idleMs = p.serverIdleMs ?? SERVER_IDLE_MS
+ queuedListener = p.queued
spokenNow = p.spoken ?? (() => 'en')
if (p.speech && appleSpeechAvailable(p.speech.host)) {
const sp = p.speech
@@ -242,7 +250,7 @@ export function hookTranscription(p: {
}
const s: Session = {
complete: () => !!transcribe && !pendingBefore && !saveFailed && !warned.has('transcribe-failed') && !s.failed && !options?.signal?.aborted,
- replacement: !!options?.save, store: p.store, refresh: p.refresh, speech: speechLocaleFor(id), priorLines: new Set(p.store.segments?.(id).map((s) => s.id) ?? []),
+ replacement: !!options?.save, liveEngine: !later && !!transcribe, store: p.store, refresh: p.refresh, speech: speechLocaleFor(id), priorLines: new Set(p.store.segments?.(id).map((s) => s.id) ?? []),
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)
@@ -342,9 +350,13 @@ function sweepEcho(id: string, s: Session) {
/** After the recorder is done (no more audio coming), the pipeline finishes what it has, then echoes are swept */
function finishSession(id: string, s: Session, audioDone: () => Promise<void> = () => Promise.resolve(), store?: SessionStore): Promise<void> {
s.store ??= store
+ let queued = false
s.done ??= audioDone().then(() => s.pipeline?.finish()).then(() => {
if (!s.replacement) sweepEcho(id, s)
if (!s.replacement && s.complete?.()) s.store?.updateMeeting(id, { transcriptionPending: false })
+ // whisper-server went down partway (#127): the audio is all in the saved recording, so the rest is transcribed from
+ // there, from where the lines end. Queued (not left as is) because a meeting with some lines is otherwise never picked up.
+ else if (s.liveEngine) { s.store?.updateMeeting(id, { transcriptionState: 'queued' }); queued = true; console.warn('ASR the transcript is incomplete: the rest is transcribed from the saved recording') }
}).catch((e) => { s.failed = true; console.error('finishing the transcript failed', e) }).finally(() => {
// the meeting's main language is kept with it, for notes written later (after a restart too)
const lang = meetingLanguage(id)
@@ -352,10 +364,14 @@ function finishSession(id: string, s: Session, audioDone: () => Promise<void> =
heard.delete(id)
if (sessions.get(id) === s) sessions.delete(id)
armServerIdle()
+ if (queued) { try { queuedListener?.(id) } catch (e) { console.error('queueing the saved recording failed', e) } }
})
return s.done
}
+/** The meeting's live transcript is still being worked on or finished: its saved recording must wait */
+export const transcriptOpen = (id: string): boolean => sessions.has(id)
+
/** Resolves when the meeting's transcript is all saved (after it stops); at once when there is nothing left to do */
export const transcriptFinished = (id: string): Promise<void> => sessions.get(id)?.done ?? Promise.resolve()
diff --git a/app/src/main/index.ts b/app/src/main/index.ts
index 2253a9dc..e5dfeba5 100644
--- a/app/src/main/index.ts
+++ b/app/src/main/index.ts
@@ -60,7 +60,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 { liveSilentMs, 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, transcriptOpen, transcriptPartials } from './asr'
import { hookCallNames, type Watch } from './callNames'
import { helperWatch, killAllWatches } from './callNames/watch'
import { macFullName } from './user'
@@ -606,6 +606,8 @@ app.whenReady().then(() => {
refresh: (id) => { win?.webContents.send('transcript:speakers', id); sendWidgetTranscript('transcript:speakers', id) },
sendPartial: (part) => { win?.webContents.send('transcript:partial', part); sendWidgetTranscript('transcript:partial', part) },
warn: (code) => tell({ t: 'warn', code }), pidFile: join(userDataDir(), 'whisper-server.pid'),
+ // whisper-server went down mid-meeting (#127): the rest is read from the saved recording once the transcript is settled
+ queued: () => { void savedTranscriptions.pump() },
// English only (the default) or Multi-language, read on each chunk so the footer's picker counts at once
spoken: () => spokenSetting(loadSettings(settingsFile)),
// Apple's on-device speech for the live words (macOS 26, Apple Silicon); fake mode has a stand-in when a test asks
@@ -698,7 +700,7 @@ app.whenReady().then(() => {
})
let finishing = false, discardUnsaved = false
const savedTranscriptions = createSavedTranscriptions({
- store, ready: () => !!setup.installed()?.asr, recording: () => !!activeMeeting() || !!resumingId || finishing,
+ store, ready: () => !!setup.installed()?.asr, recording: () => !!activeMeeting() || !!resumingId || finishing, live: transcriptOpen,
tracks: async id => {
await recordingSettled(id)
const tracks: Partial<Record<'me'|'them',AsyncIterable<Float32Array>>> = {}
diff --git a/app/src/main/savedTranscription.ts b/app/src/main/savedTranscription.ts
index 0b0e3a8e..023b4c80 100644
--- a/app/src/main/savedTranscription.ts
+++ b/app/src/main/savedTranscription.ts
@@ -6,6 +6,8 @@ import type { TranscriptionState } from '../shared/transcription'
/** One queue for uploaded audio and saved recordings. Stopping never deletes either. */
export function createSavedTranscriptions(d: {
store: Store; ready: () => boolean; recording: () => boolean
+ /** its live transcript is still being finished: reading the saved recording now would race it (#127) */
+ live?: (id: string) => boolean
tracks: (id: string) => Promise<Partial<Record<Track,AsyncIterable<Float32Array>>>>
transcribe: (id: string, tracks: Partial<Record<Track,AsyncIterable<Float32Array>>>, options: RecordedOptions) => Promise<boolean>
draft?: (id:string) => void
@@ -19,11 +21,14 @@ export function createSavedTranscriptions(d: {
if(draining||quitting)return
draining=true
try {
+ // a waiting label on a meeting whose transcript got done some other way would stay up for good (#127)
+ for(const id of d.store.clearFinishedTranscriptionStates())d.changed(id)
for(const meeting of d.store.untranscribedMeetings()) {
if(quitting)break
const id=meeting.id
const current=d.store.meeting(id)
if(!current||current.trashedAt!=null||['stopped','error','preparing','done'].includes(current.transcriptionState??''))continue
+ if(d.live?.(id))continue
if(d.recording()){set(id,'waiting-recording');continue}
if(!d.ready()){set(id,'waiting-model');continue}
const job={id,abort:new AbortController(),stopped:false};running=job;set(id,'transcribing')
diff --git a/app/src/main/store.ts b/app/src/main/store.ts
index 77a08c10..e5943e3e 100644
--- a/app/src/main/store.ts
+++ b/app/src/main/store.ts
@@ -408,6 +408,11 @@ export class Store {
return (rows as Row[]).map(r => this.readMeeting(r))
}
+ /** Waiting or queued labels on meetings with nothing left to transcribe (recordings, not uploads or replacements): cleared, their ids returned */
+ clearFinishedTranscriptionStates(): string[] {
+ return (this.db.prepare(`UPDATE meetings SET transcription_state=NULL WHERE transcription_pending=0 AND transcription_again=0 AND COALESCE(source,'')!='audio-file'
+ AND transcription_state IN ('queued','transcribing','waiting-model','waiting-recording') RETURNING id`).all() as Array<{ id: string }>).map(r => r.id)
+ }
clearTranscriptionState(id:string) { this.db.prepare('UPDATE meetings SET transcription_state=NULL,transcription_again=0 WHERE id=?').run(id);this.clearTranscriptionDraft(id) }
interruptAudioPreparations() {
this.db.prepare("UPDATE meetings SET transcription_state='error',transcription_pending=0 WHERE source='audio-file' AND transcription_state='preparing'").run()
diff --git a/app/test/savedTranscription.test.ts b/app/test/savedTranscription.test.ts
index fe7ca7dd..cbb5cf9d 100644
--- a/app/test/savedTranscription.test.ts
+++ b/app/test/savedTranscription.test.ts
@@ -75,3 +75,18 @@ it('retains a complete original when a replacement finishes without usable words
const id=note().id;store.addSegments([line(id,0,300,'Original')]);await jobs.start(id,true)
await vi.waitFor(()=>expect(jobs.owns(id)).toBe(false));expect(store.segments(id).map(l=>l.text)).toEqual(['Original']);expect(store.meeting(id)?.transcriptionAgain).not.toBe(true);expect(summarize).not.toHaveBeenCalled()
})
+
+it('leaves a meeting alone while its live transcript is still being finished (#127)',async()=>{
+ const id=note().id;store.updateMeeting(id,{transcriptionPending:true});let live=true
+ jobs=createSavedTranscriptions({store,ready:()=>model,recording:()=>recording,live:()=>live,tracks:async()=>({them:(async function*(){yield new Float32Array(1600)})()}),transcribe,summarize,changed})
+ recording=true;await jobs.pump();recording=false;await jobs.pump()
+ expect(transcribe).not.toHaveBeenCalled();expect(store.meeting(id)?.transcriptionState).toBeUndefined()
+ live=false;await jobs.pump();await vi.waitFor(()=>expect(store.meeting(id)?.transcriptionState).toBe('done'))
+})
+it('clears a waiting label left on a meeting whose transcript is already done (#127)',async()=>{
+ const id=note().id;store.updateMeeting(id,{state:'done',transcriptionPending:false,transcriptionState:'waiting-recording'})
+ const upload=note().id;store.db.prepare('UPDATE meetings SET source=? WHERE id=?').run('audio-file',upload);store.updateMeeting(upload,{transcriptionPending:false,transcriptionState:'preparing'})
+ await jobs.pump()
+ expect(store.meeting(id)?.transcriptionState).toBeUndefined();expect(changed).toHaveBeenCalledWith(id)
+ expect(store.meeting(upload)?.transcriptionState).toBe('preparing')
+})
diff --git a/app/test/transcription.test.ts b/app/test/transcription.test.ts
index 03f496f3..8444df6a 100644
--- a/app/test/transcription.test.ts
+++ b/app/test/transcription.test.ts
@@ -44,7 +44,7 @@ const disposers: Array<() => void> = []
afterEach(async () => { disposers.splice(0).forEach((d) => d()); await settleTranscription(2000); stopTranscriptionServer() })
/** both hooks over one shared start/stop fan-out, registered in the order asked for */
-function rig(order: 'capture-first' | 'transcription-first', t: { transcriber?: (c: Chunk, heard?: (language: string, chars: number) => void) => Promise<Line[]> | Line[]; modelPath?: () => string | undefined; refresh?: (id: string) => void; holdMs?: number } = {}) {
+function rig(order: 'capture-first' | 'transcription-first', t: { transcriber?: (c: Chunk, heard?: (language: string, chars: number) => void) => Promise<Line[]> | Line[]; modelPath?: () => string | undefined; refresh?: (id: string) => void; holdMs?: number; queued?: (id: string) => void } = {}) {
const starts: Array<(m: Meeting) => void> = [], stops: Array<(m: Meeting) => void> = []
const onStart = (fn: (m: Meeting) => void) => { starts.push(fn); return () => {} }
const onStop = (fn: (m: Meeting) => void) => { stops.push(fn); return () => {} }
@@ -52,7 +52,7 @@ function rig(order: 'capture-first' | 'transcription-first', t: { transcriber?:
const sent: string[] = [], warns: string[] = []
const hookT = () => disposers.push(hookTranscription({
store, modelPath: t.modelPath ?? (() => '/model.bin'), send: (s) => sent.push(`${s.track}:${s.text}`), warn: (c) => warns.push(c),
- refresh: t.refresh, holdMs: t.holdMs, transcriber: 'transcriber' in t ? t.transcriber : async (c) => says(c), onStart, onStop, pidFile: undefined,
+ refresh: t.refresh, holdMs: t.holdMs, queued: t.queued, transcriber: 'transcriber' in t ? t.transcriber : async (c) => says(c), onStart, onStop, pidFile: undefined,
}))
const hookC = () => hookCapture({
dirOf: (id) => `/m/${id}`, onStart, onStop, stopMeeting: (id) => stops.forEach((f) => f({ id } as Meeting)),
@@ -433,15 +433,20 @@ describe('a meeting recorded before the speech model was in (#30)', () => {
expect(await transcribeRecorded(m.id, { them: track(1) })).toBe(false)
expect(store.meeting(m.id)?.transcriptionPending).toBe(true)
})
- it('a meeting with some transcript is never transcribed again (no lines twice)', async () => {
- const r = rig('transcription-first', { transcriber: async () => { throw new Error('whisper fell over') } })
+ it('whisper failing partway through a live meeting queues the rest of its saved recording for later (#127)', async () => {
+ let calls = 0
+ const queued: string[] = []
+ const r = rig('transcription-first', { transcriber: async (c) => { if (calls++) throw new Error('whisper-server exited (SIGKILL)'); return says(c) }, queued: (id) => queued.push(id) })
const m = meeting()
- r.begin(m); r.procs[0].say('them', 500)
+ r.begin(m); r.procs[0].say('them', 500); r.procs[0].say('them', 4000)
+ await tick()
await r.stop(m)
store.updateMeeting(m.id, { state: 'stopped' })
- store.addSegments([{ meetingId: m.id, track: 'them', startMs: 0, endMs: 900, text: 'one line made it', speaker: null }])
- expect(store.meeting(m.id)?.transcriptionPending).toBe(true)
- expect(store.untranscribedMeetings()).toEqual([])
+ expect(store.segments(m.id)).toHaveLength(1)
+ expect(store.meeting(m.id)).toMatchObject({ transcriptionPending: true, transcriptionState: 'queued' })
+ // the saved recording carries on from where its lines end (savedTranscription's fromMs), so no line comes twice
+ expect(store.untranscribedMeetings().map((x) => x.id)).toEqual([m.id])
+ expect(queued).toEqual([m.id])
})
it('without the model yet, nothing happens and the meeting keeps waiting', async () => {
rig('transcription-first', { modelPath: () => undefined })