From 81a368ddf2ef589c2376172665590836ce64be71 Mon Sep 17 00:00:00 2001 From: dillonstreator Date: Fri, 27 Nov 2026 13:28:21 -0600 Subject: [PATCH] Add held-out speaker evals on real meetings: VoxConverse and recorded Zoom calls. - `pnpm eval:voxconverse` scores DER and speaker count on VoxConverse v0.3 test clips (CC BY 4.0, 2-8 people), with labels and audio pinned by commit and revision. - `pnpm eval:zoom` (Windows) labels recorded Zoom meetings from YouTube off the video: the tile with the green active-speaker border, its name read with Windows' own OCR, corrected for the border's lag and cut to speech. Videos stay in eval-data/. - Turn-only references show WER and cpWER as n/a; unit tests for the RTTM parser and the border, turn and name logic. --- .changeset/brown-jars-cover.md | 5 + AGENTS.md | 2 +- apps/lyra/package.json | 2 + apps/lyra/scripts/eval/ami.cjs | 2 +- apps/lyra/scripts/eval/voxconverse.cjs | 102 ++++++++ apps/lyra/scripts/eval/voxconverse.test.mjs | 43 ++++ apps/lyra/scripts/eval/zoom-ocr.ps1 | 43 ++++ apps/lyra/scripts/eval/zoom-video.cjs | 178 +++++++++++++ apps/lyra/scripts/eval/zoom.cjs | 265 ++++++++++++++++++++ apps/lyra/scripts/eval/zoom.test.mjs | 196 +++++++++++++++ apps/lyra/scripts/run-eval.cjs | 38 ++- docs/EVALS.md | 9 +- 12 files changed, 877 insertions(+), 8 deletions(-) create mode 100644 .changeset/brown-jars-cover.md create mode 100644 apps/lyra/scripts/eval/voxconverse.cjs create mode 100644 apps/lyra/scripts/eval/voxconverse.test.mjs create mode 100644 apps/lyra/scripts/eval/zoom-ocr.ps1 create mode 100644 apps/lyra/scripts/eval/zoom-video.cjs create mode 100644 apps/lyra/scripts/eval/zoom.cjs create mode 100644 apps/lyra/scripts/eval/zoom.test.mjs diff --git a/.changeset/brown-jars-cover.md b/.changeset/brown-jars-cover.md new file mode 100644 index 00000000..064435dc --- /dev/null +++ b/.changeset/brown-jars-cover.md @@ -0,0 +1,5 @@ +--- + +--- + + diff --git a/AGENTS.md b/AGENTS.md index cde823cb..c9e3a5bb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -19,7 +19,7 @@ Roadmap: [docs/PLAN.md](docs/PLAN.md). Human contributor guide: [CONTRIBUTING.md | Native addon smoke | `pnpm smoke` (only needed when touching `src/main/whisper.ts` or native deps) | | QA with real audio | `node scripts/make-demo-audio.cjs` (in `apps/lyra`; Windows SAPI or macOS `say`) makes `test-audio/meeting.wav` (two synthetic voices); see the `qa-test` skill | | Meeting pipeline smoke | `pnpm smoke:meeting [system.wav]`: replays the audio as a live recording (chunked Whisper per track, speakers labeled every half minute, relabel after stop); `--offline` runs diarize-then-transcribe instead; `--notes local` adds notes; `--no-relabel` keeps the labels given while recording; `--enroll owner.wav` saves a voice first; `LYRA_MODELS_DIR` reuses downloads | -| Speaker evals | `pnpm eval:sessions` (in `apps/lyra`): real voices (LibriSpeech, CC BY 4.0; needs ffmpeg) laid out as 2–6 person room, hybrid and call sessions with exact ground truth (Opus remote audio, speaker bleed, music or a video playing, a fan, backchannels, crosstalk); `--seeds 3` for three draws each, `--enroll` to save the owner's voice first; `pnpm eval:calls`: TTS call/room scenarios (speaker bleed, clipping, quick turns, crosstalk); `pnpm eval:ami` scores real AMI meetings (`--meetings`, `--minutes`, `--mic`). WER, cpWER, DER; data and results go to `eval-data/`. `--pipeline live` (default: what the app runs), `stream` (the lines as labeled while recording, before relabel), `offline`, or `capture` (mic-only items played as a fake microphone through the window's real capture path, in real time). Experiments: `--asr parakeet`, `--no-context` (Whisper without its prompt). `--quick` runs a fixed subset (about 2 min for calls, 4 for sessions) for direction while working; `--jobs 2` runs items in parallel. `--check` fails the run if it is worse than the stored baseline (`scripts/eval/baselines/`), `--update-baseline` stores it; `pnpm eval:local` scores your own recordings, added with `node scripts/eval/local.cjs add ` and kept out of the repo. Task runs are headless: no window opens | +| Speaker evals | `pnpm eval:sessions` (in `apps/lyra`): real voices (LibriSpeech, CC BY 4.0; needs ffmpeg) laid out as 2–6 person room, hybrid and call sessions with exact ground truth (Opus remote audio, speaker bleed, music or a video playing, a fan, backchannels, crosstalk); `--seeds 3` for three draws each, `--enroll` to save the owner's voice first; `pnpm eval:calls`: TTS call/room scenarios (speaker bleed, clipping, quick turns, crosstalk); `pnpm eval:ami` scores real AMI meetings (`--meetings`, `--minutes`, `--mic`); `pnpm eval:voxconverse` scores DER and speaker count on real VoxConverse debates and news clips, 2–8 people, that nothing was tuned on (`--files`, `--minutes`); `pnpm eval:zoom` (Windows; needs yt-dlp) scores DER on recorded Zoom meetings from YouTube, labelled from the video's active-speaker border and name tiles (`--videos`, `--minutes`). WER, cpWER, DER; data and results go to `eval-data/`. `--pipeline live` (default: what the app runs), `stream` (the lines as labeled while recording, before relabel), `offline`, or `capture` (mic-only items played as a fake microphone through the window's real capture path, in real time). Experiments: `--asr parakeet`, `--no-context` (Whisper without its prompt). `--quick` runs a fixed subset (about 2 min for calls, 4 for sessions) for direction while working; `--jobs 2` runs items in parallel. `--check` fails the run if it is worse than the stored baseline (`scripts/eval/baselines/`), `--update-baseline` stores it; `pnpm eval:local` scores your own recordings, added with `node scripts/eval/local.cjs add ` and kept out of the repo. Task runs are headless: no window opens | | Tune speaker clustering | In `apps/lyra`, with `LYRA_MODELS_DIR`: `node scripts/eval/cluster-lab.cjs` sweeps voice models, window sizes and clustering bars on the sessions in seconds, without Whisper; `node scripts/eval/voice-scores.cjs` shows how a saved voice scores against its owner and everyone else (the basis for `meeting/thresholds.ts`) | | Word lists | `pnpm word-lists` (in `apps/lyra`) regenerates `src/main/data/hallucinations.json` and `src/shared/data/whisperLanguages.json` from pinned upstream sources; never edit them by hand | | Debug a mislabeled session | `pnpm replay:session ` (in `apps/lyra`): re-runs its kept audio through each pipeline and prints who spoke each line; `--reference ref.json` scores it. A session's `raw/live.json` has each chunk's words and the track it was heard on | diff --git a/apps/lyra/package.json b/apps/lyra/package.json index 108b3595..76ddd07a 100644 --- a/apps/lyra/package.json +++ b/apps/lyra/package.json @@ -21,6 +21,8 @@ "eval:calls": "node scripts/run-eval.cjs --dataset calls", "eval:sessions": "node scripts/run-eval.cjs --dataset sessions", "eval:ami": "node scripts/run-eval.cjs --dataset ami", + "eval:voxconverse": "node scripts/run-eval.cjs --dataset voxconverse", + "eval:zoom": "node scripts/run-eval.cjs --dataset zoom", "eval:local": "node scripts/run-eval.cjs --dataset local", "replay:session": "node scripts/replay-session.cjs", "screenshot": "electron-vite build && node scripts/capture-screenshot.cjs", diff --git a/apps/lyra/scripts/eval/ami.cjs b/apps/lyra/scripts/eval/ami.cjs index 52866af3..3503a7f1 100644 --- a/apps/lyra/scripts/eval/ami.cjs +++ b/apps/lyra/scripts/eval/ami.cjs @@ -149,4 +149,4 @@ async function prepare(dataDir, meeting, { mic = MICS[0], minutes = 10 } = {}) { return { id: `${meeting}.${mic}`, wav, seconds, reference: reference(wordsDir, meeting, seconds) } } -module.exports = { DEFAULT_MEETINGS, MICS, prepare, parseWords, reference } +module.exports = { DEFAULT_MEETINGS, MICS, download, prepare, parseWords, reference } diff --git a/apps/lyra/scripts/eval/voxconverse.cjs b/apps/lyra/scripts/eval/voxconverse.cjs new file mode 100644 index 00000000..8837d8a1 --- /dev/null +++ b/apps/lyra/scripts/eval/voxconverse.cjs @@ -0,0 +1,102 @@ +// VoxConverse v0.3 (CC BY 4.0, VGG Oxford; copyright of the audio stays with the videos' +// owners): multi-speaker clips of debates, news and talk shows from YouTube, with hand-checked +// speaker turns as RTTM. https://www.robots.ox.ac.uk/~vgg/data/voxconverse/ +// +// Speaker turns only, no words: it scores DER and the speaker count, not WER or cpWER. Real +// voices Lyra was never tuned on, so it is the held-out check the sessions can't be. +// +// Labels come from the authors' repository at a pinned commit (~3 MB, once). Oxford's audio +// zips now ask for a login, so the test WAVs come one at a time (~5–15 MB each) from a CC BY +// 4.0 mirror at a pinned revision. Both go to /voxconverse/. Citation: Chung et al., +// "Spot the conversation: speaker diarisation in the wild", Interspeech 2020. + +const { spawnSync } = require('node:child_process') +const { existsSync, mkdirSync, readFileSync } = require('node:fs') +const { join } = require('node:path') +const { download } = require('./ami.cjs') +const { RATE, readWav, writeWav } = require('./wav.cjs') + +const LABELS_COMMIT = '24bf60be297701cd7e4ef18550c6d390c1b87365' +const LABELS_URL = `https://codeload.github.com/joonson/voxconverse/tar.gz/${LABELS_COMMIT}` +const AUDIO_REVISION = '7e3ea2807400b9ed79451e20513f7a50ac4fd846' +const AUDIO_URL = (file) => + `https://huggingface.co/datasets/ggfox00000/dia-voxconverse-test/resolve/${AUDIO_REVISION}/audio/test/${file}.wav` + +/** + * Test files of 4–7 minutes, one for each of 2 to 6 people and one of 8, about 31 minutes in + * all; `fyqoe` has the most overlapped speech of them (a fifth of its speech time). + */ +const DEFAULT_FILES = ['tkhgs', 'fyqoe', 'nprxc', 'rpkso', 'xvxwv', 'qadia'] +/** 2, 3 and 5 people: about 15 minutes. */ +const QUICK_FILES = ['tkhgs', 'fyqoe', 'rpkso'] + +/** Reference segments from an RTTM file's SPEAKER lines, in time order. */ +function parseRttm(text) { + const segments = [] + for (const line of text.split(/\r?\n/)) { + const fields = line.trim().split(/\s+/) + if (fields[0] !== 'SPEAKER' || fields.length < 8) continue + const start = Number(fields[3]) + const duration = Number(fields[4]) + if (!Number.isFinite(start) || !Number.isFinite(duration) || duration <= 0) continue + segments.push({ speaker: fields[7], start, end: start + duration, text: '' }) + } + return segments.sort((a, b) => a.start - b.start) +} + +/** The segments that start before `seconds`, cut at it. */ +function clip(segments, seconds) { + return segments.filter((s) => s.start < seconds).map((s) => ({ ...s, end: Math.min(s.end, seconds) })) +} + +/** One fetch of the labels per run, however many files are prepared at once (`--jobs`). */ +let labels = null +function ensureLabels(dir) { + labels ??= fetchLabels(dir).catch((error) => { + labels = null + throw error + }) + return labels +} + +async function fetchLabels(dir) { + const root = join(dir, `voxconverse-${LABELS_COMMIT}`) + if (existsSync(join(root, 'test'))) return root + const archive = join(dir, `labels-${LABELS_COMMIT}.tar.gz`) + await download(LABELS_URL, archive) + // GNU tar and bsdtar (Windows 10+, macOS) both read gzip. + const tar = process.platform === 'win32' ? join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'tar.exe') : 'tar' + const result = spawnSync(tar, ['-xzf', archive, '-C', dir], { stdio: 'inherit' }) + if (result.status !== 0 || !existsSync(join(root, 'test'))) throw new Error(`could not extract ${archive}`) + return root +} + +/** + * Prepares one VoxConverse test file: the WAV to feed Lyra and its reference turns. + * `minutes` = 0 (the default) keeps the whole file. + */ +async function prepare(dataDir, file, { minutes = 0 } = {}) { + if (!/^[a-z]{5}$/.test(file)) throw new Error(`not a VoxConverse file id: ${file}`) + const dir = join(dataDir, 'voxconverse') + mkdirSync(join(dir, 'audio'), { recursive: true }) + const rttm = join(await ensureLabels(dir), 'test', `${file}.rttm`) + if (!existsSync(rttm)) throw new Error(`${file} is not in the VoxConverse test split`) + const full = join(dir, 'audio', `${file}.wav`) + await download(AUDIO_URL(file), full) + let wav = full + let samples = readWav(full) + if (minutes > 0 && samples.length > minutes * 60 * RATE) { + samples = samples.subarray(0, minutes * 60 * RATE) + wav = join(dir, 'audio', `${file}.${minutes}m.wav`) + writeWav(wav, samples) + } + const seconds = samples.length / RATE + return { + id: `vox-${file}`, + wav, + seconds, + reference: { segments: clip(parseRttm(readFileSync(rttm, 'utf8')), seconds) } + } +} + +module.exports = { DEFAULT_FILES, QUICK_FILES, prepare, parseRttm, clip } diff --git a/apps/lyra/scripts/eval/voxconverse.test.mjs b/apps/lyra/scripts/eval/voxconverse.test.mjs new file mode 100644 index 00000000..b1c5947d --- /dev/null +++ b/apps/lyra/scripts/eval/voxconverse.test.mjs @@ -0,0 +1,43 @@ +import { createRequire } from 'node:module' +import { describe, expect, it } from 'vitest' + +const require = createRequire(import.meta.url) +const { parseRttm, clip } = require('./voxconverse.cjs') + +describe('parseRttm', () => { + it('reads SPEAKER lines as turns in time order, start plus duration as the end', () => { + const text = [ + 'SPEAKER aepyx 1 6.20000 5.34000 spk01 ', + 'SPEAKER aepyx 1 2.50000 3.66000 spk00 ' + ].join('\r\n') + expect(parseRttm(text)).toEqual([ + { speaker: 'spk00', start: 2.5, end: 6.16, text: '' }, + { speaker: 'spk01', start: 6.2, end: 11.54, text: '' } + ]) + }) + + it('skips other record types, blank lines and empty or malformed turns', () => { + const text = [ + 'SPKR-INFO aepyx 1 unknown spk00 ', + '', + 'SPEAKER aepyx 1 1.0 0 spk00 ', + 'SPEAKER aepyx 1 x 2.0 spk00 ', + 'SPEAKER aepyx 1 3.0 1.0 spk02 ' + ].join('\n') + expect(parseRttm(text)).toEqual([{ speaker: 'spk02', start: 3, end: 4, text: '' }]) + }) +}) + +describe('clip', () => { + it('drops turns from the cut on and shortens the one across it', () => { + const turns = [ + { speaker: 'a', start: 0, end: 5, text: '' }, + { speaker: 'b', start: 8, end: 12, text: '' }, + { speaker: 'a', start: 10, end: 11, text: '' } + ] + expect(clip(turns, 10)).toEqual([ + { speaker: 'a', start: 0, end: 5, text: '' }, + { speaker: 'b', start: 8, end: 10, text: '' } + ]) + }) +}) diff --git a/apps/lyra/scripts/eval/zoom-ocr.ps1 b/apps/lyra/scripts/eval/zoom-ocr.ps1 new file mode 100644 index 00000000..c7536da2 --- /dev/null +++ b/apps/lyra/scripts/eval/zoom-ocr.ps1 @@ -0,0 +1,43 @@ +# Reads the text in each image with the OCR engine built into Windows (Windows.Media.Ocr), so the +# Zoom eval (zoom-video.cjs) needs nothing installed. Windows PowerShell 5.1 only: PowerShell 7 +# can't load WinRT types. +# +# powershell -NoProfile -ExecutionPolicy Bypass -File zoom-ocr.ps1 a.png b.png ... +# +# Prints one JSON object per line: {"path": "...", "text": "..."}. +param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Paths) +$ErrorActionPreference = 'Stop' +[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + +Add-Type -AssemblyName System.Runtime.WindowsRuntime +$null = [Windows.Storage.StorageFile, Windows.Storage, ContentType = WindowsRuntime] +$null = [Windows.Media.Ocr.OcrEngine, Windows.Foundation, ContentType = WindowsRuntime] +$null = [Windows.Graphics.Imaging.BitmapDecoder, Windows.Foundation, ContentType = WindowsRuntime] + +# WinRT calls are async; this waits on one through the .NET bridge. +$asTask = [System.WindowsRuntimeSystemExtensions].GetMethods() | Where-Object { + $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' +} | Select-Object -First 1 +function Wait-Async($operation, [Type]$type) { + $task = $asTask.MakeGenericMethod($type).Invoke($null, @($operation)) + $task.Wait() | Out-Null + $task.Result +} + +$engine = [Windows.Media.Ocr.OcrEngine]::TryCreateFromUserProfileLanguages() +if ($null -eq $engine) { throw 'no OCR language installed (Settings > Time & language > Language)' } + +foreach ($path in $Paths) { + $file = Wait-Async ([Windows.Storage.StorageFile]::GetFileFromPathAsync((Resolve-Path $path).Path)) ([Windows.Storage.StorageFile]) + $stream = Wait-Async ($file.OpenAsync([Windows.Storage.FileAccessMode]::Read)) ([Windows.Storage.Streams.IRandomAccessStream]) + try { + $decoder = Wait-Async ([Windows.Graphics.Imaging.BitmapDecoder]::CreateAsync($stream)) ([Windows.Graphics.Imaging.BitmapDecoder]) + $bitmap = Wait-Async ($decoder.GetSoftwareBitmapAsync()) ([Windows.Graphics.Imaging.SoftwareBitmap]) + $result = Wait-Async ($engine.RecognizeAsync($bitmap)) ([Windows.Media.Ocr.OcrResult]) + # ConvertTo-Json in 5.1 leaves control characters unescaped, which breaks the JSON. + $text = (($result.Lines | ForEach-Object { $_.Text }) -join ' ') -replace '\p{Cc}', ' ' + } finally { + $stream.Dispose() + } + [Console]::Out.WriteLine((@{ path = $path; text = $text } | ConvertTo-Json -Compress)) +} diff --git a/apps/lyra/scripts/eval/zoom-video.cjs b/apps/lyra/scripts/eval/zoom-video.cjs new file mode 100644 index 00000000..c971df3b --- /dev/null +++ b/apps/lyra/scripts/eval/zoom-video.cjs @@ -0,0 +1,178 @@ +// Recorded Zoom meetings from YouTube as an eval: the audio, and speaker turns read off the +// video's active-speaker border and name tiles (how, and what that can't see: zoom.cjs). +// +// Defaults are GitLab's public "Key Meeting" streams (GitLab Unfiltered) in Zoom gallery view, +// each tile named. Speaker view (one person full screen) isn't read yet. The videos are under YouTube's standard license, so they're +// downloaded to /zoom// for this machine only and never go in the repo; nor do +// the names read off them. Needs yt-dlp and ffmpeg on the PATH; names are read with the OCR +// built into Windows (zoom-ocr.ps1), so it runs on Windows only for now. + +const { spawn, spawnSync } = require('node:child_process') +const { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, writeFileSync } = require('node:fs') +const { join } = require('node:path') +const { RATE, readWav, writeWav } = require('./wav.cjs') +const zoom = require('./zoom.cjs') + +/** + * GitLab Key Meetings that stay in gallery view (most of the series is recorded in speaker + * view, which has no border to read): videos of 24, 21, 22 and 18 minutes. + */ +const DEFAULT_VIDEOS = ['qGFoZ8yodc4', 'FR6HO6o7PB0', 'JS1RRdfGUos', 'HurwHyh0yLc'] +const QUICK_VIDEOS = ['qGFoZ8yodc4'] + +/** Frames are read at this size and rate: enough for the border, a quarter-second of timing. */ +const WIDTH = 854 +const HEIGHT = 480 +const FPS = 4 +/** Bump when the labelling changes, so cached references are made again. */ +const VERSION = 1 + +function run(command, args) { + const result = spawnSync(command, args, { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 }) + if (result.error) throw new Error(`${command} could not start: ${result.error.message}`) + if (result.status !== 0) throw new Error(`${command} failed: ${(result.stderr || result.stdout).trim().slice(-400)}`) + return result.stdout +} + +/** The video (480p at most, video only) and audio, once. */ +function download(dir, id) { + const has = (prefix) => readdirSync(dir).find((name) => name.startsWith(prefix) && !name.endsWith('.part')) + for (const [prefix, format] of [ + ['video.', 'bv*[height<=480][ext=mp4]/bv*[height<=480]'], + ['audio.', 'ba[ext=m4a]/ba'] + ]) { + if (has(prefix)) continue + process.stdout.write(`eval: downloading ${id} (${prefix.slice(0, -1)})\n`) + run('yt-dlp', ['-q', '--no-warnings', '--no-playlist', '-f', format, '-o', join(dir, `${prefix}%(ext)s`), `https://www.youtube.com/watch?v=${id}`]) + } + return { video: join(dir, has('video.')), audio: join(dir, has('audio.')) } +} + +/** The highlighted box in every frame, streamed from ffmpeg (a 20-minute video is ~30 s). */ +function scanFrames(video) { + const size = WIDTH * HEIGHT * 3 + const ffmpeg = spawn('ffmpeg', ['-v', 'error', '-i', video, '-vf', `fps=${FPS},scale=${WIDTH}:${HEIGHT}`, '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-']) + const boxes = [] + let pending = Buffer.alloc(0) + ffmpeg.stdout.on('data', (data) => { + pending = Buffer.concat([pending, data]) + while (pending.length >= size) { + boxes.push(zoom.findHighlight(pending.subarray(0, size), WIDTH, HEIGHT)) + pending = pending.subarray(size) + } + }) + return new Promise((resolve, reject) => { + ffmpeg.on('error', reject) + ffmpeg.on('close', (status) => (status === 0 ? resolve(boxes) : reject(new Error(`ffmpeg exit ${status} reading ${video}`)))) + }) +} + +/** The name strip along the bottom of a tile: about a fifth of its height, three quarters of its width. */ +function nameStrip(box) { + const height = Math.max(12, Math.round((box.y1 - box.y0) * 0.19)) + return { x: box.x0 + 2, y: box.y1 - height - 1, w: Math.round((box.x1 - box.x0) * 0.75), h: height } +} + +/** Crops each run's name strip at up to three moments and reads them; returns texts per run. */ +function readNames(dir, video, runs) { + const crops = join(dir, 'names') + mkdirSync(crops, { recursive: true }) + const jobs = [] + runs.forEach((highlight, index) => { + if (!highlight.box) return + const length = highlight.end - highlight.start + const moments = length > 6 ? [0.25, 0.5, 0.75] : [0.5] + moments.forEach((at, k) => { + const path = join(crops, `${index}-${k}.png`) + const { x, y, w, h } = nameStrip(highlight.box) + // Scaled up 4x: Windows' OCR misses text this small at its own size. + const filter = `scale=${WIDTH}:${HEIGHT},crop=${w}:${h}:${x}:${y},scale=iw*4:ih*4:flags=lanczos` + const time = (highlight.start + length * at).toFixed(2) + if (!existsSync(path)) run('ffmpeg', ['-v', 'error', '-y', '-ss', time, '-i', video, '-frames:v', '1', '-vf', filter, path]) + jobs.push({ index, path }) + }) + }) + const texts = new Map(jobs.map(({ path }) => [path, ''])) + const script = join(__dirname, 'zoom-ocr.ps1') + // A few dozen paths per call keeps the command line short of Windows' limit. + for (let at = 0; at < jobs.length; at += 40) { + const out = run('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', script, ...jobs.slice(at, at + 40).map((j) => j.path)]) + for (const line of out.split(/\r?\n/).filter(Boolean)) { + const { path, text } = JSON.parse(line) + texts.set(path, text) + } + } + const byRun = new Map() + for (const { index, path } of jobs) byRun.set(index, [...(byRun.get(index) ?? []), texts.get(path)]) + return byRun +} + +/** The audio as 16 kHz mono, once. */ +function audioWav(dir, audio) { + const wav = join(dir, 'audio.wav') + if (!existsSync(wav)) { + run('ffmpeg', ['-v', 'error', '-y', '-i', audio, '-ac', '1', '-ar', String(RATE), '-c:a', 'pcm_s16le', `${wav}.tmp.wav`]) + renameSync(`${wav}.tmp.wav`, wav) + } + return wav +} + +/** Makes (or reuses) one video's audio and reference. `minutes` = 0 keeps all of it. */ +async function prepare(dataDir, id, { minutes = 0 } = {}) { + if (process.platform !== 'win32') throw new Error('the Zoom eval reads names with Windows OCR; run it on Windows') + if (!/^[\w-]{11}$/.test(id)) throw new Error(`not a YouTube video id: ${id}`) + const dir = join(dataDir, 'zoom', id) + mkdirSync(dir, { recursive: true }) + const labelsPath = join(dir, 'labels.json') + let labels = existsSync(labelsPath) ? JSON.parse(readFileSync(labelsPath, 'utf8')) : null + if (!labels || labels.version !== VERSION) { + const { video, audio } = download(dir, id) + const wav = audioWav(dir, audio) + process.stdout.write(`eval: reading who is highlighted in ${id}\n`) + const runs = zoom.highlightRuns(await scanFrames(video), FPS) + const texts = readNames(dir, video, runs) + const cleaned = new Map([...texts].map(([index, list]) => [index, list.map(zoom.cleanName).filter(Boolean)])) + const canonical = zoom.canonicalNames([...cleaned.values()].flat()) + const names = {} + for (const [index, list] of cleaned) { + // The name most of a run's readings agree on. + const votes = new Map() + for (const name of list.map((n) => canonical.get(n))) votes.set(name, (votes.get(name) ?? 0) + 1) + const top = [...votes].sort((a, b) => b[1] - a[1])[0] + if (top) names[index] = top[0] + } + const samples = readWav(wav) + const speech = zoom.speechRegions(samples, RATE) + const lag = zoom.estimateLag(runs, speech) + const spans = zoom.scoredSpans(runs) + labels = { version: VERSION, id, fps: FPS, lag, spans, runs, names, ocr: Object.fromEntries(texts) } + writeFileSync(labelsPath, JSON.stringify(labels, null, 1)) + } + const wavAll = join(dir, 'audio.wav') + const samples = readWav(wavAll) + const speech = zoom.speechRegions(samples, RATE) + const all = zoom.turns(labels.runs.map((run, index) => ({ ...run, index })), speech, (run) => labels.names[run.index] ?? null, labels.lag.lag) + let spans = labels.spans.map((s) => ({ start: Math.max(0, s.start - labels.lag.lag), end: Math.min(samples.length / RATE, s.end - labels.lag.lag) })) + if (minutes > 0) { + // The first `minutes` of kept audio. + let left = minutes * 60 + spans = spans.flatMap((s) => { + if (left <= 0) return [] + const end = Math.min(s.end, s.start + left) + left -= end - s.start + return [{ start: s.start, end }] + }) + } + const pieces = spans.map((s) => samples.subarray(Math.round(s.start * RATE), Math.round(s.end * RATE))) + const kept = new Float32Array(pieces.reduce((n, p) => n + p.length, 0)) + let offset = 0 + for (const piece of pieces) { + kept.set(piece, offset) + offset += piece.length + } + const wav = join(dir, `kept${minutes > 0 ? `.${minutes}m` : ''}.wav`) + writeWav(wav, kept) + return { id: `zoom-${id}`, wav, seconds: kept.length / RATE, reference: { segments: zoom.onKeptTimeline(all, spans) } } +} + +module.exports = { DEFAULT_VIDEOS, QUICK_VIDEOS, prepare, nameStrip } diff --git a/apps/lyra/scripts/eval/zoom.cjs b/apps/lyra/scripts/eval/zoom.cjs new file mode 100644 index 00000000..73bedbdd --- /dev/null +++ b/apps/lyra/scripts/eval/zoom.cjs @@ -0,0 +1,265 @@ +// Reference speaker turns read off a recorded Zoom meeting's video: in gallery view Zoom draws a +// green border around whoever it hears, and each tile carries the person's name. Public meeting +// recordings (GitLab streams many to YouTube) become real video calls with labels, without +// anyone labelling them by hand. +// +// What this reference can't see: Zoom outlines one person at a time, so overlapped speech +// counts for one of them; the border follows Zoom's own speaker detection, which runs a little +// late (estimated per video and taken off); and it stays on the last person through a pause, +// so turns are cut to where the audio has speech. Stretches with no border (screen share, +// speaker view) are left out of the audio and the reference both. Good for DER at the usual +// collar, not for sub-second boundaries. +// +// Pure functions here; `zoom-video.cjs` downloads, decodes and reads names. + +const { editDistance } = require('./metrics.cjs') + +/** + * Zoom's active-speaker border: a saturated green, about rgb(100, 244, 0), darker at the edges + * of a thin border once the video is compressed (rgb(38, 163, 0) on small tiles). + */ +function isBorderGreen(r, g, b) { + return g > 140 && g - r > 70 && g - b > 100 +} + +/** A border edge is at least this long, in pixels; smaller tiles than this are not read. */ +const MIN_EDGE = 40 + +/** + * The highlighted tile in one RGB24 frame, as its border's outer box, or null. Looks for two + * long green rows with the same ends and checks the sides between them, so a green shirt or + * background on screen isn't taken for the border. + */ +function findHighlight(frame, width, height) { + const green = (x, y) => { + const i = (y * width + x) * 3 + return isBorderGreen(frame[i], frame[i + 1], frame[i + 2]) + } + /** Each row's longest green run, bridging gaps of up to two pixels (compression). */ + const runs = [] + for (let y = 0; y < height; y++) { + let best = null + let start = -1 + let lastGreen = -1 + for (let x = 0; x <= width; x++) { + if (x < width && green(x, y)) { + if (start < 0 || x - lastGreen > 3) start = x + lastGreen = x + } else if (start >= 0 && (x === width || x - lastGreen > 3)) { + if (!best || lastGreen - start > best.x1 - best.x0) best = { x0: start, x1: lastGreen } + start = -1 + } + } + runs.push(best && best.x1 - best.x0 + 1 >= MIN_EDGE ? best : null) + } + const near = (a, b) => Math.abs(a - b) <= 4 + for (let top = 0; top < height; top++) { + const edge = runs[top] + if (!edge) continue + let bottom = -1 + for (let y = height - 1; y >= top + MIN_EDGE; y--) { + const run = runs[y] + if (run && near(run.x0, edge.x0) && near(run.x1, edge.x1)) { + bottom = y + break + } + } + if (bottom < 0) continue + /** The share of rows with green within two pixels inside the edge at `x`. */ + const side = (x, inward) => { + let count = 0 + for (let y = top; y <= bottom; y++) if ([0, 1, 2].some((d) => green(x + d * inward, y))) count++ + return count / (bottom - top + 1) + } + if (side(edge.x0, 1) > 0.8 && side(edge.x1, -1) > 0.8) return { x0: edge.x0, y0: top, x1: edge.x1, y1: bottom } + } + return null +} + +const sameBox = (a, b) => + a === b || (a !== null && b !== null && ['x0', 'y0', 'x1', 'y1'].every((k) => Math.abs(a[k] - b[k]) <= 3)) + +/** + * Runs of frames with the same highlighted box: [{ start, end, box }] in seconds, where `box` + * is null while nothing is highlighted. A box seen for a single frame is taken as the frame + * before it (a fade between tiles). + */ +function highlightRuns(boxes, fps) { + const runs = [] + for (let i = 0; i < boxes.length; i++) { + let box = boxes[i] + if (i > 0 && i + 1 < boxes.length && !sameBox(box, boxes[i - 1]) && !sameBox(box, boxes[i + 1])) box = boxes[i - 1] + const last = runs[runs.length - 1] + if (last && sameBox(last.box, box)) last.end = (i + 1) / fps + else runs.push({ start: i / fps, end: (i + 1) / fps, box }) + } + return runs +} + +/** + * Where the audio has speech: 30 ms frames louder than the quiet floor (its 10th percentile) + * by `margin` dB, joined across gaps shorter than `bridge` seconds, dropping blips shorter + * than `shortest`. Rough on purpose: it only trims the border's hold through pauses. + */ +function speechRegions(samples, rate, { margin = 12, bridge = 0.3, shortest = 0.2 } = {}) { + const hop = Math.round(rate * 0.03) + const levels = [] + for (let at = 0; at + hop <= samples.length; at += hop) { + let sum = 0 + for (let i = at; i < at + hop; i++) sum += samples[i] * samples[i] + levels.push(10 * Math.log10(sum / hop + 1e-10)) + } + if (levels.length === 0) return [] + const floor = levels.slice().sort((a, b) => a - b)[Math.floor(levels.length * 0.1)] + const regions = [] + levels.forEach((level, index) => { + if (level < floor + margin) return + const start = (index * hop) / rate + const end = ((index + 1) * hop) / rate + const last = regions[regions.length - 1] + if (last && start - last.end < bridge) last.end = end + else regions.push({ start, end }) + }) + return regions.filter((r) => r.end - r.start >= shortest) +} + +/** + * How late the border is, in seconds: the shift that puts the most changes of highlighted tile + * within `window` of the start of a speech region, and of those, the one that puts them + * closest. Searched over 0 to `most`. + */ +function estimateLag(runs, speech, { most = 2, step = 0.05, window = 0.25 } = {}) { + const changes = [] + for (let i = 1; i < runs.length; i++) if (runs[i].box && runs[i - 1].box) changes.push(runs[i].start) + const onsets = speech.map((r) => r.start) + let best = { lag: 0, hits: -1, distance: Infinity } + for (let lag = 0; lag <= most + 1e-9; lag += step) { + let hits = 0 + let distance = 0 + for (const change of changes) { + const nearest = Math.min(...onsets.map((onset) => Math.abs(change - lag - onset))) + if (nearest <= window) { + hits++ + distance += nearest + } + } + if (hits > best.hits || (hits === best.hits && distance < best.distance - 1e-9)) best = { lag: +lag.toFixed(2), hits, distance } + } + return { lag: best.lag, changes: changes.length, matched: Math.max(0, best.hits) } +} + +/** + * Reference turns: each run's speaker (`nameOf(run)`, null when unknown), moved earlier by + * `lag`, cut to the speech regions. Runs with no box or no name are not scored. + */ +function turns(runs, speech, nameOf, lag) { + const out = [] + for (const run of runs) { + const speaker = run.box ? nameOf(run) : null + if (!speaker) continue + const start = Math.max(0, run.start - lag) + const end = Math.max(0, run.end - lag) + for (const region of speech) { + const from = Math.max(start, region.start) + const to = Math.min(end, region.end) + if (to - from > 0.05) out.push({ speaker, start: from, end: to, text: '' }) + } + } + return out.sort((a, b) => a.start - b.start) +} + +/** + * The stretches to keep: spans of runs with a highlight, ignoring gaps of no highlight shorter + * than `gap` seconds (a tile fading or the layout reflowing), at least `shortest` long. + */ +function scoredSpans(runs, { gap = 3, shortest = 30 } = {}) { + const spans = [] + for (const run of runs) { + if (!run.box) continue + const last = spans[spans.length - 1] + if (last && run.start - last.end <= gap) last.end = run.end + else spans.push({ start: run.start, end: run.end }) + } + return spans.filter((s) => s.end - s.start >= shortest) +} + +/** Moves turns inside `spans` onto a timeline where only the spans are kept, back to back. */ +function onKeptTimeline(segments, spans) { + const out = [] + let offset = 0 + for (const span of spans) { + for (const s of segments) { + const from = Math.max(s.start, span.start) + const to = Math.min(s.end, span.end) + if (to > from) out.push({ ...s, start: +(from - span.start + offset).toFixed(3), end: +(to - span.start + offset).toFixed(3) }) + } + offset += span.end - span.start + } + return out.sort((a, b) => a.start - b.start) +} + +/** + * A tile's name as OCR read it, cleaned: the part before the title Zoom shows after it ("Ada + * Lovelace - CTO"; OCR reads the dash as any of these marks) or the "..." of a cut-off name. + */ +function cleanName(text) { + const name = text + .replace(/^[^A-Za-z]+|^I\s+(?=[A-Z])/g, '') + .split(/\s*[-–—•|:;,·¯]+\s|\s[-–—•|:;,·¯]+|[-–—•|:;,·¯]|\.{2,}|…/)[0] + .replace(/[^A-Za-z]+$/, '') + .replace(/\s+/g, ' ') + .trim() + return name.length >= 2 ? name : null +} + +/** + * One spelling per person: names read a few characters apart (OCR on small tiles) or cut short + * on a narrower tile ("Christopher Le", "Christo") are the same person, under the longest + * spelling read at least twice (or the longest, when none was). + */ +function canonicalNames(readings) { + const counts = new Map() + for (const name of readings) counts.set(name, (counts.get(name) ?? 0) + 1) + const key = (name) => name.toLowerCase().replace(/[^a-z]/g, '') + const words = (name) => name.toLowerCase().split(/[^a-z]+/).filter(Boolean) + const same = (nameA, nameB) => { + const [a, b] = [key(nameA), key(nameB)] + const [short, long] = a.length <= b.length ? [a, b] : [b, a] + if (short.length >= 3 && long.startsWith(short)) return true + if (editDistance(a, b) <= Math.max(1, Math.floor(short.length * 0.25))) return true + // A cut-off name with a misread letter: compare it with as much of the longer one. + if (short.length >= 6 && editDistance(short, long.slice(0, short.length)) <= 1) return true + // A short first name misread ("Lily Mai" as "uy Mai"): the same last name, a close first. + const [wa, wb] = [words(nameA), words(nameB)] + return ( + wa.length >= 2 && wb.length >= 2 && wa.at(-1).length >= 3 && wa.at(-1) === wb.at(-1) && editDistance(wa[0], wb[0]) <= 2 + ) + } + /** Longest first, so cut-off names find the full one. */ + const people = [] + for (const [name] of [...counts].sort((a, b) => key(b[0]).length - key(a[0]).length || b[1] - a[1])) { + const match = people.find((p) => p.spellings.some((s) => same(s, name))) + if (match) match.spellings.push(name) + else people.push({ spellings: [name] }) + } + const canonical = new Map() + for (const { spellings } of people) { + const often = spellings.filter((s) => counts.get(s) >= 2) + const pick = (often.length > 0 ? often : spellings).reduce((a, b) => (key(b).length > key(a).length ? b : a)) + for (const spelling of spellings) canonical.set(spelling, pick) + } + return canonical +} + +module.exports = { + isBorderGreen, + findHighlight, + highlightRuns, + speechRegions, + estimateLag, + turns, + scoredSpans, + onKeptTimeline, + cleanName, + canonicalNames +} diff --git a/apps/lyra/scripts/eval/zoom.test.mjs b/apps/lyra/scripts/eval/zoom.test.mjs new file mode 100644 index 00000000..c07041db --- /dev/null +++ b/apps/lyra/scripts/eval/zoom.test.mjs @@ -0,0 +1,196 @@ +import { createRequire } from 'node:module' +import { describe, expect, it } from 'vitest' + +const require = createRequire(import.meta.url) +const z = require('./zoom.cjs') + +/** A grey frame with a green rectangle outline `thickness` pixels wide. */ +function frame(width, height, box, { thickness = 2, color = [100, 244, 0] } = {}) { + const data = Buffer.alloc(width * height * 3, 90) + const paint = (x, y) => data.set(color, (y * width + x) * 3) + for (let y = box.y0; y <= box.y1; y++) { + for (let x = box.x0; x <= box.x1; x++) { + const edge = x - box.x0 < thickness || box.x1 - x < thickness || y - box.y0 < thickness || box.y1 - y < thickness + if (edge) paint(x, y) + } + } + return data +} + +describe('findHighlight', () => { + it('finds the outline of the highlighted tile', () => { + const box = { x0: 20, y0: 10, x1: 120, y1: 70 } + expect(z.findHighlight(frame(160, 90, box), 160, 90)).toEqual(box) + }) + + it('finds the darker, thinner border of a small tile', () => { + const box = { x0: 30, y0: 20, x1: 80, y1: 65 } + expect(z.findHighlight(frame(160, 90, box, { thickness: 1, color: [38, 163, 0] }), 160, 90)).toEqual(box) + }) + + it('ignores a filled green area: no sides between the two rows', () => { + const data = Buffer.alloc(160 * 90 * 3, 90) + for (let y = 10; y < 70; y++) for (let x = 20; x < 120; x++) if (y === 10 || y === 69) data.set([100, 244, 0], (y * 160 + x) * 3) + expect(z.findHighlight(data, 160, 90)).toBeNull() + }) + + it('returns null on a frame with no green', () => { + expect(z.findHighlight(Buffer.alloc(160 * 90 * 3, 90), 160, 90)).toBeNull() + }) +}) + +describe('highlightRuns', () => { + const a = { x0: 0, y0: 0, x1: 50, y1: 50 } + const b = { x0: 60, y0: 0, x1: 110, y1: 50 } + + it('joins frames with the same box, boxes a pixel or two apart included', () => { + const a2 = { ...a, x1: 52 } + expect(z.highlightRuns([a, a2, b, b], 4)).toEqual([ + { start: 0, end: 0.5, box: a }, + { start: 0.5, end: 1, box: b } + ]) + }) + + it('takes a box seen for one frame as the one before it', () => { + expect(z.highlightRuns([a, a, b, a, a], 4)).toEqual([{ start: 0, end: 1.25, box: a }]) + }) + + it('keeps stretches with no highlight as their own runs', () => { + expect(z.highlightRuns([a, a, null, null, b, b], 2)).toEqual([ + { start: 0, end: 1, box: a }, + { start: 1, end: 2, box: null }, + { start: 2, end: 3, box: b } + ]) + }) +}) + +describe('speechRegions', () => { + it('finds the loud part of quiet audio', () => { + const rate = 1000 + const samples = new Float32Array(3 * rate).fill(0.001) + for (let i = rate; i < 2 * rate; i++) samples[i] = i % 2 ? 0.5 : -0.5 + const regions = z.speechRegions(samples, rate) + expect(regions).toHaveLength(1) + // 30-sample hops: the hops across 1 s and 2 s are a third and two thirds loud, loud enough. + expect(regions[0].start).toBeCloseTo(0.99, 5) + expect(regions[0].end).toBeCloseTo(2.01, 5) + }) +}) + +describe('estimateLag', () => { + it('finds how late the border moves after speech starts', () => { + const box = { x0: 0, y0: 0, x1: 50, y1: 50 } + const other = { x0: 60, y0: 0, x1: 110, y1: 50 } + const runs = [ + { start: 0, end: 5.5, box }, + { start: 5.5, end: 10.5, box: other }, + { start: 10.5, end: 20, box } + ] + const speech = [ + { start: 0, end: 4 }, + { start: 5, end: 9 }, + { start: 10, end: 18 } + ] + expect(z.estimateLag(runs, speech)).toEqual({ lag: 0.5, changes: 2, matched: 2 }) + }) +}) + +describe('turns', () => { + it('moves runs earlier by the lag, cuts them to speech, and skips unnamed or empty runs', () => { + const box = { x0: 0, y0: 0, x1: 1, y1: 1 } + const runs = [ + { start: 1, end: 6, box, name: 'Ada' }, + { start: 6, end: 8, box: null }, + { start: 8, end: 12, box, name: null }, + { start: 12, end: 16, box, name: 'Grace' } + ] + const speech = [ + { start: 0, end: 3 }, + { start: 4, end: 14 } + ] + expect(z.turns(runs, speech, (run) => run.name, 1)).toEqual([ + { speaker: 'Ada', start: 0, end: 3, text: '' }, + { speaker: 'Ada', start: 4, end: 5, text: '' }, + { speaker: 'Grace', start: 11, end: 14, text: '' } + ]) + }) +}) + +describe('scoredSpans and onKeptTimeline', () => { + const box = { x0: 0, y0: 0, x1: 1, y1: 1 } + + it('bridges short gaps with no highlight and drops short spans', () => { + const runs = [ + { start: 0, end: 40, box }, + { start: 40, end: 42, box: null }, + { start: 42, end: 60, box }, + { start: 60, end: 100, box: null }, + { start: 100, end: 110, box } + ] + expect(z.scoredSpans(runs)).toEqual([{ start: 0, end: 60 }]) + }) + + it('puts turns on a timeline of the kept spans back to back', () => { + const spans = [ + { start: 10, end: 20 }, + { start: 50, end: 60 } + ] + const segments = [ + { speaker: 'a', start: 5, end: 12, text: '' }, + { speaker: 'b', start: 30, end: 40, text: '' }, + { speaker: 'c', start: 55, end: 70, text: '' } + ] + expect(z.onKeptTimeline(segments, spans)).toEqual([ + { speaker: 'a', start: 0, end: 2, text: '' }, + { speaker: 'c', start: 15, end: 20, text: '' } + ]) + }) +}) + +describe('cleanName', () => { + it('keeps the name before the title, whatever mark OCR read the dash as', () => { + expect(z.cleanName('Eric Johnson - CTO')).toBe('Eric Johnson') + expect(z.cleanName('Sid Sijbrandij • CEO ...')).toBe('Sid Sijbrandij') + expect(z.cleanName('Bryan Wise: V...')).toBe('Bryan Wise') + expect(z.cleanName('Tanya Pazitny | Qua...')).toBe('Tanya Pazitny') + }) + + it('drops the "..." of a cut-off name and a stray mark before it', () => { + expect(z.cleanName('Christopher Lefelh...')).toBe('Christopher Lefelh') + expect(z.cleanName('I Mek Stittri -')).toBe('Mek Stittri') + }) + + it('returns null when nothing like a name is left', () => { + expect(z.cleanName('...')).toBeNull() + expect(z.cleanName('')).toBeNull() + }) +}) + +describe('canonicalNames', () => { + it('joins misreadings and cut-off names under the longest spelling read twice', () => { + const readings = [ + 'Christopher Lefelh', + 'Christopher Lefelh', + 'Christophey Lefelh', + 'Christopher Le', + 'Christo', + 'Christie Lennev', + 'Christie Lennev', + 'Liy Mai', + 'Liy Mai', + 'uy Mai' + ] + const names = z.canonicalNames(readings) + expect(names.get('Christophey Lefelh')).toBe('Christopher Lefelh') + expect(names.get('Christopher Le')).toBe('Christopher Lefelh') + expect(names.get('Christo')).toBe('Christopher Lefelh') + expect(names.get('Christie Lennev')).toBe('Christie Lennev') + // "Lily Mai" read as "Liy" and "uy": the same last name, first names two letters apart. + expect(names.get('uy Mai')).toBe('Liy Mai') + }) + + it('keeps different people with the same first name apart', () => { + const names = z.canonicalNames(['Steve Loyd', 'Steve Loyd', 'Steve Martin', 'Steve Martin']) + expect(new Set(names.values())).toEqual(new Set(['Steve Loyd', 'Steve Martin'])) + }) +}) diff --git a/apps/lyra/scripts/run-eval.cjs b/apps/lyra/scripts/run-eval.cjs index 26f8727d..bf8438d4 100644 --- a/apps/lyra/scripts/run-eval.cjs +++ b/apps/lyra/scripts/run-eval.cjs @@ -8,6 +8,11 @@ // pnpm eval:ami # ES2004a, IS1009a, TS3003a; first 10 min; far-field mic // pnpm eval:ami --meetings ES2004a --minutes 5 --mic Mix-Headset // pnpm eval:ami --minutes 0 # whole meetings (slow) +// pnpm eval:voxconverse # six VoxConverse test files, 2–8 people (DER only) +// pnpm eval:voxconverse --files tkhgs,qadia --minutes 3 +// pnpm eval:zoom # recorded Zoom meetings from YouTube, labelled from +// # the video's speaker border (Windows; DER only) +// pnpm eval:zoom --videos qGFoZ8yodc4 --minutes 10 // pnpm eval:local # your own recordings (scripts/eval/local.cjs) // node scripts/run-eval.cjs --score ref.json hyp.json # score any two transcripts // --check compare with the stored baseline for this suite, pipeline and @@ -48,6 +53,8 @@ const { compare, summarize } = require('./eval/baseline.cjs') const calls = require('./eval/calls.cjs') const local = require('./eval/local.cjs') const sessions = require('./eval/sessions.cjs') +const voxconverse = require('./eval/voxconverse.cjs') +const zoomVideo = require('./eval/zoom-video.cjs') const { score } = require('./eval/metrics.cjs') const root = join(__dirname, '..') @@ -62,7 +69,9 @@ const quick = process.argv.includes('--quick') /** One of each kind of trouble the full suites cover, chosen to finish in minutes. */ const QUICK = { calls: ['call-speakers', 'call-quick-turns', 'call-similar-voices', 'room-far-field'], - sessions: ['room-2-desk', 'room-2-quick', 'room-2-music', 'hybrid-2+1', 'call-1+1-quick'] + sessions: ['room-2-desk', 'room-2-quick', 'room-2-music', 'hybrid-2+1', 'call-1+1-quick'], + voxconverse: voxconverse.QUICK_FILES, + zoom: zoomVideo.QUICK_VIDEOS } const jobs = Math.max(1, Number(arg('jobs', quick ? '2' : '1')) || 1) const pipeline = arg('pipeline', 'live') @@ -72,11 +81,13 @@ const asr = arg('asr', 'whisper') const noContext = process.argv.includes('--no-context') const largerSpeakerModel = process.argv.includes('--larger-speaker-model') const pct = (value) => `${(value * 100).toFixed(1)}%`.padStart(7) +/** A word rate, or n/a for a reference of speaker turns without words (VoxConverse). */ +const wordPct = (value, words) => (words > 0 ? pct(value) : ' n/a') function report(id, result) { const { wer, cpWer, der } = result process.stdout.write( - `${id.padEnd(22)} WER ${pct(wer.rate)} cpWER ${pct(cpWer.rate)} DER ${pct(der.rate)}` + + `${id.padEnd(22)} WER ${wordPct(wer.rate, wer.words)} cpWER ${wordPct(cpWer.rate, cpWer.words)} DER ${pct(der.rate)}` + ` (miss ${pct(der.missed)} fa ${pct(der.falseAlarm)} conf ${pct(der.confusion)})` + ` speakers ${result.hypSpeakers}/${result.refSpeakers}` + `${relabeled(result.labels) === null ? '' : ` relabeled ${pct(relabeled(result.labels)).trim()}`}\n` @@ -186,7 +197,25 @@ function plan(dataset, dataDir) { items: meetings.map((meeting) => ({ name: meeting, prepare: () => ami.prepare(dataDir, meeting, { mic, minutes }) })) } } - throw new Error(`unknown --dataset ${dataset}; use calls, sessions, local or ami`) + if (dataset === 'voxconverse') { + const files = list(arg('files', (quick ? QUICK.voxconverse : voxconverse.DEFAULT_FILES).join(','))) + const minutes = Number(arg('minutes', '0')) + if (!Number.isFinite(minutes) || minutes < 0) throw new Error('--minutes must be a number ≥ 0') + return { + options: { files, minutes }, + items: files.map((file) => ({ name: file, prepare: () => voxconverse.prepare(dataDir, file, { minutes }) })) + } + } + if (dataset === 'zoom') { + const videos = list(arg('videos', (quick ? QUICK.zoom : zoomVideo.DEFAULT_VIDEOS).join(','))) + const minutes = Number(arg('minutes', '0')) + if (!Number.isFinite(minutes) || minutes < 0) throw new Error('--minutes must be a number ≥ 0') + return { + options: { videos, minutes }, + items: videos.map((video) => ({ name: video, prepare: () => zoomVideo.prepare(dataDir, video, { minutes }) })) + } + } + throw new Error(`unknown --dataset ${dataset}; use calls, sessions, local, ami, voxconverse or zoom`) } async function main() { @@ -252,8 +281,9 @@ async function main() { const run = save() const { overall } = run if (results.length > 0) { + const words = results.reduce((total, r) => total + r.wer.words, 0) process.stdout.write( - `${'overall'.padEnd(22)} WER ${pct(overall.wer)} cpWER ${pct(overall.cpWer)} DER ${pct(overall.der)}` + + `${'overall'.padEnd(22)} WER ${wordPct(overall.wer, words)} cpWER ${wordPct(overall.cpWer, words)} DER ${pct(overall.der)}` + `${overall.relabeled === undefined ? '' : ` relabeled ${pct(overall.relabeled).trim()}`}\n` ) } diff --git a/docs/EVALS.md b/docs/EVALS.md index 7db76879..ed1ff675 100644 --- a/docs/EVALS.md +++ b/docs/EVALS.md @@ -10,6 +10,8 @@ claims about accuracy quote this file, with its date and sample size, or are not | `pnpm eval:sessions` | Real voices (LibriSpeech dev-clean + test-clean, 80 speakers, CC BY 4.0) laid out as conversations: 2 to 6 people at one desk mic in different seats, hybrid meetings and calls with Opus remote audio and speaker bleed, music or a video playing, a fan, backchannels, crosstalk, a speaker who moves, an hour-long meeting when named. Versioned and seeded (`--seeds`); `--enroll` saves the owner's voice first | WER, cpWER, DER, speaker count | ffmpeg; downloads ~690 MB of LibriSpeech once and the models | | `pnpm eval:calls` | Synthetic calls and rooms made with system text-to-speech: speaker bleed, clipping, quick turns, crosstalk, similar voices | WER, cpWER, DER, speaker count | Windows (SAPI voices) or macOS (`say`, no similar-voice cases); downloads the models | | `pnpm eval:ami` | Real meetings from the AMI corpus (`--meetings`, `--minutes`, `--mic`) | WER, cpWER, DER | Downloads AMI audio and the models | +| `pnpm eval:voxconverse` | Real clips from VoxConverse v0.3 test (CC BY 4.0; debates, news, talk shows from YouTube) with hand-checked speaker turns: six files of 4–7 minutes, 2 to 6 people and one of 8 (`--files`, `--minutes`; `--quick`: 2, 3 and 5 people). Nothing in Lyra was tuned on them, so it is the held-out check on speakers | DER, speaker count (no words in the reference: WER and cpWER show n/a) | Downloads the labels (~3 MB) and ~10 MB of audio per file, and the models | +| `pnpm eval:zoom` | Recorded Zoom meetings from YouTube in gallery view (by default four of GitLab's public Key Meetings, 18–24 minutes each). The reference is read off the video (`scripts/eval/zoom.cjs`): the tile with Zoom's green active-speaker border, its name read with Windows' own OCR, moved earlier by the border's measured lag and cut to where the audio has speech. Stretches with no border (speaker view, screen share) are cut from the audio. Zoom outlines one person at a time, so overlapped speech isn't in the reference. Audio and names stay in `eval-data/zoom/`, never in the repo (standard YouTube license) | DER, speaker count (no words: WER and cpWER show n/a) | Windows, yt-dlp, ffmpeg; downloads ~70 MB per video and the models | | `node scripts/eval/cluster-lab.cjs` | The sessions, without Whisper | DER and speaker count for each voice model, window size and clustering bar | The models | | `node scripts/eval/voice-scores.cjs` | The sessions' enroll.wav against each speaker | How a saved voice scores against its owner and everyone else | The models | | `pnpm replay:session ` | A recorded session's kept audio | Who spoke each line; scores with `--reference` | The session's audio still kept | @@ -70,6 +72,8 @@ the number of sessions or scenarios. Sessions WER is driven by overlapping speec | 2026-11-25 | before the larger speaker model | AMI far-field (ES2004a, IS1009a, TS3003a, EN2002a; 10 min each) | live | 4 (40 min) | 39.2% | 47.6% | 31.1% | | 2026-11-25 | larger speaker model on (`--larger-speaker-model`) | AMI far-field, the same four | live | 4 (40 min) | 39.3% | 42.6% | 25.1% | | 2026-11-25 | larger speaker model on | sessions v2 mini, quick | live | 5 | 20.5% | 26.5% | 17.3% | +| 2026-11-27 | 2617f5e | VoxConverse test, quick (tkhgs, fyqoe, rpkso: 2, 3, 5 people) | live | 3 (15 min) | n/a | n/a | 11.7% | +| 2026-11-27 | 2617f5e | Zoom, quick (GitLab qGFoZ8yodc4; 9 speakers) | live | 1 (22 min) | n/a | n/a | 5.1% | ## The larger speaker model @@ -131,8 +135,9 @@ results above with them in mind: - **Tuned on the test set.** The speaker thresholds (`src/main/meeting/thresholds.ts`, the clustering bars) were tuned with `cluster-lab.cjs` and `voice-scores.cjs` on the same sessions - `eval:sessions` scores. There is no held-out set, so the sessions numbers are optimistic for - voices and rooms they haven't seen. + `eval:sessions` scores, so the sessions numbers are optimistic for voices and rooms they + haven't seen. `eval:voxconverse` and `eval:zoom` are the held-out checks: keep tuning off them, or they stop being + held out. - **`cluster-lab.cjs` is a copy.** It re-implements the clustering instead of importing the app's `clustering.ts`, so a sweep can disagree with what the app does after either one changes. - **Speaker naming is not scored.** cpWER and DER only check that lines are grouped by the right