offmute-v2 0.0.1-opus.0 β†’ 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,120 +1,167 @@
1
- # offmute-v2 πŸŽ™οΈβ±οΈ
1
+ # offmute-v2
2
2
 
3
- **Timestamp-correct, diarized meeting transcription.** Point it at a video or audio file and get back a transcript where every speaker turn is on the right millisecond, labelled with the speaker's name (when it can be inferred) and tone β€” as **SRT**, **Markdown**, or **JSON**.
3
+ Best-in-class diarized meeting transcription. A video/audio file (plus optional
4
+ instructions) goes in; a **timestamp-correct, diarized transcript with tone/behavior
5
+ labels** comes out β€” as SRT, Markdown, and JSON.
4
6
 
5
- It's the successor to [offmute](https://github.com/southbridgeai/offmute): great diarized transcripts, but now with real timestamps.
7
+ Runs as an **npx CLI**, a **Node library**, and **in the browser**.
6
8
 
7
- ```bash
8
- export GEMINI_API_KEY=... # multimodal understanding
9
- export ASSEMBLYAI_API_KEY=... # word-level timing
10
- npx offmute-v2 meeting.mp4 -i "Two founders chatting; label them by name."
11
- # β†’ meeting.srt meeting.md meeting.json
12
- ```
13
-
14
- ## Why it's accurate
9
+ > Living context: `intermediates/process_log_thoughts_ideas_hypotheses_and_scratch_space.md`
10
+ > (hypotheses, findings, gotchas) and `docs/spec.md` (design). Re-read when context compresses.
15
11
 
16
- No single model is good at everything, so offmute-v2 uses each for what it's best at and **fuses** them:
12
+ ## Results (verified on test-files/1: 32min talk + audience Q&A)
17
13
 
18
- | Job | Tool | Why |
19
- |-----|------|-----|
20
- | **WHEN** β€” word-level timestamps | ASR (AssemblyAI) | sub-second accurate; LLM timestamps drift minutes over a long file |
21
- | **WHO / HOW** β€” names, tone, hard audio | multimodal LLM (Gemini) | infers names from context, hears tone, handles crowds/interruptions; raw ASR diarization can't |
22
- | **fuse** | token alignment | maps the LLM's words onto the ASR's timestamps |
14
+ End-to-end pipeline vs the hand-checked reference SRT (38 entries):
23
15
 
24
- The LLM writes the transcript and decides who's talking; the ASR supplies the clock; an alignment pass marries them. (Details in [`docs/SPEC.md`](docs/SPEC.md).)
16
+ | metric | result |
17
+ |---|---|
18
+ | word accuracy (WER) | **86.5%** (WER 0.135) |
19
+ | reference coverage | **38/38** entries covered |
20
+ | boundary timing | **median 0.00s, p90 2.16s** |
21
+ | speaker accuracy | **94%** |
22
+ | alignment | 326/326 segments aligned to ASR word timing |
25
23
 
26
- ### Measured on a 32-minute talk (founder presentation + audience Q&A)
24
+ Speaker diarization correctly separates the presenter (named **Rishi** via the
25
+ identification pass) from 3 audience questioners, merging an AssemblyAI over-split of
26
+ the presenter into two speakers.
27
27
 
28
- Against a hand-checked reference transcript:
28
+ ## How it works
29
29
 
30
- - **Word error rate: 8.1%**
31
- - **Speaker attribution: 98.8%** (word-level)
32
- - **Turn-boundary timing: 0.04s median, 0.43s p90** error
30
+ A **hybrid** of two complementary strengths (the `inspirations/` projects each had one):
33
31
 
