offmute-v2 0.0.2 → 0.0.4

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Southbridge
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,95 +1,287 @@
1
- # offmute-v2
1
+ <div align="center">
2
2
 
3
- **Timestamp-correct, diarized meeting transcription** — a video/audio file goes in; a
4
- speaker-labelled, tone-annotated transcript with accurate timestamps comes out (SRT / Markdown /
5
- JSON). It fuses a multimodal LLM (content, diarization, tone, speaker identity) with an ASR model
6
- (word-level timing), aligned together. Runs as an npx CLI, a Node library, and in the browser.
3
+ # offmute-v2 🎙️⏱️
7
4
 
8
- > 📝 **Full write-up:** _"offmute-v2: GLM vs Opus"_ — **coming soon** at
9
- > http://southbridge.ai/blog/offmute-v2-glm-vs-opus
5
+ ### `npx offmute-v2 meeting.mp4`
6
+
7
+ **Timestamp-correct, diarized meeting transcription.** Point it at a video or audio file and get
8
+ back a transcript where every speaker turn lands on the right millisecond — labelled with the
9
+ speaker's name (when it can be inferred) and their tone — as **SRT**, **Markdown**, and **JSON**.
10
+
11
+ [![npm](https://img.shields.io/npm/v/offmute-v2?color=cb3837&logo=npm)](https://www.npmjs.com/package/offmute-v2)
12
+ [![license](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
13
+ [![node](https://img.shields.io/badge/node-%E2%89%A520-339933?logo=node.js&logoColor=white)](#requirements)
14
+
15
+ 📝 **Read the full write-up — _"offmute-v2: GLM vs Opus"_ — coming soon at
16
+ [southbridge.ai/blog/offmute-v2-glm-vs-opus](http://southbridge.ai/blog/offmute-v2-glm-vs-opus)**
17
+
18
+ </div>
10
19
 
11
20
  ---
12
21
 
13
- ## This repo is an agent-vs-agent experiment
22
+ It's the successor to [offmute](https://github.com/southbridgeai/offmute): the same great diarized,
23
+ tone-aware transcripts — now with **real timestamps**, SRT output, a resumable pipeline, and a
24
+ browser build. No single model is good at everything, so offmute-v2 uses each for what it's best at
25
+ and **fuses** them.
26
+
27
+ ```bash
28
+ export GEMINI_API_KEY=... # multimodal understanding (or GOOGLE_API_KEY)
29
+ export ASSEMBLYAI_API_KEY=... # word-level timing
30
+
31
+ npx offmute-v2 meeting.mp4 -i "Panel of founders; label them by name."
32
+ # → meeting.srt meeting.md meeting.json
33
+ ```
34
+
35
+ That's it. `bunx offmute-v2 meeting.mp4` works too.
36
+
37
+ ## What you get
38
+
39
+ A clean, sub-second-aligned, speaker-labelled transcript with tone — same content rendered three ways:
40
+
41
+ **`meeting.srt`** (drop straight onto the video):
42
+
43
+ ```srt
44
+ 1
45
+ 00:00:00,160 --> 00:00:00,720
46
+ Speaker D: GPU
47
+
48
+ 2
49
+ 00:00:01,199 --> 00:00:05,440
50
+ Presenter: And I'm inspired. I think I'm going to apply to NTU this fall. (confident, joking)
51
+ ```
52
+
53
+ **`meeting.md`** (skimmable, grouped by speaker, with talk-time):
54
+
55
+ ```markdown
56
+ *Duration: 1914s · Speakers: 5*
57
+
58
+ ## Speakers
59
+ - **Presenter** (1461s)
60
+ - **Speaker B** (97s) · **Speaker C** (87s) · ...
61
+
62
+ ## Transcript
63
+ [00:00] **Speaker D**: GPU
64
+ [00:01] **Presenter** *(confident, joking)*: And I'm inspired. I think I'm going to apply to NTU this fall.
65
+ ```
66
+
67
+ **`meeting.json`** — every segment with `start`/`end`, `speaker`, `text`, `tone[]`, `timingSource`,
68
+ `confidence`, and word-level timings — for downstream tooling.
14
69
 
15
- offmute-v2 was built **twice, from a single identical prompt**, by two different models running in
16
- **Claude Code** — as a head-to-head of how each does on a hard, AI-resistant build (combining the
17
- ideas from [offmute], [meeting-diary], and [ipgu] into one timestamp-accurate diarizer):
70
+ ## Why it's accurate
18
71
 
19
- | Branch | Built by | npm | What it is |
20
- |--------|----------|-----|------------|
21
- | [`glm`](../../tree/glm) | **GLM-5.2** | `offmute-v2@latest` / `@glm` | the **primary**, daily-driven build |
22
- | [`opus`](../../tree/opus) | **Claude Opus 4.8** | `offmute-v2@opus` | the comparison build, preserved with full history |
23
- | `master` | — | — | this overview + the current primary (tracks `glm` for now; may diverge) |
72
+ LLMs are brilliant at *understanding* speech (who's talking, through interruptions, in a crowd,
73
+ with tone) but [terrible at timestamps](#how-it-works). ASR models are the opposite: sub-second
74
+ timing, but mediocre diarization and no sense of tone. offmute-v2 runs **both** and marries them:
24
75
 
25
- The two branches have **independent histories** — each is the full, unedited commit trail of that
26
- model's build, including every review round and fix (so you can read exactly what happened).
76
+ | Job | Tool | Why |
77
+ |-----|------|-----|
78
+ | **WHO / HOW** — speakers, names, tone, hard audio | multimodal **LLM** (Gemini) | infers names from context, hears tone, handles crowds & interruptions |
79
+ | **WHEN** — word-level timestamps | **ASR** (AssemblyAI / Groq Whisper) | sub-second accurate; LLM timestamps drift *minutes* over a long file |
80
+ | **fuse** | edit-distance **alignment** | transfers the ASR's clock onto the LLM's richer words |
27
81
 
28
- ## The receipts (per branch, in `docs/`)
82
+ ```mermaid
83
+ flowchart LR
84
+ IN["🎬 audio / video"] --> PRE["preprocess<br/>16kHz mono + keyframes"]
85
+ PRE --> LLM["multimodal LLM<br/>diarize · transcribe · tone<br/><i>(per chunk)</i>"]
86
+ PRE --> ASR["ASR<br/>word-level timestamps<br/><i>(whole file)</i>"]
87
+ LLM --> AL["align<br/>edit-distance fuse"]
88
+ ASR --> AL
89
+ AL --> GF["gap-fill<br/>recover dropped speech"]
90
+ GF --> CON["consistency<br/>stable speakers"]
91
+ CON --> ID["identify names<br/><i>(optional, level 3)</i>"]
92
+ ID --> FIN["finalize →<br/>SRT · MD · JSON"]
93
+ ```
94
+
95
+ **Measured** on a hand-checked 32-minute talk (founder presentation + audience Q&A): **≈8% word
96
+ error rate** and **~99% word-level speaker attribution**, with turn boundaries riding AssemblyAI's
97
+ word timing (first cue at `00:00:00,160`, exactly matching ground truth). Full methodology, runs,
98
+ and an independent re-score live in [`docs/`](#receipts--how-this-repo-was-built) and the article.
29
99
 
30
- Each build branch carries its own review trail:
100
+ ## Features
31
101
 
32
- - `docs/spec.md` — the plan & hypotheses
33
- - `docs/review-1/` — first run-through review + the model's diagnosed fixes
34
- - `docs/review-2/` — code-read + independent review + fixes
35
- - `docs/comparison-response.md` (glm) / `docs/review-comparison-fixes.md` (opus) — each model's
36
- response to the cross-model comparison
37
- - `intermediates/process_log_*.md` — the model's append-only dev journal
102
+ - 🎯 **Timestamp-correct** — word-level timing from ASR, fused onto LLM text by alignment.
103
+ - 🎭 **Diarization + tone** — separates speakers through interruptions; annotates `(laughing)`,
104
+ `(hesitant)`, `(confident)`, …
105
+ - 🧑‍🤝‍🧑 **Three levels of speaker labelling** — separation → stable `Speaker A/B` → real names
106
+ inferred from context (`--level 3`).
107
+ - 🎬 **Video-aware** — samples keyframes for visual context (who's on screen, demos, slides).
108
+ - ⚡ **Chunked + concurrent** — long files are split with overlap and stitched back with
109
+ **ownership-partition** dedup (no double-printed sentences at chunk seams).
110
+ - ♻️ **Resumable & stoppable** — every stage caches to disk (in the **OS temp dir** by default;
111
+ the path is printed each run, and `-i <dir>` keeps it wherever you like). Re-runs skip finished
112
+ work, Ctrl-C leaves partials. The cache is keyed on the input **and** the config, so changing
113
+ `--model` never serves you a stale transcript.
114
+ - 🔀 **Pluggable providers** — Gemini for the LLM; AssemblyAI *or* Groq Whisper for timing.
115
+ - 🌐 **Runs in the browser** — a pure, node-free core + `fetch` providers + ffmpeg.wasm.
116
+ - 🔎 **Fully inspectable** — every LLM prompt+response is logged to `llm-calls.jsonl`; all
117
+ intermediates are plain JSON.
38
118
 
39
- Browse them on [`glm`](../../tree/glm/docs) and [`opus`](../../tree/opus/docs).
119
+ ## Usage
40
120
 
41
- ## Quick start
121
+ ### CLI
42
122
 
43
123
  ```bash
44
- export GEMINI_API_KEY=... # multimodal transcription (or GOOGLE_API_KEY)
45
- export ASSEMBLYAI_API_KEY=... # word-level timing
46
-
47
- # primary (GLM) build:
48
- npx offmute-v2@latest meeting.mp4
49
- # explicitly pin a build:
50
- npx offmute-v2@glm meeting.mp4
51
- npx offmute-v2@opus meeting.mp4
124
+ npx offmute-v2 <input> [options]
52
125
  ```
53
126
 
54
- As a library (this `master`/GLM line takes a single options object — `input` and `outputDir`
55
- are required):
127
+ | Option | Default | Description |
128
+ |--------|---------|-------------|
129
+ | `-o, --output <dir>` | `./output` | where to write `*.srt` / `*.md` / `*.json` |
130
+ | `--instructions <text>` | – | guide diarization / labelling, e.g. `"host is Alice; group callers as 'Caller'"` |
131
+ | `--model <name>` | `gemini-2.5-flash` | multimodal LLM (`gemini-2.5-pro`, `gemini-3.1-pro-preview`, `gemini-flash-latest`, …) |
132
+ | `--level <1\|2\|3>` | `2` | 1 = separation · 2 = stable anon · 3 = identify names |
133
+ | `--timestamped <p>` | `assemblyai` | timing provider: `assemblyai` · `whisper-groq` · `none` |
134
+ | `--reasoner <name>` | `deepseek-chat` | text model for the name-identification pass (level 3) |
135
+ | `--chunk-seconds <n>` | `600` | chunk length · `--overlap-seconds` (default `60`) |
136
+ | `--formats <list>` | `srt,md,json` | which outputs to write |
137
+ | `--passes <list>` | all | run/resume a subset of stages |
138
+ | `--force` | – | ignore caches and recompute |
139
+ | `--only-chunk <n>` | – | process a single chunk (debugging) |
140
+ | `-i, --intermediates <dir>` | auto | cache dir (auto-derived per input) |
141
+
142
+ ```bash
143
+ npx offmute-v2 meeting.mp4 --level 3 # name the speakers
144
+ npx offmute-v2 meeting.mp4 --model gemini-2.5-pro # higher quality
145
+ npx offmute-v2 talk.mov --timestamped whisper-groq # free/fast timing, no AssemblyAI
146
+ npx offmute-v2 meeting.mp4 --passes align,consistency,finalize # resume from cache
147
+ ```
148
+
149
+ ### Library
150
+
151
+ The primary line takes a single options object (`input` and `outputDir` are required):
56
152
 
57
153
  ```ts
58
154
  import { transcribe } from "offmute-v2";
59
155
 
60
- const { segments, speakers } = await transcribe({
156
+ const { segments, speakers, metadata } = await transcribe({
61
157
  input: "meeting.mp4",
62
158
  outputDir: "./out",
63
- model: "gemini-flash-latest", // or gemini-2.5-pro, gemini-3.1-pro-preview, …
159
+ model: "gemini-flash-latest",
160
+ level: 3,
161
+ instructions: "Three-person panel; label by name.",
64
162
  formats: ["srt", "md", "json"],
65
- // apiKeys: { gemini, assemblyai } // optional; falls back to env
163
+ apiKeys: { gemini: "...", assemblyai: "..." }, // optional; falls back to env
66
164
  });
165
+
166
+ console.log(segments[0]); // { start, end, speaker, text, tone, timingSource, ... }
67
167
  ```
68
168
 
69
- Both branches publish the same `offmute-v2` CLI and library; they differ in pipeline internals (e.g.
70
- GLM's ASR-backbone consistency + gap-fill, Opus's ownership-partition merge + voice-anchored
71
- identify) and in the library call shape (the Opus build uses `transcribe(input, options)`). See each
72
- branch's README and [`RELEASING.md`](RELEASING.md) for the `latest` / `glm` / `opus` npm tags.
169
+ Individual stages (`alignSegments`, `assignGlobalSpeakers`, `finalizeSegments`, formatters, …) are
170
+ exported too, so you can build your own pipeline.
73
171
 
74
- ## Build from source
172
+ ### Browser
75
173
 
76
- ```bash
77
- git clone https://github.com/SouthBridgeAI/offmute-v2.git
78
- cd offmute-v2 && git checkout glm # or: opus
174
+ The fusion core (align / consistency / identify / finalize / format) is pure TypeScript with **zero
175
+ node-only imports**, so it bundles tiny and runs in the browser via `offmute-v2/browser` — using
176
+ `fetch`-based providers and `ffmpeg.wasm` for in-browser audio extraction. See
177
+ [`docs/`](#receipts--how-this-repo-was-built) / the browser example for the integration seam.
178
+
179
+ ## How it works
180
+
181
+ A multi-stage pipeline where each stage persists a JSON intermediate (so it's resumable and
182
+ debuggable):
183
+
184
+ 1. **preprocess** — ffmpeg → compact mono 16 kHz **mp3** + scene-aware keyframes (a 9.6 GB `.mov`
185
+ becomes a few MB of audio in seconds — transparent for speech, but a fraction of lossless size).
186
+ 2. **describe** — a quick multimodal pass builds a meeting summary + speaker roster to prime
187
+ transcription.
188
+ 3. **llm-transcribe** — each chunk goes to the LLM for verbatim text, diarization, and tone. Output
189
+ is plain text with coarse `mm:ss` markers, parsed leniently (truncated text degrades gracefully
190
+ where truncated JSON would be unrecoverable — a lesson from [ipgu](#credits)).
191
+ 4. **timestamped** — the whole file goes to ASR for word-level timing + a speaker backbone.
192
+ 5. **align** — the heart: the LLM's token stream is aligned against the ASR word stream with a
193
+ Needleman–Wunsch edit-distance DP, transferring accurate word times onto the richer LLM text.
194
+ 6. **gap-fill** — anywhere ASR heard speech that no LLM segment covers, an ASR fallback is inserted
195
+ so nothing is dropped.
196
+ 7. **consistency** — the ASR voice clusters act as a global backbone, merging the LLM's per-chunk
197
+ labels into stable speakers (and fixing ASR over-splits).
198
+ 8. **identify** *(level 3)* — a reasoning model maps `Speaker A` → real names using context + a
199
+ voice-cluster hint.
200
+ 9. **finalize** — overlap fixes, clamping, readable subtitle-sized blocks, and SRT/MD/JSON.
201
+
202
+ > [!NOTE]
203
+ > The hard parts of this problem are **chunk overlap** and **alignment**. offmute-v2 partitions
204
+ > overlap by *ownership* (each word is emitted by exactly one chunk) so sentences are never
205
+ > double-printed at seams, and aligns the *whole* chunk in one DP pass so common words like "it"
206
+ > can't mis-match to a later occurrence.
79
207
 
80
- # glm build (npm): npm ci && npm run build && npm test
81
- # opus build (bun): bun install && bun run build && bun test
82
- node dist/cli.js --help # (glm CLI entry is dist/cli.cjs)
208
+ ## Built twice, in the open: GLM vs Opus
209
+
210
+ This repo is also an **agent-vs-agent experiment**. offmute-v2 was built **twice, from one identical
211
+ prompt**, by two different models running in **Claude Code** — a head-to-head on a hard,
212
+ AI-resistant build (fusing the ideas of [offmute], [meeting-diary], and [ipgu] into one
213
+ timestamp-accurate diarizer):
214
+
215
+ | Branch | Built by | npm tag | What it is |
216
+ |--------|----------|---------|------------|
217
+ | [`master`](../../tree/master) | GLM line + post-launch fixes | `offmute-v2@latest` | the daily-driven, hardened build (this README) |
218
+ | [`glm`](../../tree/glm) | **GLM-5.2** | `offmute-v2@glm` | the frozen GLM experiment build |
219
+ | [`opus`](../../tree/opus) | **Claude Opus 4.8** | `offmute-v2@opus` | the frozen Opus experiment build |
220
+
221
+ ```bash
222
+ npx offmute-v2@glm meeting.mp4 # the GLM build, exactly as submitted
223
+ npx offmute-v2@opus meeting.mp4 # the Opus build, exactly as submitted
83
224
  ```
84
225
 
226
+ The `glm` and `opus` branches have **independent histories** — each is the full, unedited commit
227
+ trail of that model's build, every review round, and every fix. The headline finding (spoiler):
228
+ once a chunk-overlap dedup bug is accounted for, the two are a near dead-heat on accuracy, and the
229
+ differences are in code conventions, error DX, and packaging. The full analysis is in the article.
230
+
231
+ ## Receipts & how this repo was built
232
+
233
+ Everything is open for inspection:
234
+
235
+ - **Per-branch review trails** (on [`glm`](../../tree/glm/docs) / [`opus`](../../tree/opus/docs)):
236
+ `docs/spec.md`, `docs/review-1/`, `docs/review-2/` (run-throughs, code reads, an independent
237
+ review, and each model's diagnosed fixes), and the append-only `intermediates/process_log_*.md`
238
+ dev journals.
239
+ - **Releasing & npm tags:** [`RELEASING.md`](RELEASING.md) — published via GitHub Actions **npm
240
+ Trusted Publishing (OIDC)**, no tokens, with provenance.
241
+
242
+ ## Diarization levels
243
+
244
+ 1. **Separation** — who speaks when.
245
+ 2. **Anonymous-consistent** — `Speaker A/B`, stable across the whole file *(default)*.
246
+ 3. **Identification** — real names inferred from context (needs `DEEPSEEK_API_KEY`, or point
247
+ `--reasoner` at another provider). Use `--instructions` to steer (e.g. *"everyone except the
248
+ host is 'Audience'"*).
249
+
85
250
  ## Requirements
86
- - Node ≥ 20 and `ffmpeg`/`ffprobe` on PATH (CLI / library). Browser builds use ffmpeg.wasm.
87
- - API keys from env or injected: `GEMINI_API_KEY` (or `GOOGLE_API_KEY`), `ASSEMBLYAI_API_KEY`;
88
- optional `DEEPSEEK_API_KEY` / `GROQ_API_KEY` depending on the build/options.
89
251
 
90
- ## License
91
- Apache-2.0. Built on [offmute], [meeting-diary], and [ipgu]. Credit to the model teams — including
92
- [z.ai](https://z.ai) for GLM-5.2.
252
+ - **Node ≥ 20** and **`ffmpeg`/`ffprobe`** on `PATH` (CLI / library). The browser build uses
253
+ ffmpeg.wasm instead.
254
+ - **API keys** (from env or the `apiKeys` option):
255
+ - `GEMINI_API_KEY` (or `GOOGLE_API_KEY`) — required.
256
+ - `ASSEMBLYAI_API_KEY` — required for timing (or use `--timestamped whisper-groq` + `GROQ_API_KEY`).
257
+ - `DEEPSEEK_API_KEY` — optional, for `--level 3` name identification.
258
+
259
+ ## Development
260
+
261
+ ```bash
262
+ git clone https://github.com/SouthBridgeAI/offmute-v2.git
263
+ cd offmute-v2 # master = the primary build
264
+ npm ci
265
+ npm run typecheck && npm run lint && npm test
266
+ npm run build # tsup → dist/ (node + browser bundles)
267
+ npm run dev -- meeting.mp4 # run from source
268
+ ```
269
+
270
+ To compare against the experiment builds, check out the [`glm`](../../tree/glm) or
271
+ [`opus`](../../tree/opus) branch (the Opus build uses Bun: `bun install && bun run build`).
272
+
273
+ ## Credits
274
+
275
+ Built on three predecessors, with their hard-won lessons carried forward:
276
+
277
+ - **[offmute]** — multimodal describe→transcribe, diarization, tone.
278
+ - **[meeting-diary]** — ASR word-timestamps + speaker diarization.
279
+ - **[ipgu]** — chunk/merge discipline and structured extraction from LLM output.
280
+
281
+ Created by [Southbridge](https://southbridge.ai). Thanks to the model teams — including
282
+ [z.ai](https://z.ai) for GLM-5.2 and Anthropic for Claude Opus.
283
+
284
+ **License:** Apache-2.0.
93
285
 
94
286
  [offmute]: https://github.com/southbridgeai/offmute
95
287
  [meeting-diary]: https://github.com/southbridgeai/meeting-diary
package/dist/cli.cjs CHANGED
@@ -40,6 +40,7 @@ var import_node_fs4 = require("fs");
40
40
  var import_node_crypto = require("crypto");
41
41
  var import_node_path = require("path");
42
42
  var import_node_fs = require("fs");
43
+ var import_node_os = require("os");
43
44
  var DEFAULT_PASSES = [
44
45
  "preprocess",
45
46
  "describe",
@@ -112,7 +113,7 @@ function deriveIntermediatesDir(input2) {
112
113
  const abs = (0, import_node_path.resolve)(input2);
113
114
  const hash = (0, import_node_crypto.createHash)("sha1").update(abs).digest("hex").slice(0, 8);
114
115
  const base = (0, import_node_path.basename)(input2, extOf(input2)) || "input";
115
- return `${(0, import_node_path.dirname)(abs)}/.offmute-v2-${base}-${hash}`;
116
+ return `${(0, import_node_os.tmpdir)()}/offmute-v2-${base}-${hash}`;
116
117
  }
117
118
  function extOf(p) {
118
119
  const i = p.lastIndexOf(".");
@@ -199,7 +200,7 @@ var import_node_child_process = require("child_process");
199
200
  var import_promises = require("fs/promises");
200
201
  var import_node_path2 = require("path");
201
202
  function run(cmd, args, _opts = {}) {
202
- return new Promise((resolve2, reject) => {
203
+ return new Promise((resolve3, reject) => {
203
204
  const child = (0, import_node_child_process.spawn)(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
204
205
  let stdout = "";
205
206
  let stderr = "";
@@ -207,7 +208,7 @@ function run(cmd, args, _opts = {}) {
207
208
  child.stderr.on("data", (d) => stderr += d.toString());
208
209
  child.on("error", reject);
209
210
  child.on("close", (code) => {
210
- if (code === 0) resolve2({ stdout, stderr });
211
+ if (code === 0) resolve3({ stdout, stderr });
211
212
  else {
212
213
  const tail = stderr.slice(-800);
213
214
  reject(new Error(`${cmd} exited ${code}: ${tail}`));
@@ -1736,6 +1737,7 @@ async function transcribe(opts2) {
1736
1737
  }
1737
1738
  (0, import_node_fs4.mkdirSync)(options.intermediatesDir, { recursive: true });
1738
1739
  (0, import_node_fs4.mkdirSync)(options.outputDir, { recursive: true });
1740
+ logger.info(`intermediates: ${(0, import_node_path5.resolve)(options.intermediatesDir)} (file://${(0, import_node_path5.resolve)(options.intermediatesDir)})`);
1739
1741
  setLlmLogPath(options.llmLog ? `${options.intermediatesDir}/llm-calls.jsonl` : null);
1740
1742
  const sourcePath = `${options.intermediatesDir}/source.json`;
1741
1743
  const sig = inputSignature(options.input);
@@ -1779,7 +1781,8 @@ async function transcribe(opts2) {
1779
1781
  }
1780
1782
  }
1781
1783
  let probeInfo = null;
1782
- const audioPath = `${options.intermediatesDir}/audio.flac`;
1784
+ const AUDIO_OPTS = { format: "mp3", bitrate: "64k" };
1785
+ const audioPath = `${options.intermediatesDir}/audio.mp3`;
1783
1786
  const probePath = `${options.intermediatesDir}/probe.json`;
1784
1787
  if (has(passes2, "preprocess")) {
1785
1788
  logger.info("=== preprocess ===");
@@ -1789,8 +1792,8 @@ async function transcribe(opts2) {
1789
1792
  writeJson(probePath, probeInfo);
1790
1793
  }
1791
1794
  if (!(0, import_node_fs4.existsSync)(audioPath) || forceAll) {
1792
- logger.info("extracting audio (mono 16kHz FLAC)...");
1793
- await extractAudio(options.input, audioPath, { format: "flac" });
1795
+ logger.info("extracting audio (mono 16kHz mp3)...");
1796
+ await extractAudio(options.input, audioPath, AUDIO_OPTS);
1794
1797
  }
1795
1798
  if (probeInfo.hasVideo) {
1796
1799
  const kfDir = `${options.intermediatesDir}/keyframes`;
@@ -1811,9 +1814,9 @@ async function transcribe(opts2) {
1811
1814
  if (!description) {
1812
1815
  logger.info("=== describe ===");
1813
1816
  const client = new GeminiClient(keys.gemini);
1814
- const samplePath = `${options.intermediatesDir}/sample.flac`;
1817
+ const samplePath = `${options.intermediatesDir}/sample.mp3`;
1815
1818
  if (!(0, import_node_fs4.existsSync)(samplePath) || forceAll) {
1816
- await extractChunk(audioPath, samplePath, 0, Math.min(300, duration), { format: "flac" });
1819
+ await extractChunk(audioPath, samplePath, 0, Math.min(300, duration), AUDIO_OPTS);
1817
1820
  }
1818
1821
  const files = [{ path: samplePath }];
1819
1822
  const kfDir = `${options.intermediatesDir}/keyframes`;
@@ -1867,9 +1870,9 @@ async function transcribe(opts2) {
1867
1870
  logger.info(`chunk ${chunk.index}: cached (${cached.segments.length} segments)`);
1868
1871
  return tagWith(cached, chunk);
1869
1872
  }
1870
- const chunkPath = `${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}.flac`;
1873
+ const chunkPath = `${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}.mp3`;
1871
1874
  if (!(0, import_node_fs4.existsSync)(chunkPath) || forceAll) {
1872
- await extractChunk(audioPath, chunkPath, chunk.start, chunk.end, { format: "flac" });
1875
+ await extractChunk(audioPath, chunkPath, chunk.start, chunk.end, AUDIO_OPTS);
1873
1876
  }
1874
1877
  let previousTail;
1875
1878
  if (chunk.index > 0) {
@@ -1932,12 +1935,11 @@ async function transcribe(opts2) {
1932
1935
  if (provider === "whisper-groq") {
1933
1936
  logger.info("=== timestamped (Groq Whisper \u2014 no diarization) ===");
1934
1937
  if (!keys.groq) throw new Error("GROQ_API_KEY is required for whisper-groq");
1935
- const mp3Path = `${options.intermediatesDir}/audio.mp3`;
1936
- if (!(0, import_node_fs4.existsSync)(mp3Path) || options.force) {
1937
- await extractAudio(options.input, mp3Path, { format: "mp3", bitrate: "64k" });
1938
+ if (!(0, import_node_fs4.existsSync)(audioPath) || forceAll) {
1939
+ await extractAudio(options.input, audioPath, AUDIO_OPTS);
1938
1940
  }
1939
1941
  const { readFile: readFile2 } = await import("fs/promises");
1940
- const buf = await readFile2(mp3Path);
1942
+ const buf = await readFile2(audioPath);
1941
1943
  const groq = new WhisperGroqClient(keys.groq);
1942
1944
  asrResult = await groq.transcribe(buf);
1943
1945
  writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);