offmute-v2 0.0.3 → 0.0.5
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 +55 -49
- package/dist/cli.cjs +94 -40
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +95 -41
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +89 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +90 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,17 +28,19 @@ and **fuses** them.
|
|
|
28
28
|
export GEMINI_API_KEY=... # multimodal understanding (or GOOGLE_API_KEY)
|
|
29
29
|
export ASSEMBLYAI_API_KEY=... # word-level timing
|
|
30
30
|
|
|
31
|
-
npx offmute-v2 meeting.mp4
|
|
32
|
-
# → meeting.
|
|
31
|
+
npx offmute-v2 meeting.mp4 --instructions "Panel of founders; label them by name."
|
|
32
|
+
# → meeting.md (written right next to meeting.mp4)
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
That's it. `bunx offmute-v2 meeting.mp4` works too.
|
|
36
36
|
|
|
37
37
|
## What you get
|
|
38
38
|
|
|
39
|
-
A clean, sub-second-aligned, speaker-labelled transcript with tone
|
|
39
|
+
A clean, sub-second-aligned, speaker-labelled transcript with tone. By default offmute-v2 writes a
|
|
40
|
+
**single `meeting.md` next to your input file** — add `--formats srt,md,json` (and/or `-o <dir>`) for
|
|
41
|
+
SubRip subtitles and JSON. The same content, three ways:
|
|
40
42
|
|
|
41
|
-
**`meeting.srt`** (drop straight onto the video):
|
|
43
|
+
**`meeting.srt`** (`--formats srt` — drop straight onto the video):
|
|
42
44
|
|
|
43
45
|
```srt
|
|
44
46
|
1
|
|
@@ -50,34 +52,36 @@ Speaker D: GPU
|
|
|
50
52
|
Presenter: And I'm inspired. I think I'm going to apply to NTU this fall. (confident, joking)
|
|
51
53
|
```
|
|
52
54
|
|
|
53
|
-
**`meeting.md`** (skimmable, grouped by speaker, with talk-time):
|
|
55
|
+
**`meeting.md`** (the **default** — skimmable, grouped by speaker, with talk-time):
|
|
54
56
|
|
|
55
57
|
```markdown
|
|
56
|
-
|
|
58
|
+
_Duration: 1914s · Speakers: 5_
|
|
57
59
|
|
|
58
60
|
## Speakers
|
|
61
|
+
|
|
59
62
|
- **Presenter** (1461s)
|
|
60
|
-
- **Speaker B** (97s)
|
|
63
|
+
- **Speaker B** (97s) · **Speaker C** (87s) · ...
|
|
61
64
|
|
|
62
65
|
## Transcript
|
|
66
|
+
|
|
63
67
|
[00:00] **Speaker D**: GPU
|
|
64
|
-
[00:01] **Presenter**
|
|
68
|
+
[00:01] **Presenter** _(confident, joking)_: And I'm inspired. I think I'm going to apply to NTU this fall.
|
|
65
69
|
```
|
|
66
70
|
|
|
67
|
-
**`meeting.json`** — every segment with `start`/`end`, `speaker`, `text`,
|
|
68
|
-
`confidence`, and word-level timings — for downstream tooling.
|
|
71
|
+
**`meeting.json`** (`--formats json`) — every segment with `start`/`end`, `speaker`, `text`,
|
|
72
|
+
`tone[]`, `timingSource`, `confidence`, and word-level timings — for downstream tooling.
|
|
69
73
|
|
|
70
74
|
## Why it's accurate
|
|
71
75
|
|
|
72
|
-
LLMs are brilliant at
|
|
76
|
+
LLMs are brilliant at _understanding_ speech (who's talking, through interruptions, in a crowd,
|
|
73
77
|
with tone) but [terrible at timestamps](#how-it-works). ASR models are the opposite: sub-second
|
|
74
78
|
timing, but mediocre diarization and no sense of tone. offmute-v2 runs **both** and marries them:
|
|
75
79
|
|
|
76
|
-
| Job
|
|
77
|
-
|
|
78
|
-
| **WHO / HOW** — speakers, names, tone, hard audio | multimodal **LLM** (Gemini)
|
|
79
|
-
| **WHEN** — word-level timestamps
|
|
80
|
-
| **fuse**
|
|
80
|
+
| Job | Tool | Why |
|
|
81
|
+
| ------------------------------------------------- | ----------------------------------- | --------------------------------------------------------------------- |
|
|
82
|
+
| **WHO / HOW** — speakers, names, tone, hard audio | multimodal **LLM** (Gemini) | infers names from context, hears tone, handles crowds & interruptions |
|
|
83
|
+
| **WHEN** — word-level timestamps | **ASR** (AssemblyAI / Groq Whisper) | sub-second accurate; LLM timestamps drift _minutes_ over a long file |
|
|
84
|
+
| **fuse** | edit-distance **alignment** | transfers the ASR's clock onto the LLM's richer words |
|
|
81
85
|
|
|
82
86
|
```mermaid
|
|
83
87
|
flowchart LR
|
|
@@ -107,10 +111,11 @@ and an independent re-score live in [`docs/`](#receipts--how-this-repo-was-built
|
|
|
107
111
|
- 🎬 **Video-aware** — samples keyframes for visual context (who's on screen, demos, slides).
|
|
108
112
|
- ⚡ **Chunked + concurrent** — long files are split with overlap and stitched back with
|
|
109
113
|
**ownership-partition** dedup (no double-printed sentences at chunk seams).
|
|
110
|
-
- ♻️ **Resumable & stoppable** — every stage caches to disk
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
- ♻️ **Resumable & stoppable** — every stage caches to disk (in the **OS temp dir** by default;
|
|
115
|
+
the path is printed each run, and `-i <dir>` keeps it wherever you like). Re-runs skip finished
|
|
116
|
+
work, Ctrl-C leaves partials. The cache is keyed on the input **and** the config, so changing
|
|
117
|
+
`--model` never serves you a stale transcript.
|
|
118
|
+
- 🔀 **Pluggable providers** — Gemini for the LLM; AssemblyAI _or_ Groq Whisper for timing.
|
|
114
119
|
- 🌐 **Runs in the browser** — a pure, node-free core + `fetch` providers + ffmpeg.wasm.
|
|
115
120
|
- 🔎 **Fully inspectable** — every LLM prompt+response is logged to `llm-calls.jsonl`; all
|
|
116
121
|
intermediates are plain JSON.
|
|
@@ -123,20 +128,20 @@ and an independent re-score live in [`docs/`](#receipts--how-this-repo-was-built
|
|
|
123
128
|
npx offmute-v2 <input> [options]
|
|
124
129
|
```
|
|
125
130
|
|
|
126
|
-
| Option
|
|
127
|
-
|
|
128
|
-
| `-o, --output <dir>`
|
|
129
|
-
| `--instructions <text>`
|
|
130
|
-
| `--model <name>`
|
|
131
|
-
| `--level <1\|2\|3>`
|
|
132
|
-
| `--timestamped <p>`
|
|
133
|
-
| `--reasoner <name>`
|
|
134
|
-
| `--chunk-seconds <n>`
|
|
135
|
-
| `--formats <list>`
|
|
136
|
-
| `--passes <list>`
|
|
137
|
-
| `--force`
|
|
138
|
-
| `--only-chunk <n>`
|
|
139
|
-
| `-i, --intermediates <dir>` | auto
|
|
131
|
+
| Option | Default | Description |
|
|
132
|
+
| --------------------------- | ------------------ | ------------------------------------------------------------------------------------- |
|
|
133
|
+
| `-o, --output <dir>` | _next to input_ | where to write the transcript(s); default is the input file's own folder |
|
|
134
|
+
| `--instructions <text>` | – | guide diarization / labelling, e.g. `"host is Alice; group callers as 'Caller'"` |
|
|
135
|
+
| `--model <name>` | `gemini-3.1-pro-preview` | multimodal LLM; use `gemini-2.5-flash` / `gemini-flash-latest` for faster/cheaper runs |
|
|
136
|
+
| `--level <1\|2\|3>` | `2` | 1 = separation · 2 = stable anon · 3 = identify names |
|
|
137
|
+
| `--timestamped <p>` | `assemblyai` | timing provider: `assemblyai` · `whisper-groq` · `none` |
|
|
138
|
+
| `--reasoner <name>` | `deepseek-chat` | text model for the name-identification pass (level 3) |
|
|
139
|
+
| `--chunk-seconds <n>` | `600` | chunk length · `--overlap-seconds` (default `60`) |
|
|
140
|
+
| `--formats <list>` | `md` | which outputs to write (`srt`, `md`, `json`) |
|
|
141
|
+
| `--passes <list>` | all | run/resume a subset of stages |
|
|
142
|
+
| `--force` | – | ignore caches and recompute |
|
|
143
|
+
| `--only-chunk <n>` | – | process a single chunk (debugging) |
|
|
144
|
+
| `-i, --intermediates <dir>` | auto | cache dir (auto-derived per input) |
|
|
140
145
|
|
|
141
146
|
```bash
|
|
142
147
|
npx offmute-v2 meeting.mp4 --level 3 # name the speakers
|
|
@@ -147,18 +152,19 @@ npx offmute-v2 meeting.mp4 --passes align,consistency,finalize # resume from c
|
|
|
147
152
|
|
|
148
153
|
### Library
|
|
149
154
|
|
|
150
|
-
The primary line takes a single options object
|
|
155
|
+
The primary line takes a single options object. Only `input` is required — `outputDir` defaults to
|
|
156
|
+
the input file's folder and `formats` defaults to `["md"]`:
|
|
151
157
|
|
|
152
158
|
```ts
|
|
153
159
|
import { transcribe } from "offmute-v2";
|
|
154
160
|
|
|
155
161
|
const { segments, speakers, metadata } = await transcribe({
|
|
156
162
|
input: "meeting.mp4",
|
|
157
|
-
outputDir: "./out",
|
|
163
|
+
// outputDir: "./out", // optional — defaults next to the input
|
|
158
164
|
model: "gemini-flash-latest",
|
|
159
165
|
level: 3,
|
|
160
166
|
instructions: "Three-person panel; label by name.",
|
|
161
|
-
formats: ["srt", "md", "json"],
|
|
167
|
+
formats: ["srt", "md", "json"], // optional — defaults to ["md"]
|
|
162
168
|
apiKeys: { gemini: "...", assemblyai: "..." }, // optional; falls back to env
|
|
163
169
|
});
|
|
164
170
|
|
|
@@ -180,8 +186,8 @@ node-only imports**, so it bundles tiny and runs in the browser via `offmute-v2/
|
|
|
180
186
|
A multi-stage pipeline where each stage persists a JSON intermediate (so it's resumable and
|
|
181
187
|
debuggable):
|
|
182
188
|
|
|
183
|
-
1. **preprocess** — ffmpeg → 16 kHz
|
|
184
|
-
|
|
189
|
+
1. **preprocess** — ffmpeg → compact mono 16 kHz **mp3** + scene-aware keyframes (a 9.6 GB `.mov`
|
|
190
|
+
becomes a few MB of audio in seconds — transparent for speech, but a fraction of lossless size).
|
|
185
191
|
2. **describe** — a quick multimodal pass builds a meeting summary + speaker roster to prime
|
|
186
192
|
transcription.
|
|
187
193
|
3. **llm-transcribe** — each chunk goes to the LLM for verbatim text, diarization, and tone. Output
|
|
@@ -194,14 +200,14 @@ debuggable):
|
|
|
194
200
|
so nothing is dropped.
|
|
195
201
|
7. **consistency** — the ASR voice clusters act as a global backbone, merging the LLM's per-chunk
|
|
196
202
|
labels into stable speakers (and fixing ASR over-splits).
|
|
197
|
-
8. **identify**
|
|
203
|
+
8. **identify** _(level 3)_ — a reasoning model maps `Speaker A` → real names using context + a
|
|
198
204
|
voice-cluster hint.
|
|
199
205
|
9. **finalize** — overlap fixes, clamping, readable subtitle-sized blocks, and SRT/MD/JSON.
|
|
200
206
|
|
|
201
207
|
> [!NOTE]
|
|
202
208
|
> The hard parts of this problem are **chunk overlap** and **alignment**. offmute-v2 partitions
|
|
203
|
-
> overlap by
|
|
204
|
-
> double-printed at seams, and aligns the
|
|
209
|
+
> overlap by _ownership_ (each word is emitted by exactly one chunk) so sentences are never
|
|
210
|
+
> double-printed at seams, and aligns the _whole_ chunk in one DP pass so common words like "it"
|
|
205
211
|
> can't mis-match to a later occurrence.
|
|
206
212
|
|
|
207
213
|
## Built twice, in the open: GLM vs Opus
|
|
@@ -211,11 +217,11 @@ prompt**, by two different models running in **Claude Code** — a head-to-head
|
|
|
211
217
|
AI-resistant build (fusing the ideas of [offmute], [meeting-diary], and [ipgu] into one
|
|
212
218
|
timestamp-accurate diarizer):
|
|
213
219
|
|
|
214
|
-
| Branch
|
|
215
|
-
|
|
220
|
+
| Branch | Built by | npm tag | What it is |
|
|
221
|
+
| ----------------------------- | ---------------------------- | ------------------- | ---------------------------------------------- |
|
|
216
222
|
| [`master`](../../tree/master) | GLM line + post-launch fixes | `offmute-v2@latest` | the daily-driven, hardened build (this README) |
|
|
217
|
-
| [`glm`](../../tree/glm)
|
|
218
|
-
| [`opus`](../../tree/opus)
|
|
223
|
+
| [`glm`](../../tree/glm) | **GLM-5.2** | `offmute-v2@glm` | the frozen GLM experiment build |
|
|
224
|
+
| [`opus`](../../tree/opus) | **Claude Opus 4.8** | `offmute-v2@opus` | the frozen Opus experiment build |
|
|
219
225
|
|
|
220
226
|
```bash
|
|
221
227
|
npx offmute-v2@glm meeting.mp4 # the GLM build, exactly as submitted
|
|
@@ -241,10 +247,10 @@ Everything is open for inspection:
|
|
|
241
247
|
## Diarization levels
|
|
242
248
|
|
|
243
249
|
1. **Separation** — who speaks when.
|
|
244
|
-
2. **Anonymous-consistent** — `Speaker A/B`, stable across the whole file
|
|
250
|
+
2. **Anonymous-consistent** — `Speaker A/B`, stable across the whole file _(default)_.
|
|
245
251
|
3. **Identification** — real names inferred from context (needs `DEEPSEEK_API_KEY`, or point
|
|
246
|
-
`--reasoner` at another provider). Use `--instructions` to steer (e.g.
|
|
247
|
-
host is 'Audience'"
|
|
252
|
+
`--reasoner` at another provider). Use `--instructions` to steer (e.g. _"everyone except the
|
|
253
|
+
host is 'Audience'"_).
|
|
248
254
|
|
|
249
255
|
## Requirements
|
|
250
256
|
|
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",
|
|
@@ -53,12 +54,14 @@ var MODELS = {
|
|
|
53
54
|
gemini25Pro: "gemini-2.5-pro",
|
|
54
55
|
gemini25Flash: "gemini-2.5-flash",
|
|
55
56
|
gemini3Pro: "gemini-3-pro-preview",
|
|
57
|
+
gemini31Pro: "gemini-3.1-pro-preview",
|
|
58
|
+
geminiFlashLatest: "gemini-flash-latest",
|
|
56
59
|
deepseek: "deepseek-chat",
|
|
57
60
|
deepseekReasoner: "deepseek-reasoner",
|
|
58
61
|
gpt4o: "gpt-4o",
|
|
59
62
|
claudeSonnet: "claude-sonnet-4-5"
|
|
60
63
|
};
|
|
61
|
-
var DEFAULT_TRANSCRIBE_MODEL = MODELS.
|
|
64
|
+
var DEFAULT_TRANSCRIBE_MODEL = MODELS.gemini31Pro;
|
|
62
65
|
var DEFAULT_REASONER_MODEL = MODELS.deepseek;
|
|
63
66
|
function resolveKeys(injected) {
|
|
64
67
|
const env = process.env;
|
|
@@ -75,7 +78,8 @@ function resolveKeys(injected) {
|
|
|
75
78
|
function resolveOptions(opts2) {
|
|
76
79
|
return {
|
|
77
80
|
input: opts2.input,
|
|
78
|
-
|
|
81
|
+
// Default: write next to the input file (e.g. meeting.md beside meeting.mp4) — no ./output folder.
|
|
82
|
+
outputDir: opts2.outputDir ?? (0, import_node_path.dirname)((0, import_node_path.resolve)(opts2.input)),
|
|
79
83
|
intermediatesDir: opts2.intermediatesDir ?? deriveIntermediatesDir(opts2.input),
|
|
80
84
|
instructions: opts2.instructions,
|
|
81
85
|
knownSpeakers: opts2.knownSpeakers,
|
|
@@ -95,7 +99,7 @@ function resolveOptions(opts2) {
|
|
|
95
99
|
screenshotCount: opts2.screenshotCount ?? 6,
|
|
96
100
|
concurrency: opts2.concurrency ?? 4,
|
|
97
101
|
saveIntermediates: opts2.saveIntermediates ?? true,
|
|
98
|
-
formats: opts2.formats ?? ["
|
|
102
|
+
formats: opts2.formats ?? ["md"],
|
|
99
103
|
diarizationLevel: opts2.diarizationLevel ?? 2,
|
|
100
104
|
apiKeys: opts2.apiKeys,
|
|
101
105
|
model: opts2.model,
|
|
@@ -112,7 +116,7 @@ function deriveIntermediatesDir(input2) {
|
|
|
112
116
|
const abs = (0, import_node_path.resolve)(input2);
|
|
113
117
|
const hash = (0, import_node_crypto.createHash)("sha1").update(abs).digest("hex").slice(0, 8);
|
|
114
118
|
const base = (0, import_node_path.basename)(input2, extOf(input2)) || "input";
|
|
115
|
-
return `${(0,
|
|
119
|
+
return `${(0, import_node_os.tmpdir)()}/offmute-v2-${base}-${hash}`;
|
|
116
120
|
}
|
|
117
121
|
function extOf(p) {
|
|
118
122
|
const i = p.lastIndexOf(".");
|
|
@@ -199,7 +203,7 @@ var import_node_child_process = require("child_process");
|
|
|
199
203
|
var import_promises = require("fs/promises");
|
|
200
204
|
var import_node_path2 = require("path");
|
|
201
205
|
function run(cmd, args, _opts = {}) {
|
|
202
|
-
return new Promise((
|
|
206
|
+
return new Promise((resolve3, reject) => {
|
|
203
207
|
const child = (0, import_node_child_process.spawn)(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
204
208
|
let stdout = "";
|
|
205
209
|
let stderr = "";
|
|
@@ -207,7 +211,7 @@ function run(cmd, args, _opts = {}) {
|
|
|
207
211
|
child.stderr.on("data", (d) => stderr += d.toString());
|
|
208
212
|
child.on("error", reject);
|
|
209
213
|
child.on("close", (code) => {
|
|
210
|
-
if (code === 0)
|
|
214
|
+
if (code === 0) resolve3({ stdout, stderr });
|
|
211
215
|
else {
|
|
212
216
|
const tail = stderr.slice(-800);
|
|
213
217
|
reject(new Error(`${cmd} exited ${code}: ${tail}`));
|
|
@@ -1723,10 +1727,9 @@ function has(passes2, p) {
|
|
|
1723
1727
|
}
|
|
1724
1728
|
async function transcribe(opts2) {
|
|
1725
1729
|
if (!opts2 || typeof opts2.input !== "string" || opts2.input.length === 0) {
|
|
1726
|
-
throw new Error(
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
throw new Error("transcribe(options): 'outputDir' (directory for outputs) is required");
|
|
1730
|
+
throw new Error(
|
|
1731
|
+
"transcribe(options): 'input' (path to the audio/video file) is required"
|
|
1732
|
+
);
|
|
1730
1733
|
}
|
|
1731
1734
|
const options = resolveOptions(opts2);
|
|
1732
1735
|
const keys = resolveKeys(options.apiKeys);
|
|
@@ -1736,11 +1739,16 @@ async function transcribe(opts2) {
|
|
|
1736
1739
|
}
|
|
1737
1740
|
(0, import_node_fs4.mkdirSync)(options.intermediatesDir, { recursive: true });
|
|
1738
1741
|
(0, import_node_fs4.mkdirSync)(options.outputDir, { recursive: true });
|
|
1742
|
+
logger.info(
|
|
1743
|
+
`intermediates: ${(0, import_node_path5.resolve)(options.intermediatesDir)} (file://${(0, import_node_path5.resolve)(options.intermediatesDir)})`
|
|
1744
|
+
);
|
|
1739
1745
|
setLlmLogPath(options.llmLog ? `${options.intermediatesDir}/llm-calls.jsonl` : null);
|
|
1740
1746
|
const sourcePath = `${options.intermediatesDir}/source.json`;
|
|
1741
1747
|
const sig = inputSignature(options.input);
|
|
1742
1748
|
const cfgSig = configSignature(opts2);
|
|
1743
|
-
const prevSig = readJson(
|
|
1749
|
+
const prevSig = readJson(
|
|
1750
|
+
sourcePath
|
|
1751
|
+
);
|
|
1744
1752
|
const inputChanged = !prevSig || prevSig.signature !== sig;
|
|
1745
1753
|
const configChanged = !prevSig || prevSig.config !== cfgSig;
|
|
1746
1754
|
if (inputChanged && prevSig) {
|
|
@@ -1779,7 +1787,8 @@ async function transcribe(opts2) {
|
|
|
1779
1787
|
}
|
|
1780
1788
|
}
|
|
1781
1789
|
let probeInfo = null;
|
|
1782
|
-
const
|
|
1790
|
+
const AUDIO_OPTS = { format: "mp3", bitrate: "64k" };
|
|
1791
|
+
const audioPath = `${options.intermediatesDir}/audio.mp3`;
|
|
1783
1792
|
const probePath = `${options.intermediatesDir}/probe.json`;
|
|
1784
1793
|
if (has(passes2, "preprocess")) {
|
|
1785
1794
|
logger.info("=== preprocess ===");
|
|
@@ -1789,8 +1798,8 @@ async function transcribe(opts2) {
|
|
|
1789
1798
|
writeJson(probePath, probeInfo);
|
|
1790
1799
|
}
|
|
1791
1800
|
if (!(0, import_node_fs4.existsSync)(audioPath) || forceAll) {
|
|
1792
|
-
logger.info("extracting audio (mono 16kHz
|
|
1793
|
-
await extractAudio(options.input, audioPath,
|
|
1801
|
+
logger.info("extracting audio (mono 16kHz mp3)...");
|
|
1802
|
+
await extractAudio(options.input, audioPath, AUDIO_OPTS);
|
|
1794
1803
|
}
|
|
1795
1804
|
if (probeInfo.hasVideo) {
|
|
1796
1805
|
const kfDir = `${options.intermediatesDir}/keyframes`;
|
|
@@ -1811,9 +1820,9 @@ async function transcribe(opts2) {
|
|
|
1811
1820
|
if (!description) {
|
|
1812
1821
|
logger.info("=== describe ===");
|
|
1813
1822
|
const client = new GeminiClient(keys.gemini);
|
|
1814
|
-
const samplePath = `${options.intermediatesDir}/sample.
|
|
1823
|
+
const samplePath = `${options.intermediatesDir}/sample.mp3`;
|
|
1815
1824
|
if (!(0, import_node_fs4.existsSync)(samplePath) || forceAll) {
|
|
1816
|
-
await extractChunk(audioPath, samplePath, 0, Math.min(300, duration),
|
|
1825
|
+
await extractChunk(audioPath, samplePath, 0, Math.min(300, duration), AUDIO_OPTS);
|
|
1817
1826
|
}
|
|
1818
1827
|
const files = [{ path: samplePath }];
|
|
1819
1828
|
const kfDir = `${options.intermediatesDir}/keyframes`;
|
|
@@ -1823,7 +1832,13 @@ async function transcribe(opts2) {
|
|
|
1823
1832
|
if ((0, import_node_fs4.existsSync)(p)) files.push({ path: p });
|
|
1824
1833
|
}
|
|
1825
1834
|
}
|
|
1826
|
-
description = await describeMeeting(
|
|
1835
|
+
description = await describeMeeting(
|
|
1836
|
+
client,
|
|
1837
|
+
models.transcribe,
|
|
1838
|
+
files,
|
|
1839
|
+
(0, import_node_path5.basename)(options.input),
|
|
1840
|
+
options.instructions
|
|
1841
|
+
);
|
|
1827
1842
|
writeJson(descPath, description);
|
|
1828
1843
|
logger.info(`description: ${description.description.slice(0, 120)}...`);
|
|
1829
1844
|
}
|
|
@@ -1836,27 +1851,39 @@ async function transcribe(opts2) {
|
|
|
1836
1851
|
let silences = [];
|
|
1837
1852
|
try {
|
|
1838
1853
|
silences = await detectSilence(audioPath, { noiseDb: -15, minDuration: 0.3 });
|
|
1839
|
-
if (silences.length < 3)
|
|
1854
|
+
if (silences.length < 3)
|
|
1855
|
+
silences = await detectSilence(audioPath, { noiseDb: -12, minDuration: 0.25 });
|
|
1840
1856
|
} catch {
|
|
1841
1857
|
}
|
|
1842
1858
|
chunks = planChunks(duration, options.chunkDurationSec, options.chunkOverlapSec);
|
|
1843
1859
|
if (silences.length > 3) {
|
|
1844
1860
|
chunks = chunks.map((c) => {
|
|
1845
|
-
const snapped = snapToSilence(
|
|
1861
|
+
const snapped = snapToSilence(
|
|
1862
|
+
c.start,
|
|
1863
|
+
silences,
|
|
1864
|
+
Math.min(10, options.chunkOverlapSec / 2)
|
|
1865
|
+
);
|
|
1846
1866
|
return { ...c, start: snapped, trustedStart: snapped + c.overlapWithPrevious };
|
|
1847
1867
|
});
|
|
1848
1868
|
}
|
|
1849
1869
|
}
|
|
1850
1870
|
const tagWith = (r, chunk) => ({
|
|
1851
1871
|
...r,
|
|
1852
|
-
segments: r.segments.map((s) => ({
|
|
1872
|
+
segments: r.segments.map((s) => ({
|
|
1873
|
+
...s,
|
|
1874
|
+
chunkIndex: chunk.index,
|
|
1875
|
+
trustedStart: chunk.trustedStart
|
|
1876
|
+
}))
|
|
1853
1877
|
});
|
|
1854
1878
|
let llmChunkResults = [];
|
|
1855
1879
|
if (has(passes2, "llm-transcribe")) {
|
|
1856
1880
|
logger.info("=== llm-transcribe ===");
|
|
1857
1881
|
let runChunks = chunks;
|
|
1858
|
-
if (options.onlyChunk !== void 0)
|
|
1859
|
-
|
|
1882
|
+
if (options.onlyChunk !== void 0)
|
|
1883
|
+
runChunks = chunks.filter((c) => c.index === options.onlyChunk);
|
|
1884
|
+
logger.info(
|
|
1885
|
+
`${runChunks.length} chunks (${options.chunkDurationSec}s, ${options.chunkOverlapSec}s overlap)`
|
|
1886
|
+
);
|
|
1860
1887
|
const client = new GeminiClient(keys.gemini);
|
|
1861
1888
|
const llmDir = `${options.intermediatesDir}/llm`;
|
|
1862
1889
|
(0, import_node_fs4.mkdirSync)(llmDir, { recursive: true });
|
|
@@ -1867,9 +1894,9 @@ async function transcribe(opts2) {
|
|
|
1867
1894
|
logger.info(`chunk ${chunk.index}: cached (${cached.segments.length} segments)`);
|
|
1868
1895
|
return tagWith(cached, chunk);
|
|
1869
1896
|
}
|
|
1870
|
-
const chunkPath = `${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}.
|
|
1897
|
+
const chunkPath = `${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}.mp3`;
|
|
1871
1898
|
if (!(0, import_node_fs4.existsSync)(chunkPath) || forceAll) {
|
|
1872
|
-
await extractChunk(audioPath, chunkPath, chunk.start, chunk.end,
|
|
1899
|
+
await extractChunk(audioPath, chunkPath, chunk.start, chunk.end, AUDIO_OPTS);
|
|
1873
1900
|
}
|
|
1874
1901
|
let previousTail;
|
|
1875
1902
|
if (chunk.index > 0) {
|
|
@@ -1880,7 +1907,9 @@ async function transcribe(opts2) {
|
|
|
1880
1907
|
previousTail = prev.segments.slice(-6).map((s) => `${s.speaker}: ${s.text}`).join("\n");
|
|
1881
1908
|
}
|
|
1882
1909
|
}
|
|
1883
|
-
logger.info(
|
|
1910
|
+
logger.info(
|
|
1911
|
+
`chunk ${chunk.index}: transcribing [${chunk.start.toFixed(0)}-${chunk.end.toFixed(0)}]s...`
|
|
1912
|
+
);
|
|
1884
1913
|
const result2 = await transcribeChunk(
|
|
1885
1914
|
client,
|
|
1886
1915
|
models.transcribe,
|
|
@@ -1897,7 +1926,10 @@ async function transcribe(opts2) {
|
|
|
1897
1926
|
{ chunkDurationSec: chunk.end - chunk.start, validationRetries: 1 }
|
|
1898
1927
|
);
|
|
1899
1928
|
writeJson(parsedPath, result2);
|
|
1900
|
-
(0, import_node_fs4.writeFileSync)(
|
|
1929
|
+
(0, import_node_fs4.writeFileSync)(
|
|
1930
|
+
`${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}_raw.json`,
|
|
1931
|
+
result2.raw
|
|
1932
|
+
);
|
|
1901
1933
|
return tagWith(result2, chunk);
|
|
1902
1934
|
});
|
|
1903
1935
|
const errored = llmChunkResults.filter((r) => r.error);
|
|
@@ -1932,19 +1964,24 @@ async function transcribe(opts2) {
|
|
|
1932
1964
|
if (provider === "whisper-groq") {
|
|
1933
1965
|
logger.info("=== timestamped (Groq Whisper \u2014 no diarization) ===");
|
|
1934
1966
|
if (!keys.groq) throw new Error("GROQ_API_KEY is required for whisper-groq");
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
await extractAudio(options.input, mp3Path, { format: "mp3", bitrate: "64k" });
|
|
1967
|
+
if (!(0, import_node_fs4.existsSync)(audioPath) || forceAll) {
|
|
1968
|
+
await extractAudio(options.input, audioPath, AUDIO_OPTS);
|
|
1938
1969
|
}
|
|
1939
1970
|
const { readFile: readFile2 } = await import("fs/promises");
|
|
1940
|
-
const buf = await readFile2(
|
|
1971
|
+
const buf = await readFile2(audioPath);
|
|
1941
1972
|
const groq = new WhisperGroqClient(keys.groq);
|
|
1942
1973
|
asrResult = await groq.transcribe(buf);
|
|
1943
1974
|
writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);
|
|
1944
1975
|
} else {
|
|
1945
1976
|
logger.info("=== timestamped (AssemblyAI) ===");
|
|
1946
|
-
if (!keys.assemblyai)
|
|
1947
|
-
|
|
1977
|
+
if (!keys.assemblyai)
|
|
1978
|
+
throw new Error(
|
|
1979
|
+
"ASSEMBLYAI_API_KEY is required for the timestamped pass (or use --timestamped whisper-groq)"
|
|
1980
|
+
);
|
|
1981
|
+
const aai = new AssemblyAIProvider({
|
|
1982
|
+
apiKey: keys.assemblyai,
|
|
1983
|
+
cacheDir: `${options.intermediatesDir}/assemblyai`
|
|
1984
|
+
});
|
|
1948
1985
|
asrResult = await aai.transcribe(audioPath);
|
|
1949
1986
|
writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);
|
|
1950
1987
|
}
|
|
@@ -1988,7 +2025,11 @@ async function transcribe(opts2) {
|
|
|
1988
2025
|
}
|
|
1989
2026
|
if (options.diarizationLevel >= 3 && has(passes2, "identify") && keys.deepseek && description) {
|
|
1990
2027
|
logger.info("=== identify (DeepSeek) ===");
|
|
1991
|
-
const dsClient = OpenAICompatClient.fromProvider(
|
|
2028
|
+
const dsClient = OpenAICompatClient.fromProvider(
|
|
2029
|
+
"deepseek",
|
|
2030
|
+
keys.deepseek,
|
|
2031
|
+
models.reasoner
|
|
2032
|
+
);
|
|
1992
2033
|
const id = await identifySpeakers(
|
|
1993
2034
|
dsClient,
|
|
1994
2035
|
models.reasoner,
|
|
@@ -1997,7 +2038,9 @@ async function transcribe(opts2) {
|
|
|
1997
2038
|
description.roster,
|
|
1998
2039
|
options.knownSpeakers
|
|
1999
2040
|
);
|
|
2000
|
-
logger.info(
|
|
2041
|
+
logger.info(
|
|
2042
|
+
`identified ${Object.keys(id.nameMap).length} speakers: ${JSON.stringify(id.nameMap)}`
|
|
2043
|
+
);
|
|
2001
2044
|
writeJson(`${options.intermediatesDir}/identified.json`, id);
|
|
2002
2045
|
segments = segments.map(
|
|
2003
2046
|
(s) => id.nameMap[s.speaker] ? { ...s, speakerName: id.nameMap[s.speaker] } : s
|
|
@@ -2028,9 +2071,18 @@ async function transcribe(opts2) {
|
|
|
2028
2071
|
const result = { segments: finalSegments, speakers, metadata };
|
|
2029
2072
|
for (const fmt of options.formats) {
|
|
2030
2073
|
const base = (0, import_node_path5.basename)(options.input, ext(options.input));
|
|
2031
|
-
if (fmt === "srt")
|
|
2032
|
-
|
|
2033
|
-
|
|
2074
|
+
if (fmt === "srt")
|
|
2075
|
+
(0, import_node_fs4.writeFileSync)(
|
|
2076
|
+
`${options.outputDir}/${base}.srt`,
|
|
2077
|
+
formatSrt(result, { title: base })
|
|
2078
|
+
);
|
|
2079
|
+
if (fmt === "md")
|
|
2080
|
+
(0, import_node_fs4.writeFileSync)(
|
|
2081
|
+
`${options.outputDir}/${base}.md`,
|
|
2082
|
+
formatMarkdown(result, { title: base })
|
|
2083
|
+
);
|
|
2084
|
+
if (fmt === "json")
|
|
2085
|
+
(0, import_node_fs4.writeFileSync)(`${options.outputDir}/${base}.json`, formatJson(result));
|
|
2034
2086
|
}
|
|
2035
2087
|
logger.info(`outputs written to ${options.outputDir}`);
|
|
2036
2088
|
return result;
|
|
@@ -2049,10 +2101,10 @@ try {
|
|
|
2049
2101
|
} catch {
|
|
2050
2102
|
}
|
|
2051
2103
|
var program = new import_commander.Command();
|
|
2052
|
-
program.name("offmute-v2").description("Diarized meeting transcription with multimodal LLMs + timestamped alignment.").version(packageVersion).argument("<input>", "input video/audio file").option("-o, --output <dir>", "output directory
|
|
2104
|
+
program.name("offmute-v2").description("Diarized meeting transcription with multimodal LLMs + timestamped alignment.").version(packageVersion).argument("<input>", "input video/audio file").option("-o, --output <dir>", "output directory (default: next to the input file)").option(
|
|
2053
2105
|
"-i, --intermediates <dir>",
|
|
2054
2106
|
"intermediates directory (default: auto-derived per input file so caches never collide)"
|
|
2055
|
-
).option("--instructions <text>", "custom instructions for the LLM").option("--passes <list>", "comma-separated passes to run").option("--chunk-seconds <n>", "chunk duration in seconds", "600").option("--overlap-seconds <n>", "chunk overlap in seconds", "60").option("--concurrency <n>", "max concurrent chunk requests", "4").option("--screenshots <n>", "number of keyframes to extract (video)", "6").option("--formats <list>", "output formats: srt,md,json
|
|
2107
|
+
).option("--instructions <text>", "custom instructions for the LLM").option("--passes <list>", "comma-separated passes to run").option("--chunk-seconds <n>", "chunk duration in seconds", "600").option("--overlap-seconds <n>", "chunk overlap in seconds", "60").option("--concurrency <n>", "max concurrent chunk requests", "4").option("--screenshots <n>", "number of keyframes to extract (video)", "6").option("--formats <list>", "output formats: srt,md,json (default: md)").option("--level <1|2|3>", "diarization level (1=separation, 2=consistent, 3=identify)", "2").option("--model <name>", "override transcription model").option("--reasoner <name>", "override text-reasoner model (default deepseek-chat)").option("--timestamped <provider>", "timestamped provider (assemblyai|whisper-groq|none)").option("--force", "force reprocess cached chunk outputs", false).option("--only-chunk <n>", "process only a specific chunk index (debug)").option("--save-intermediates", "save intermediates (default true)", true).option("--no-progress", "hide progress output").option("--no-llm-log", "disable per-call LLM logging to <intermediates>/llm-calls.jsonl").option("--log-level <level>", "debug | info | warn | error", "info");
|
|
2056
2108
|
program.parse();
|
|
2057
2109
|
var opts = program.opts();
|
|
2058
2110
|
var input = program.args[0];
|
|
@@ -2065,6 +2117,7 @@ var level = parseInt(opts.level, 10);
|
|
|
2065
2117
|
transcribe({
|
|
2066
2118
|
input,
|
|
2067
2119
|
outputDir: opts.output,
|
|
2120
|
+
// undefined → defaults to the input file's directory
|
|
2068
2121
|
intermediatesDir: opts.intermediates,
|
|
2069
2122
|
instructions: opts.instructions,
|
|
2070
2123
|
passes,
|
|
@@ -2072,7 +2125,8 @@ transcribe({
|
|
|
2072
2125
|
chunkOverlapSec: parseInt(opts.overlapSeconds, 10),
|
|
2073
2126
|
concurrency: parseInt(opts.concurrency, 10),
|
|
2074
2127
|
screenshotCount: parseInt(opts.screenshots, 10),
|
|
2075
|
-
formats: opts.formats.split(","),
|
|
2128
|
+
formats: opts.formats ? opts.formats.split(",") : void 0,
|
|
2129
|
+
// undefined → defaults to ["md"]
|
|
2076
2130
|
diarizationLevel: level,
|
|
2077
2131
|
model: opts.model,
|
|
2078
2132
|
reasoner: opts.reasoner,
|