Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/brown-jars-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

---


2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file.wav> [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; `--crash` dies half way through, then resumes as the next start would; `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 <session>` 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 <session>` 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 <session id or folder>` (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 |
Expand Down
2 changes: 2 additions & 0 deletions apps/lyra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/lyra/scripts/eval/ami.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
102 changes: 102 additions & 0 deletions apps/lyra/scripts/eval/voxconverse.cjs
Original file line number Diff line number Diff line change
@@ -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 <dataDir>/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 }
43 changes: 43 additions & 0 deletions apps/lyra/scripts/eval/voxconverse.test.mjs
Original file line number Diff line number Diff line change
@@ -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 <NA> <NA> spk01 <NA> <NA>',
'SPEAKER aepyx 1 2.50000 3.66000 <NA> <NA> spk00 <NA> <NA>'
].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 <NA> <NA> <NA> unknown spk00 <NA> <NA>',
'',
'SPEAKER aepyx 1 1.0 0 <NA> <NA> spk00 <NA> <NA>',
'SPEAKER aepyx 1 x 2.0 <NA> <NA> spk00 <NA> <NA>',
'SPEAKER aepyx 1 3.0 1.0 <NA> <NA> spk02 <NA> <NA>'
].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: '' }
])
})
})
43 changes: 43 additions & 0 deletions apps/lyra/scripts/eval/zoom-ocr.ps1
Original file line number Diff line number Diff line change
@@ -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))
}
Loading
Loading