34
- In a few places it diarizes *better* than the hand-checked reference (e.g. splitting an audience question from the speaker's answer where the reference merged them).
32
+ - **Multimodal LLM** (Gemini) β†’ best *content*: verbatim text, tone, diarization through
33
+ interruptions, speaker identification via context. Coarse timestamps only.
34
+ - **Timestamped transcriber** (AssemblyAI Universal-2) β†’ best *timing*: word-accurate
35
+ timestamps + clean speaker separation over the whole file. No tone/context.
35
36
 
36
- ## CLI
37
-
38
- ```bash
39
- npx offmute-v2 <input> [options]
37
+ ```
38
+ preprocess β†’ describe β†’ llm-transcribe (per chunk) β†’ timestamped (whole file)
39
+ ↓
40
+ align (edit-distance: LLM text ↔ ASR word times)
41
+ ↓
42
+ gap-fill (recover dropped content from ASR)
43
+ ↓
44
+ consistency (merge ASR over-splits via LLM labels)
45
+ ↓
46
+ identify (optional, DeepSeek: name speakers from content)
47
+ ↓
48
+ finalize (dedup, overlap fix, clamp, format SRT/MD/JSON)
40
49
  ```
41
50
 
42
- | Option | Default | Description |
43
- |--------|---------|-------------|
44
- | `-i, --instructions <text>` | – | guide speaker labelling/focus, e.g. "host is Alice; group callers as 'Caller'" |
45
- | `-m, --model <model>` | `gemini-flash-latest` | LLM (e.g. `gemini-pro-latest` for max quality) |
46
- | `--asr <provider>` | `assemblyai` | `assemblyai` or `none` (LLM-only timing, less precise) |
47
- | `--no-video` | – | ignore the video track (audio only) |
48
- | `--keyframes <n>` | `8` | video frames sampled for visual context |
49
- | `--no-sub-segment` | – | keep whole speaker turns instead of subtitle-sized cues |
50
- | `--no-identify` | – | skip the speaker name-resolution pass |
51
- | `--thinking-level <lvl>` | `MINIMAL` | `MINIMAL\|LOW\|MEDIUM\|HIGH` (MINIMAL is best for transcription) |
52
- | `-o, --out <dir>` | `.` | where to write outputs |
53
- | `-f, --format <fmt>` | `all` | `srt \| md \| json \| all` |
54
- | `--intermediates-dir <dir>` | `.offmute_<name>` | cache dir (resumable) |
55
- | `--no-cache` | – | ignore cached intermediates |
56
-
57
- Intermediates (extracted audio, ASR JSON, raw LLM output, keyframes) are saved and reused, so re-runs are cheap and interrupted runs resume.
58
-
59
- ## Library
51
+ **The alignment** is the key idea (ts-aligner approach): align the whole chunk's LLM
52
+ token stream against the ASR word stream in one edit-distance DP pass, then split back
53
+ into segments β€” long ordered sequences pin common words unambiguously and transfer
54
+ accurate word timestamps onto the richer LLM text.
60
55
 
61
- ```ts
62
- import { transcribe, toSRT, toMarkdown } from "offmute-v2";
56
+ **Gap-fill** recovers content the LLM dropped: where ASR has speech in a time gap not
57
+ covered by any LLM segment (e.g. a dropped opening word), an ASR fallback segment is
58
+ inserted β€” so nothing the ASR heard is lost.
63
59
 
64
- const { transcript, srt, markdown } = await transcribe("meeting.mp4", {
65
- instructions: "Panel of three; label by name.",
66
- llmModel: "gemini-flash-latest",
67
- onProgress: (e) => console.log(e.stage, e.message),
68
- });
60
+ **Timestamped providers**: AssemblyAI Universal-2 (default β€” diarization + word
61
+ timestamps) or Groq Whisper (`--timestamped whisper-groq` β€” free/fast word timestamps,
62
+ no diarization; consistency then groups by LLM label).
69
63
 
70
- console.log(transcript.speakers); // [{ id, label, named, description }]
71
- console.log(transcript.segments[0]); // { start, end, speakerId, text, tone, ... }
72
- ```
64
+ ## Diarization levels (selectable via `--level`)
73
65
 
74
- Long files (>35 min) are automatically chunked with overlap and stitched back together; the whole-file ASR voice clusters keep speaker identity consistent across chunks.
66
+ 1. **Separation** β€” who speaks when (ASR speakers).
67
+ 2. **Anonymous-but-consistent** β€” Speaker A/B throughout (ASR speakers merged by LLM label; default).
68
+ 3. **Identification** β€” named speakers via content cues (DeepSeek).
75
69
 
76
- **More options:** `signal: AbortSignal` to cancel (cooperatively, at stage/chunk boundaries); `onLlmCall(rec)` to observe every LLM call (`{label, promptText, responseText, usage}`); `knownSpeakers`, `subSegment`, `identifySpeakers`, `asr: "none"`. Every LLM call (prompt + response) and the raw→parsed diarization are also written to `intermediates/<name>/llm/` and `diarize.parsed.json` for inspection.
70
+ ## Usage
71
+
72
+ ### npx CLI
73
+ ```bash
74
+ export GEMINI_API_KEY=... # multimodal transcription
75
+ export ASSEMBLYAI_API_KEY=... # timestamped transcription
76
+ export DEEPSEEK_API_KEY=... # optional, for --level 3 identification
77
+
78
+ npx offmute-v2 meeting.mov # default: flash model, level 2
79
+ npx offmute-v2 meeting.mov --model gemini-2.5-pro # higher quality
80
+ npx offmute-v2 meeting.mov --level 3 # name speakers
81
+ npx offmute-v2 meeting.mov -i "focus on action items, note accents"
82
+ npx offmute-v2 meeting.mov --passes align,consistency,finalize # resume from intermediates
83
+ npx offmute-v2 meeting.mov --only-chunk 2 # debug one chunk
84
+ ```
77
85
 
78
- ## Browser
86
+ Key options: `--passes`, `--level <1|2|3>`, `--model`, `--timestamped assemblyai|whisper-groq`,
87
+ `--formats srt,md,json`, `--chunk-seconds`, `--overlap-seconds`, `--concurrency`,
88
+ `--instructions`, `--force`, `--only-chunk`, `--reasoner`.
79
89
 
80
- Runs **entirely in the browser** (`offmute-v2/browser`, ~50KB, zero deps): decode with
81
- ffmpeg.wasm, call the providers over `fetch`, fuse with the pure core. You hand it a
82
- loaded `@ffmpeg/ffmpeg` instance and your keys β€” one call does the rest (chunking and
83
- all):
90
+ ### Node library
91
+ ```ts
92
+ import { transcribe } from "offmute-v2";
93
+ const result = await transcribe("meeting.mov", {
94
+ model: "gemini-2.5-flash",
95
+ level: 3,
96
+ instructions: "...",
97
+ apiKeys: { gemini: "...", assemblyai: "...", deepseek: "..." }, // injectable
98
+ formats: ["srt", "md", "json"],
99
+ });
100
+ // result.segments: Segment[], result.speakers: SpeakerInfo[]
101
+ ```
84
102
 
103
+ ### Browser
85
104
  ```ts
86
- import { FFmpeg } from "@ffmpeg/ffmpeg";
87
- import { transcribeInBrowser } from "offmute-v2/browser";
88
-
89
- const ffmpeg = new FFmpeg();
90
- await ffmpeg.load();
91
-
92
- const { srt, markdown, transcript } = await transcribeInBrowser(file /* File/Blob */, {
93
- ffmpeg,
94
- apiKeys: { gemini: GEMINI_KEY, assemblyai: ASSEMBLYAI_KEY }, // injected by the host
95
- instructions: "Host is Alice; label callers as 'Caller'.",
96
- useVideo: true,
97
- onProgress: (e) => console.log(e.stage, e.message),
105
+ import { transcribeBrowser } from "offmute-v2/browser";
106
+ // audio = mono Blob (extract from video via ffmpeg.wasm first)
107
+ const result = await transcribeBrowser({
108
+ audio, geminiApiKey, assemblyaiApiKey,
109
+ model: "gemini-2.5-flash", level: 3, deepseekApiKey,
98
110
  });
99
111
  ```
112
+ The core (align/consistency/identify/finalize/format) is pure TS with no node deps and
113
+ bundles to ~35KB with zero node-only imports. The browser build uses fetch-based
114
+ providers (Gemini inline base64 + AssemblyAI REST). Best for audio ≀ ~20MB inline; for
115
+ longer files, chunk with ffmpeg.wasm and call the stages directly.
100
116
 
101
- A runnable demo is in [`examples/browser/index.html`](examples/browser/index.html) (loads
102
- ffmpeg.wasm from a CDN). Lower-level pieces (`GeminiFetchClient`, `transcribeWithAssemblyAIFetch`,
103
- `extractAudioWasm`, and the pure `assembleTranscript`) are exported too β€” see
104
- [`docs/BROWSER.md`](docs/BROWSER.md). The fetch providers are isomorphic, so they work in
105
- Node 18+ as well.
117
+ ## Architecture
106
118
 
107
- ## Requirements
119
+ ```
120
+ src/
121
+ core/ types, config (models, key resolution, chunk planning), pipeline
122
+ audio/ ffmpeg wrapper (probe, audio, chunk, scene-aware keyframes, silence)
123
+ providers/ gemini (SDK), gemini-fetch + assemblyai-fetch (browser), openai-compat (DeepSeek/Groq)
124
+ transcribe/ llm transcription (prompt + JSON schema), describe (roster)
125
+ align/ normalize, edit-distance DP, aligner (flat-sequence alignment)
126
+ diarize/ consistency (merge by LLM label), identify (DeepSeek naming)
127
+ finalize/ dedup, overlap fix + clamp, format (SRT/MD/JSON with block-breaking)
128
+ eval/ scorer (WER, coverage, timing, speaker agreement vs reference)
129
+ utils/ time, srt, logger
130
+ scripts/ per-stage test scripts + eval
131
+ tests/ vitest unit tests (align, finalize)
132
+ ```
108
133
 
109
- - Node β‰₯ 18 and `ffmpeg`/`ffprobe` on PATH (CLI / Node library).
110
- - API keys from env or injected (`apiKeys` option): `GEMINI_API_KEY` (or `GOOGLE_API_KEY`), `ASSEMBLYAI_API_KEY`.
134
+ Every pipeline stage persists intermediates to disk and is **resumable** (skips work
135
+ whose output exists unless `--force`); the run is **stoppable** β€” results so far are
136
+ always on disk.
111
137
 
112
- ## Diarization levels
138
+ ## Development
139
+ ```bash
140
+ npm install
141
+ npm run typecheck && npm run lint && npm test # 16 unit tests
142
+ npm run dev # tsx src/cli.ts
143
+ npm run build # tsup β†’ dist/ (node + browser bundles)
144
+ ```
145
+
146
+ ## Requirements
147
+ - Node β‰₯ 20, ffmpeg/ffprobe in PATH.
148
+ - API keys: `GEMINI_API_KEY` (or `GOOGLE_API_KEY`), `ASSEMBLYAI_API_KEY`. `DEEPSEEK_API_KEY` optional (level 3). `GROQ_API_KEY` optional (whisper-groq fallback).
113
149
 
114
- 1. **Separation** β€” who speaks when. 2. **Anonymous-consistent** β€” Speaker A/B, stable throughout. 3. **Identification** β€” real names from context. offmute-v2 targets **3**, with instruction-driven grouping (e.g. "everyone except the host is 'Audience'").
150
+ ## Eval
151
+ ```bash
152
+ npx tsx scripts/eval.ts path/to/output.json # score a run vs the reference SRT
153
+ ```
115
154
 
116
- ## Credits
155
+ ## Reviews, fixes & receipts
156
+ This build (the **GLM** branch) was reviewed and iterated in the open. The receipts:
157
+ - **Spec & plan:** [`docs/spec.md`](docs/spec.md)
158
+ - **Round 1** (run-through): [`docs/review-1/human-review.md`](docs/review-1/human-review.md) β†’ fixes in [`docs/review-1/review-fixes.md`](docs/review-1/review-fixes.md)
159
+ - **Round 2** (code read + independent review): [`docs/review-2/human-review.md`](docs/review-2/human-review.md), [`docs/review-2/REVIEW.md`](docs/review-2/REVIEW.md), [`docs/review-2/REVIEWER_GUIDE.md`](docs/review-2/REVIEWER_GUIDE.md) β†’ fixes in [`docs/review-2/review-fixes.md`](docs/review-2/review-fixes.md)
160
+ - **Response to the GLM-vs-Opus comparison:** [`docs/comparison-response.md`](docs/comparison-response.md)
161
+ - **Dev journal:** [`intermediates/process_log_thoughts_ideas_hypotheses_and_scratch_space.md`](intermediates/process_log_thoughts_ideas_hypotheses_and_scratch_space.md)
162
+ - **Releasing / npm tags:** [`RELEASING.md`](RELEASING.md)
117
163
 
118
- Builds on three predecessors: **offmute** (multimodal describe→transcribe, tone), **ipgu** (chunk/merge discipline, timestamp validation), **meeting-diary** (ASR word-timestamps + diarization). Created by [Southbridge](https://southbridge.ai).
164
+ The Opus-built variant lives on the [`opus`](../../tree/opus) branch; the experiment overview is on [`master`](../../tree/master).
119
165
 
120
- License: Apache-2.0.
166
+ ## License
167
+ Apache-2.0.