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
Speech (Windows, Linux): where only base keeps up live, Multi-language meetings are transcribed right after they end with small or turbo instead, and the speed check times models up to twice the clip's length (#107)
christianmat710478112933
diff --git a/app/src/main/asr/speedCheck.ts b/app/src/main/asr/speedCheck.tsindex f895a106..0706349c 100644--- a/app/src/main/asr/speedCheck.ts+++ b/app/src/main/asr/speedCheck.ts@@ -1,5 +1,6 @@import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'import { dirname, join } from 'node:path'+import { AFTER_MEETING_RTF } from '@yogurt/picker'import type { SpeedDeps, SpeedResult } from '../setup'import { createWhisperServer, type WhisperServer } from './server'import { createTranscriber } from './transcribe'@@ -47,8 +48,9 @@ type MeasureOpts = {/*** The realtime factor of one careful (beam 5) reading of the clip: time taken over its length. The first 3 s are read- * once beforehand, so loading and the graphics' first-run work are not counted. A reading that takes longer than the- * clip itself is stopped: null, too slow by far.+ * once beforehand, so loading and the graphics' first-run work are not counted. A reading that takes longer than+ * AFTER_MEETING_RTF times the clip is stopped: null, too slow by far (up to that it can still read recordings after the+ * meeting, #107).*/export async function measureSpeed(model: string, o: MeasureOpts): Promise<{ rtf: number | null; gpuOff: boolean }> {const srv = o.server?.(model) ?? createWhisperServer({ binary: o.binary, model, vadModel: o.vadModel, gpuFallback: !o.cpu, cpuOnly: o.cpu, startTimeoutMs: 180_000, backoffMs: [0], checkGpu: (url) => hearsClip(url, readWav(readFileSync(o.clip)).subarray(0, 5 * 16000)) })@@ -59,7 +61,7 @@ export async function measureSpeed(model: string, o: MeasureOpts): Promise<{ rtfawait srv.url().catch(() => srv.url())const language = () => 'en'await createTranscriber({ url: () => srv.url(), language, timeoutMs: 120_000 })({ track: 'them', startMs: 0, samples: samples.subarray(0, 3 * 16000) })- const read = createTranscriber({ url: () => srv.url(), language, timeoutMs: Math.round(clipMs) })+ const read = createTranscriber({ url: () => srv.url(), language, timeoutMs: Math.round(clipMs * AFTER_MEETING_RTF) })const t0 = performance.now()try { await read({ track: 'them', startMs: 0, samples }) } catch (e) {if (e instanceof Error && e.name === 'TimeoutError') return { rtf: null, gpuOff: srv.cpuOnly }diff --git a/app/src/main/index.ts b/app/src/main/index.tsindex acd2c169..c8d3450b 100644--- a/app/src/main/index.ts+++ b/app/src/main/index.ts@@ -44,7 +44,7 @@ import { loginItemOn, openedAtLogin, setLoginItem, syncLoginItem } from './loginimport { createMedia } from './media'import { createTray, linuxTrayHost } from './tray'import { trayWindowEnd } from './trayMenu'-import { SetupController } from './setup'+import { asrFor, SetupController } from './setup'import { fakeMeasure, measureSpeed, speedClipPath, speedStore } from './asr/speedCheck'import { vadModelPath, whisperServerPath } from './asr/server'import { openStore, type Store } from './store'@@ -668,9 +668,12 @@ app.whenReady().then(() => {if (process.platform === 'darwin' || process.platform === 'win32') lookForCallOf = (app, back) => callNames.lookForCall(app, back)// Windows and Linux: whisper left the graphics card in a meeting, so the speed check (timed with it) runs again next startonWhisperGpuOff(() => speedStore(speedFile()).forget())- hookTranscription({ store, modelPath: () => setup.installed()?.asr, smallerModels: () => setup.installed()?.smallerAsr ?? [],+ // the speech model for the spoken language: where base keeps up live but is poor outside English, Multi-language+ // meetings are read with a better one from the recording after they end (#107)+ const asrNow = () => { const i = setup.installed(); return i && asrFor(i, spokenSetting(loadSettings(settingsFile))) }+ hookTranscription({ store, modelPath: () => asrNow()?.path, smallerModels: () => setup.installed()?.smallerAsr ?? [],// the speed check's findings: whisper on the processor (faster there than on built-in graphics), or after the meeting- cpuOnly: () => !!setup.installed()?.asrCpu, afterMeeting: () => !!setup.installed()?.asrAfterMeeting, send: (seg) => {+ cpuOnly: () => !!asrNow()?.cpu, afterMeeting: () => !!asrNow()?.afterMeeting, send: (seg) => {const order = seg.track === 'them' && seg.speaker ? store.speakerOrder(seg.meetingId, seg.speaker) : []const colored = { ...seg, speakerColor: speakerColor(seg.track, seg.speaker, order) }win?.webContents.send('transcript:segment', colored); sendWidgetTranscript('transcript:segment', colored)diff --git a/app/src/main/setup.ts b/app/src/main/setup.tsindex 0dcc8961..616f0565 100644--- a/app/src/main/setup.ts+++ b/app/src/main/setup.ts@@ -6,12 +6,14 @@ import { ChecksumError, DiskSpaceError, ensureFile, fileNameFor, isVerified, parimport type { SetupState } from '../shared/types'import { t } from '../shared/i18n'import { tooSlow, tooWeak } from './localCheck'+import type { Spoken } from '../shared/spoken'/** What the speed check found on one computer (speedKey): the model kept (null: none keeps up) and each one's time over the clip's length */export type SpeedResult = { key: string; model: string | null; rtf: Record<string, number | null>; at: number; /** whisper had to leave the graphics card while it was timed */ gpuOff?: boolean/** times on the processor alone, for models too slow on the graphics */ cpuRtf?: Record<string, number | null>/** the model kept up on the processor, not the graphics: whisper stays there */ cpu?: boolean- /** none keeps up live: meetings are transcribed from the recording after they end */ afterMeeting?: boolean }+ /** none keeps up live: meetings are transcribed from the recording after they end */ afterMeeting?: boolean+ /** the model kept is weak outside English: this better one reads meetings in other languages after they end (#107) */ multi?: { model: string; cpu?: boolean } }/** Windows and Linux: time a speech model on this computer (null: it ran out of time), and keep what was found */export type SpeedDeps = {/** cpu: on the processor alone, never the graphics */@@ -39,7 +41,16 @@ export type SetupDeps = {}/** Where the models ended up, for the parts of the app that use them; llm once the first notes model is in (after ready) */-export type Installed = { asr: string; /** whisper runs on the processor: it kept up there and not on the graphics */ asrCpu?: true; /** whisper can't keep up live here: meetings are transcribed after they end */ asrAfterMeeting?: true; /** smaller speech models already on disk, best first: one takes over when the processor is too slow for asr (#156) */ smallerAsr?: string[]; llm?: string; recommendedLlm?: string; /** meaning search across meetings; word search works without it */ embed?: string }+export type Installed = { asr: string; /** whisper runs on the processor: it kept up there and not on the graphics */ asrCpu?: true; /** whisper can't keep up live here: meetings are transcribed after they end */ asrAfterMeeting?: true; /** asr is weak outside English: meetings in other languages are read with this one after they end (#107) */ asrMulti?: string; /** asrMulti runs on the processor */ asrMultiCpu?: true; /** smaller speech models already on disk, best first: one takes over when the processor is too slow for asr (#156) */ smallerAsr?: string[]; llm?: string; recommendedLlm?: string; /** meaning search across meetings; word search works without it */ embed?: string }++/**+ * The speech model for a meeting in this spoken language: English only reads with asr as always; Multi-language with+ * asrMulti where there is one, from the recording after the meeting (#107: base kept up live, but is poor outside English).+ */+export function asrFor(i: Installed, spoken: Spoken): { path: string; cpu: boolean; afterMeeting: boolean } {+ if (spoken !== 'en' && i.asrMulti) return { path: i.asrMulti, cpu: !!i.asrMultiCpu, afterMeeting: true }+ return { path: i.asr, cpu: !!i.asrCpu, afterMeeting: !!i.asrAfterMeeting }+}/** the first notes model keeps being tried after ready: a minute, five, then every ten (a download picks up where it stopped) */const NOTES_RETRY_MS = [60_000, 5 * 60_000, 10 * 60_000]@@ -238,8 +249,10 @@ export class SetupController {if (speed && !candidates.length) return this.set({ phase: 'error', fraction: 0, message: tooSlow(hw.os) })const keep = known && candidates.find((a) => a.id === known.model)let how: Pick<Installed, 'asrCpu' | 'asrAfterMeeting'> = keep ? { ...(known.cpu ? { asrCpu: true } : {}), ...(known.afterMeeting ? { asrAfterMeeting: true } : {}) } : {}+ const keepMulti = keep && known.multi && candidates.find((a) => a.id === known.multi!.model)+ let multi: Pick<Installed, 'asrMulti' | 'asrMultiCpu'> = {}- const waitFor: Item[] = [asrItem(speed ? keep ?? candidates[0] : asr.model)]+ const waitFor: Item[] = [asrItem(speed ? keep ?? candidates[0] : asr.model), ...(keepMulti ? [asrItem(keepMulti)] : [])]const total = waitFor.reduce((n, i) => n + i.bytes, 0)// room for the first notes model too, so it never runs out of disk after readyawait this.checkDisk([...waitFor, ...(hasUpgrade ? [] : [starterItem]), embedItem])@@ -257,8 +270,10 @@ export class SetupController {// speech: if the first choice downloads corrupted twice, the smaller one takes its placeconst tried: string[] = []let asrPath: string | undefined- if (speed && keep) asrPath = await get(asrItem(keep))- else if (speed) {+ if (speed && keep) {+ asrPath = await get(asrItem(keep))+ if (keepMulti) multi = { asrMulti: await get(asrItem(keepMulti)), ...(known.multi!.cpu ? { asrMultiCpu: true } : {}) }+ } else if (speed) {const r = await this.timeSpeech(speed, candidates, get, asrItem, hw.gpu.kind !== 'none')speed.save({ key, ...r.result, at: Date.now() })// every model downloaded corrupted: nothing to transcribe with@@ -266,6 +281,10 @@ export class SetupController {asrPath = r.pathhow = { ...(r.result.cpu ? { asrCpu: true } : {}), ...(r.result.afterMeeting ? { asrAfterMeeting: true } : {}) }if (r.result.afterMeeting) console.warn(`speed check: no speech model keeps up live here; ${r.result.model} transcribes meetings after they end`)+ if (r.multiPath) {+ multi = { asrMulti: r.multiPath, ...(r.result.multi?.cpu ? { asrMultiCpu: true } : {}) }+ console.warn(`speed check: ${r.result.model} is weak outside English; ${r.result.multi!.model} transcribes meetings in other languages after they end`)+ }}while (!asrPath) {try { asrPath = await get(asrItem(asr.model)) } catch (err) {@@ -277,7 +296,7 @@ export class SetupController {// never downloaded for this: only what is already there (a model the speed check or an earlier pick left)const picked = catalog.asr.findIndex((a) => join(dirs.asr, fileNameFor(a.url)) === asrPath)const smallerAsr = picked < 0 ? [] : catalog.asr.slice(picked + 1).map(asrItem).filter((i) => isVerified(i.dir, i.fileName, this.sha(i))).map((i) => join(i.dir, i.fileName))- this.paths = { asr: asrPath, ...how, ...(smallerAsr.length ? { smallerAsr } : {}) }+ this.paths = { asr: asrPath, ...how, ...multi, ...(smallerAsr.length ? { smallerAsr } : {}) }if (hasUpgrade) {this.paths.recommendedLlm = join(bigger!.dir, bigger!.fileName)if (isVerified(starterItem.dir, starterItem.fileName, this.sha(starterItem))) this.paths.llm = join(starterItem.dir, starterItem.fileName)@@ -316,11 +335,13 @@ export class SetupController {return t.rtf// small may lag a little behind live: base and tiny are very weak outside English (#107). With graphics, a model too// slow there is timed on the processor too (turbo never: 4 to 9 times too slow there); a built-in Radeon can be slower- }, { lagsOk: (m) => m.id.startsWith('whisper-small'), cpuToo: (m) => graphics && !m.gpuOnly && !ranOnCpu.has(m.id) && !corrupt.has(m.id) })+ // base and tiny (last resort) are weak outside English: a better one that reads recordings after the meeting is kept too+ }, { lagsOk: (m) => m.id.startsWith('whisper-small'), cpuToo: (m) => graphics && !m.gpuOnly && !ranOnCpu.has(m.id) && !corrupt.has(m.id), weak: (m) => !!m.lastResort })// the smallest fallback may be one that downloaded corrupted: then the smallest that did notconst model = r.model && !corrupt.has(r.model.id) ? r.model : [...candidates].reverse().find((c) => paths.has(c.id) && !corrupt.has(c.id)) ?? null- for (const [id, p] of paths) if (id !== model?.id) rmSync(p, { force: true })- return { path: model && paths.get(model.id), result: { model: model?.id ?? null, rtf: r.rtf, ...(r.cpuRtf ? { cpuRtf: r.cpuRtf } : {}), ...(gpuOff ? { gpuOff } : {}), ...(r.cpu && model === r.model ? { cpu: true } : {}), ...(r.afterMeeting || model !== r.model ? { afterMeeting: true } : {}) } }+ const multi = model === r.model && r.multi && paths.has(r.multi.model.id) ? r.multi : undefined+ for (const [id, p] of paths) if (id !== model?.id && id !== multi?.model.id) rmSync(p, { force: true })+ return { path: model && paths.get(model.id), multiPath: multi && paths.get(multi.model.id), result: { model: model?.id ?? null, rtf: r.rtf, ...(r.cpuRtf ? { cpuRtf: r.cpuRtf } : {}), ...(gpuOff ? { gpuOff } : {}), ...(r.cpu && model === r.model ? { cpu: true } : {}), ...(r.afterMeeting || model !== r.model ? { afterMeeting: true } : {}), ...(multi ? { multi: { model: multi.model.id, ...(multi.cpu ? { cpu: true } : {}) } } : {}) } }}/**diff --git a/app/test/setup.test.ts b/app/test/setup.test.tsindex 0803e051..dc655926 100644--- a/app/test/setup.test.ts+++ b/app/test/setup.test.ts@@ -4,7 +4,7 @@ import { join } from 'node:path'import { describe, expect, it, vi } from 'vitest'import { speedKey, type Catalog, type Hardware } from '@yogurt/picker'import bundled from '../../catalog/catalog.json'-import { SetupController, type SetupDeps, type SpeedDeps, type SpeedResult } from '../src/main/setup'+import { asrFor, SetupController, type SetupDeps, type SpeedDeps, type SpeedResult } from '../src/main/setup'import { fakeDownloadDeps } from '../src/main/fake'import { DiskSpaceError, type DownloadDeps } from '../src/main/downloader'import type { SetupState } from '../src/shared/types'@@ -604,6 +604,38 @@ describe('the speed check (Windows and Linux): speech models timed on this compuexpect(s.timed).toHaveLength(3)})+ // #107 (a Xeon with an AMD WX 3200 whose Vulkan fails the hearing test): base keeps up live but small does not. English+ // keeps base live; a meeting in another language is read with small from its recording after it ends+ it('base keeps up live but small reads within twice the clip: small is kept too, for meetings in other languages', async () => {+ const s = speed({ 'whisper-small-q5_1': 1.6, 'whisper-base-q5_1': 0.3 })+ const { c, root } = setup({ getHardware: async () => cpuPc, speed: s.deps })+ await c.start(); await c.idle()+ const small = join(root, 'asr', name(url('whisper-small-q5_1'))), base = join(root, 'asr', name(url('whisper-base-q5_1')))+ expect(c.installed()).toMatchObject({ asr: base, asrMulti: small })+ expect(c.installed()?.asrAfterMeeting).toBeUndefined()+ expect(existsSync(small)).toBe(true)+ expect(s.stored()).toMatchObject({ model: 'whisper-base-q5_1', multi: { model: 'whisper-small-q5_1' } })+ expect(asrFor(c.installed()!, 'en')).toEqual({ path: base, cpu: false, afterMeeting: false })+ expect(asrFor(c.installed()!, 'multi')).toEqual({ path: small, cpu: false, afterMeeting: true })++ const again = setup({ getHardware: async () => cpuPc, speed: s.deps, modelsDir: root })+ await again.c.start(); await again.c.idle()+ expect(again.c.installed()).toMatchObject({ asr: base, asrMulti: small })+ expect(s.timed).toHaveLength(2)+ })+ it('the better model for other languages on the processor where the graphics were slower for it', async () => {+ const s = speed({ 'whisper-large-v3-turbo-q5_0': null, 'whisper-small-q5_1': null, 'whisper-base-q5_1': 0.3 }, undefined, { 'whisper-small-q5_1': 1.5 })+ const { c } = setup({ getHardware: async () => gpuPc, speed: s.deps })+ await c.start(); await c.idle()+ expect(c.installed()).toMatchObject({ asrMultiCpu: true })+ expect(asrFor(c.installed()!, 'multi')).toMatchObject({ cpu: true, afterMeeting: true })+ expect(asrFor(c.installed()!, 'en')).toMatchObject({ cpu: false, afterMeeting: false })+ })+ it('a strong model live: the same model for every language', () => {+ expect(asrFor({ asr: '/a/small.bin', asrCpu: true }, 'multi')).toEqual({ path: '/a/small.bin', cpu: true, afterMeeting: false })+ expect(asrFor({ asr: '/a/base.bin', asrAfterMeeting: true }, 'en')).toEqual({ path: '/a/base.bin', cpu: false, afterMeeting: true })+ })+it('without graphics the processor is not timed twice', async () => {const s = speed({ 'whisper-small-q5_1': 2, 'whisper-base-q5_1': 0.3 })const { c } = setup({ getHardware: async () => cpuPc, speed: s.deps })diff --git a/app/test/speedCheck.test.ts b/app/test/speedCheck.test.tsindex 71a52360..52952635 100644--- a/app/test/speedCheck.test.ts+++ b/app/test/speedCheck.test.ts@@ -73,8 +73,14 @@ describe('the speed check (Windows and Linux)', () => {expect(s.stopped()).toBe(true)})- it('a reading that takes longer than the clip is stopped: too slow by far', async () => {- const s = await standIn(1500)+ // #107: up to twice the clip is still timed, for a model that reads recordings after the meeting+ it('a reading that takes up to twice the clip is timed; longer is stopped: too slow by far', async () => {+ const slow = await standIn(1500)+ const timed = await measureSpeed('/m/ggml-small-q5_1.bin', { binary: 'x', clip: clip(1), server: () => slow.srv })+ expect(timed.rtf).toBeGreaterThan(1.4)+ expect(timed.rtf).toBeLessThan(2)+ close?.()+ const s = await standIn(2500)const r = await measureSpeed('/m/ggml-small-q5_1.bin', { binary: 'x', clip: clip(1), server: () => s.srv })expect(r.rtf).toBeNull()expect(s.stopped()).toBe(true)diff --git a/docs/README.md b/docs/README.mdindex e96ea28d..ebf5c376 100644--- a/docs/README.md+++ b/docs/README.md@@ -10,7 +10,7 @@ Download Yogurt from [GitHub Releases](https://github.com/FrigadeHQ/yogurt/relea- **Windows:** Windows 10 version 2004 or later, x64. Run the `.exe` installer. It's signed by Frigade Inc.- **Linux:** x64, Ubuntu 22.04 or a compatible newer system, with PulseAudio or PipeWire. Make the `.AppImage` executable in its file properties, then open it. If it doesn't open, install FUSE 2 first: `sudo apt install libfuse2` on Ubuntu 22.04, `sudo apt install libfuse2t64` on 24.04 and newer. GNOME needs the AppIndicator extension to show the tray icon.-On first run, Yogurt downloads the models it needs. Windows and Linux also check transcription speed; a computer that can't transcribe live still records, and its meetings are transcribed right after they end. Recording works as soon as setup finishes. The notes model keeps downloading in the background, and notes and questions work offline once it's in. Calendar access and speaker names from calls are available on Mac only.+On first run, Yogurt downloads the models it needs. Windows and Linux also check transcription speed; a computer that can't transcribe live still records, and its meetings are transcribed right after they end. Where only a small speech model keeps up live, meetings in other languages (Multi-language) are transcribed right after they end with a better one. Recording works as soon as setup finishes. The notes model keeps downloading in the background, and notes and questions work offline once it's in. Calendar access and speaker names from calls are available on Mac only.## Mac permissionsdiff --git a/packages/picker/src/asr.ts b/packages/picker/src/asr.tsindex 72c0da98..a0d6451f 100644--- a/packages/picker/src/asr.ts+++ b/packages/picker/src/asr.ts@@ -29,7 +29,12 @@ export const KEEPS_UP_RTF = 0.5*/export const LAGS_A_LITTLE_RTF = 1.25/** part of the speed check's key: a change to how it picks measures every computer again, once */-export const SPEED_CHECK_VERSION = 'v2'+export const SPEED_CHECK_VERSION = 'v3'+/**+ * A model that reads the clip within twice its length is good enough to transcribe a meeting from its recording after+ * it ends (#107: small on a slow processor, for languages base and tiny read poorly). The speed check times up to this.+ */+export const AFTER_MEETING_RTF = 2/*** Windows and Linux: the speech models the speed check tries, best first (a Mac has none: it never measures). On the@@ -51,31 +56,40 @@ export function asrCandidates(hw: Hardware, c: Catalog, opts: { exclude?: string* None keeps up: there is still a model, never none (a computer that once got "too slow" could not record at all). It* is read after the meeting instead of live (afterMeeting): the best one that read the clip within its own length,* else the fastest, else the smallest. A meeting is recorded either way and its transcript follows.+ *+ * weak: models poor outside English (base, tiny). When one is kept, the best model before it that read the clip within+ * AFTER_MEETING_RTF is named too (multi): meetings in other languages are read with it after they end (#107).*/-export async function pickBySpeed<M extends { id: string }>(candidates: M[], measure: (m: M, onCpu?: boolean) => Promise<number | null>, opts: { lagsOk?: (m: M) => boolean; cpuToo?: (m: M) => boolean } = {}): Promise<{ model: M | null; rtf: Record<string, number | null>; cpuRtf?: Record<string, number | null>; cpu?: true; afterMeeting?: true }> {+export async function pickBySpeed<M extends { id: string }>(candidates: M[], measure: (m: M, onCpu?: boolean) => Promise<number | null>, opts: { lagsOk?: (m: M) => boolean; cpuToo?: (m: M) => boolean; weak?: (m: M) => boolean } = {}): Promise<{ model: M | null; rtf: Record<string, number | null>; cpuRtf?: Record<string, number | null>; cpu?: true; afterMeeting?: true; multi?: { model: M; cpu?: true } }> {const rtf: Record<string, number | null> = {}const cpuRtf: Record<string, number | null> = {}const withCpu = () => (Object.keys(cpuRtf).length ? { cpuRtf } : {})const keepsUp = (m: M, r: number | null) => r !== null && r <= (opts.lagsOk?.(m) ? LAGS_A_LITTLE_RTF : KEEPS_UP_RTF)+ const best = (m: M) => {+ const g = rtf[m.id] ?? Infinity, c = cpuRtf[m.id] ?? Infinity+ return { m, t: Math.min(g, c), cpu: c < g }+ }+ /** for a weak model kept: the best one before it that can read a recording after the meeting */+ const multiFor = (kept: M) => {+ if (!opts.weak?.(kept)) return {}+ const b = candidates.slice(0, candidates.indexOf(kept)).map(best).find((x) => x.t <= AFTER_MEETING_RTF)+ return b ? { multi: { model: b.m, ...(b.cpu ? { cpu: true as const } : {}) } } : {}+ }for (const m of candidates) {const r = await measure(m)rtf[m.id] = r- if (keepsUp(m, r)) return { model: m, rtf, ...withCpu() }+ if (keepsUp(m, r)) return { model: m, rtf, ...withCpu(), ...multiFor(m) }if (opts.cpuToo?.(m)) {const c = await measure(m, true)cpuRtf[m.id] = c- if (keepsUp(m, c)) return { model: m, rtf, cpuRtf, cpu: true }+ if (keepsUp(m, c)) return { model: m, rtf, cpuRtf, cpu: true, ...multiFor(m) }}}- const best = (m: M) => {- const g = rtf[m.id] ?? Infinity, c = cpuRtf[m.id] ?? Infinity- return { m, t: Math.min(g, c), cpu: c < g }- }const timed = candidates.map(best)const fastest = timed.filter((x) => Number.isFinite(x.t)).sort((a, b) => a.t - b.t)[0]const chosen = timed.find((x) => x.t <= 1) ?? fastest ?? (candidates.length ? { m: candidates[candidates.length - 1], cpu: false } : undefined)if (!chosen) return { model: null, rtf }- return { model: chosen.m, rtf, ...withCpu(), ...(chosen.cpu ? { cpu: true as const } : {}), afterMeeting: true }+ return { model: chosen.m, rtf, ...withCpu(), ...(chosen.cpu ? { cpu: true as const } : {}), afterMeeting: true, ...multiFor(chosen.m) }}/** What the speed depends on: the processor and the graphics. A different one of either and the check runs again. */diff --git a/packages/picker/src/index.ts b/packages/picker/src/index.tsindex 4542c135..acccf164 100644--- a/packages/picker/src/index.ts+++ b/packages/picker/src/index.ts@@ -2,4 +2,4 @@ export * from './types'export { bandwidthGBs } from './bandwidth'export { pick, MIN_TOK_PER_SEC, LITE_AGENT_SCORE } from './pick'export { CatalogSchema, validateCatalog } from './catalog-schema'-export { asrCandidates, KEEPS_UP_RTF, LAGS_A_LITTLE_RTF, pickAsr, pickBySpeed, SPEED_CHECK_VERSION, speedKey } from './asr'+export { AFTER_MEETING_RTF, asrCandidates, KEEPS_UP_RTF, LAGS_A_LITTLE_RTF, pickAsr, pickBySpeed, SPEED_CHECK_VERSION, speedKey } from './asr'diff --git a/packages/picker/test/asr.test.ts b/packages/picker/test/asr.test.tsindex 0cfc3bc2..a9a641d3 100644--- a/packages/picker/test/asr.test.ts+++ b/packages/picker/test/asr.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from 'vitest'-import { asrCandidates, KEEPS_UP_RTF, LAGS_A_LITTLE_RTF, pickAsr, pickBySpeed, SPEED_CHECK_VERSION, speedKey } from '../src/asr'+import { AFTER_MEETING_RTF, asrCandidates, KEEPS_UP_RTF, LAGS_A_LITTLE_RTF, pickAsr, pickBySpeed, SPEED_CHECK_VERSION, speedKey } from '../src/asr'import { machines } from './fixtures'import real from '../../../catalog/catalog.json'import type { Catalog } from '../src/types'@@ -125,12 +125,37 @@ describe('pickBySpeed', () => {const r = await pickBySpeed(list, async (m, onCpu) => (m.id === 'small' ? (onCpu ? 0.7 : 0.95) : null), { cpuToo: (m) => m.id !== 'turbo', lagsOk: () => false })expect(r).toMatchObject({ model: list[1], afterMeeting: true, cpu: true })})+ // #107: base keeps up live, but small (or turbo) reads too slowly for live. Outside English base is poor, so the better+ // one is kept too, to read a meeting's recording after it ends; English keeps base live as before+ describe('the better model for other languages, read after the meeting', () => {+ const weak = (m: { id: string }) => m.id === 'base' || m.id === 'tiny'+ it('base live, small too slow for live but within twice the clip: small for other languages', async () => {+ const r = await pickBySpeed(list, timed({ turbo: null, small: 1.6, base: 0.3 }).measure, { weak, lagsOk: (m) => m.id === 'small' })+ expect(r).toEqual({ model: list[2], rtf: { turbo: null, small: 1.6, base: 0.3 }, multi: { model: list[1] } })+ expect(AFTER_MEETING_RTF).toBe(2)+ })+ it('turbo within twice the clip beats small', async () => {+ expect((await pickBySpeed(list, timed({ turbo: 1.9, small: 1.4, base: 0.3 }).measure, { weak })).multi).toEqual({ model: list[0] })+ })+ it('on the processor where that was faster for it', async () => {+ const r = await pickBySpeed(list, async (m, onCpu) => ({ turbo: null, small: onCpu ? 1.5 : null, base: 0.3 } as Record<string, number | null>)[m.id], { weak, cpuToo: (m) => m.id === 'small' })+ expect(r.multi).toEqual({ model: list[1], cpu: true })+ })+ it('none of the better ones within twice the clip, or a strong model live: no second model', async () => {+ expect((await pickBySpeed(list, timed({ turbo: null, small: 2.5, base: 0.3 }).measure, { weak })).multi).toBeUndefined()+ expect((await pickBySpeed(list, timed({ turbo: 1.5, small: 0.4 }).measure, { weak })).multi).toBeUndefined()+ })+ it('none keeps up live and base is kept for after the meeting: small instead for other languages', async () => {+ const r = await pickBySpeed(list, timed({ turbo: null, small: 1.8, base: 0.8, tiny: 0.6 }).measure, { weak })+ expect(r).toMatchObject({ model: list[2], afterMeeting: true, multi: { model: list[1] } })+ })+ })})describe('speedKey: the speed check runs again only when the computer changes', () => {it('carries the speed check version, so a change to how it picks measures again once (#107)', () => {expect(speedKey(machines.linux3060).startsWith(`${SPEED_CHECK_VERSION}|`)).toBe(true)- expect(SPEED_CHECK_VERSION).toBe('v2')+ expect(SPEED_CHECK_VERSION).toBe('v3')})it('the same computer gives the same key; other graphics or processor a new one', () => {const k = speedKey(machines.linux3060)