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/dist/cli.js CHANGED
@@ -13,6 +13,7 @@ import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } fro
13
13
  import { createHash } from "crypto";
14
14
  import { basename, dirname, resolve } from "path";
15
15
  import { statSync } from "fs";
16
+ import { tmpdir } from "os";
16
17
  var DEFAULT_PASSES = [
17
18
  "preprocess",
18
19
  "describe",
@@ -26,12 +27,14 @@ var MODELS = {
26
27
  gemini25Pro: "gemini-2.5-pro",
27
28
  gemini25Flash: "gemini-2.5-flash",
28
29
  gemini3Pro: "gemini-3-pro-preview",
30
+ gemini31Pro: "gemini-3.1-pro-preview",
31
+ geminiFlashLatest: "gemini-flash-latest",
29
32
  deepseek: "deepseek-chat",
30
33
  deepseekReasoner: "deepseek-reasoner",
31
34
  gpt4o: "gpt-4o",
32
35
  claudeSonnet: "claude-sonnet-4-5"
33
36
  };
34
- var DEFAULT_TRANSCRIBE_MODEL = MODELS.gemini25Flash;
37
+ var DEFAULT_TRANSCRIBE_MODEL = MODELS.gemini31Pro;
35
38
  var DEFAULT_REASONER_MODEL = MODELS.deepseek;
36
39
  function resolveKeys(injected) {
37
40
  const env = process.env;
@@ -48,7 +51,8 @@ function resolveKeys(injected) {
48
51
  function resolveOptions(opts2) {
49
52
  return {
50
53
  input: opts2.input,
51
- outputDir: opts2.outputDir,
54
+ // Default: write next to the input file (e.g. meeting.md beside meeting.mp4) — no ./output folder.
55
+ outputDir: opts2.outputDir ?? dirname(resolve(opts2.input)),
52
56
  intermediatesDir: opts2.intermediatesDir ?? deriveIntermediatesDir(opts2.input),
53
57
  instructions: opts2.instructions,
54
58
  knownSpeakers: opts2.knownSpeakers,
@@ -68,7 +72,7 @@ function resolveOptions(opts2) {
68
72
  screenshotCount: opts2.screenshotCount ?? 6,
69
73
  concurrency: opts2.concurrency ?? 4,
70
74
  saveIntermediates: opts2.saveIntermediates ?? true,
71
- formats: opts2.formats ?? ["srt", "md", "json"],
75
+ formats: opts2.formats ?? ["md"],
72
76
  diarizationLevel: opts2.diarizationLevel ?? 2,
73
77
  apiKeys: opts2.apiKeys,
74
78
  model: opts2.model,
@@ -85,7 +89,7 @@ function deriveIntermediatesDir(input2) {
85
89
  const abs = resolve(input2);
86
90
  const hash = createHash("sha1").update(abs).digest("hex").slice(0, 8);
87
91
  const base = basename(input2, extOf(input2)) || "input";
88
- return `${dirname(abs)}/.offmute-v2-${base}-${hash}`;
92
+ return `${tmpdir()}/offmute-v2-${base}-${hash}`;
89
93
  }
90
94
  function extOf(p) {
91
95
  const i = p.lastIndexOf(".");
@@ -172,7 +176,7 @@ import { spawn } from "child_process";
172
176
  import { mkdir } from "fs/promises";
173
177
  import { dirname as dirname2 } from "path";
174
178
  function run(cmd, args, _opts = {}) {
175
- return new Promise((resolve2, reject) => {
179
+ return new Promise((resolve3, reject) => {
176
180
  const child = spawn(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
177
181
  let stdout = "";
178
182
  let stderr = "";
@@ -180,7 +184,7 @@ function run(cmd, args, _opts = {}) {
180
184
  child.stderr.on("data", (d) => stderr += d.toString());
181
185
  child.on("error", reject);
182
186
  child.on("close", (code) => {
183
- if (code === 0) resolve2({ stdout, stderr });
187
+ if (code === 0) resolve3({ stdout, stderr });
184
188
  else {
185
189
  const tail = stderr.slice(-800);
186
190
  reject(new Error(`${cmd} exited ${code}: ${tail}`));
@@ -1665,7 +1669,7 @@ function formatJson(result) {
1665
1669
  }
1666
1670
 
1667
1671
  // src/core/pipeline.ts
1668
- import { basename as basename3 } from "path";
1672
+ import { basename as basename3, resolve as resolve2 } from "path";
1669
1673
  var JSON_OPTS = { encoding: "utf-8" };
1670
1674
  function readJson(p) {
1671
1675
  if (!existsSync2(p)) return null;
@@ -1696,10 +1700,9 @@ function has(passes2, p) {
1696
1700
  }
1697
1701
  async function transcribe(opts2) {
1698
1702
  if (!opts2 || typeof opts2.input !== "string" || opts2.input.length === 0) {
1699
- throw new Error("transcribe(options): 'input' (path to the audio/video file) is required");
1700
- }
1701
- if (typeof opts2.outputDir !== "string" || opts2.outputDir.length === 0) {
1702
- throw new Error("transcribe(options): 'outputDir' (directory for outputs) is required");
1703
+ throw new Error(
1704
+ "transcribe(options): 'input' (path to the audio/video file) is required"
1705
+ );
1703
1706
  }
1704
1707
  const options = resolveOptions(opts2);
1705
1708
  const keys = resolveKeys(options.apiKeys);
@@ -1709,11 +1712,16 @@ async function transcribe(opts2) {
1709
1712
  }
1710
1713
  mkdirSync(options.intermediatesDir, { recursive: true });
1711
1714
  mkdirSync(options.outputDir, { recursive: true });
1715
+ logger.info(
1716
+ `intermediates: ${resolve2(options.intermediatesDir)} (file://${resolve2(options.intermediatesDir)})`
1717
+ );
1712
1718
  setLlmLogPath(options.llmLog ? `${options.intermediatesDir}/llm-calls.jsonl` : null);
1713
1719
  const sourcePath = `${options.intermediatesDir}/source.json`;
1714
1720
  const sig = inputSignature(options.input);
1715
1721
  const cfgSig = configSignature(opts2);
1716
- const prevSig = readJson(sourcePath);
1722
+ const prevSig = readJson(
1723
+ sourcePath
1724
+ );
1717
1725
  const inputChanged = !prevSig || prevSig.signature !== sig;
1718
1726
  const configChanged = !prevSig || prevSig.config !== cfgSig;
1719
1727
  if (inputChanged && prevSig) {
@@ -1752,7 +1760,8 @@ async function transcribe(opts2) {
1752
1760
  }
1753
1761
  }
1754
1762
  let probeInfo = null;
1755
- const audioPath = `${options.intermediatesDir}/audio.flac`;
1763
+ const AUDIO_OPTS = { format: "mp3", bitrate: "64k" };
1764
+ const audioPath = `${options.intermediatesDir}/audio.mp3`;
1756
1765
  const probePath = `${options.intermediatesDir}/probe.json`;
1757
1766
  if (has(passes2, "preprocess")) {
1758
1767
  logger.info("=== preprocess ===");
@@ -1762,8 +1771,8 @@ async function transcribe(opts2) {
1762
1771
  writeJson(probePath, probeInfo);
1763
1772
  }
1764
1773
  if (!existsSync2(audioPath) || forceAll) {
1765
- logger.info("extracting audio (mono 16kHz FLAC)...");
1766
- await extractAudio(options.input, audioPath, { format: "flac" });
1774
+ logger.info("extracting audio (mono 16kHz mp3)...");
1775
+ await extractAudio(options.input, audioPath, AUDIO_OPTS);
1767
1776
  }
1768
1777
  if (probeInfo.hasVideo) {
1769
1778
  const kfDir = `${options.intermediatesDir}/keyframes`;
@@ -1784,9 +1793,9 @@ async function transcribe(opts2) {
1784
1793
  if (!description) {
1785
1794
  logger.info("=== describe ===");
1786
1795
  const client = new GeminiClient(keys.gemini);
1787
- const samplePath = `${options.intermediatesDir}/sample.flac`;
1796
+ const samplePath = `${options.intermediatesDir}/sample.mp3`;
1788
1797
  if (!existsSync2(samplePath) || forceAll) {
1789
- await extractChunk(audioPath, samplePath, 0, Math.min(300, duration), { format: "flac" });
1798
+ await extractChunk(audioPath, samplePath, 0, Math.min(300, duration), AUDIO_OPTS);
1790
1799
  }
1791
1800
  const files = [{ path: samplePath }];
1792
1801
  const kfDir = `${options.intermediatesDir}/keyframes`;
@@ -1796,7 +1805,13 @@ async function transcribe(opts2) {
1796
1805
  if (existsSync2(p)) files.push({ path: p });
1797
1806
  }
1798
1807
  }
1799
- description = await describeMeeting(client, models.transcribe, files, basename3(options.input), options.instructions);
1808
+ description = await describeMeeting(
1809
+ client,
1810
+ models.transcribe,
1811
+ files,
1812
+ basename3(options.input),
1813
+ options.instructions
1814
+ );
1800
1815
  writeJson(descPath, description);
1801
1816
  logger.info(`description: ${description.description.slice(0, 120)}...`);
1802
1817
  }
@@ -1809,27 +1824,39 @@ async function transcribe(opts2) {
1809
1824
  let silences = [];
1810
1825
  try {
1811
1826
  silences = await detectSilence(audioPath, { noiseDb: -15, minDuration: 0.3 });
1812
- if (silences.length < 3) silences = await detectSilence(audioPath, { noiseDb: -12, minDuration: 0.25 });
1827
+ if (silences.length < 3)
1828
+ silences = await detectSilence(audioPath, { noiseDb: -12, minDuration: 0.25 });
1813
1829
  } catch {
1814
1830
  }
1815
1831
  chunks = planChunks(duration, options.chunkDurationSec, options.chunkOverlapSec);
1816
1832
  if (silences.length > 3) {
1817
1833
  chunks = chunks.map((c) => {
1818
- const snapped = snapToSilence(c.start, silences, Math.min(10, options.chunkOverlapSec / 2));
1834
+ const snapped = snapToSilence(
1835
+ c.start,
1836
+ silences,
1837
+ Math.min(10, options.chunkOverlapSec / 2)
1838
+ );
1819
1839
  return { ...c, start: snapped, trustedStart: snapped + c.overlapWithPrevious };
1820
1840
  });
1821
1841
  }
1822
1842
  }
1823
1843
  const tagWith = (r, chunk) => ({
1824
1844
  ...r,
1825
- segments: r.segments.map((s) => ({ ...s, chunkIndex: chunk.index, trustedStart: chunk.trustedStart }))
1845
+ segments: r.segments.map((s) => ({
1846
+ ...s,
1847
+ chunkIndex: chunk.index,
1848
+ trustedStart: chunk.trustedStart
1849
+ }))
1826
1850
  });
1827
1851
  let llmChunkResults = [];
1828
1852
  if (has(passes2, "llm-transcribe")) {
1829
1853
  logger.info("=== llm-transcribe ===");
1830
1854
  let runChunks = chunks;
1831
- if (options.onlyChunk !== void 0) runChunks = chunks.filter((c) => c.index === options.onlyChunk);
1832
- logger.info(`${runChunks.length} chunks (${options.chunkDurationSec}s, ${options.chunkOverlapSec}s overlap)`);
1855
+ if (options.onlyChunk !== void 0)
1856
+ runChunks = chunks.filter((c) => c.index === options.onlyChunk);
1857
+ logger.info(
1858
+ `${runChunks.length} chunks (${options.chunkDurationSec}s, ${options.chunkOverlapSec}s overlap)`
1859
+ );
1833
1860
  const client = new GeminiClient(keys.gemini);
1834
1861
  const llmDir = `${options.intermediatesDir}/llm`;
1835
1862
  mkdirSync(llmDir, { recursive: true });
@@ -1840,9 +1867,9 @@ async function transcribe(opts2) {
1840
1867
  logger.info(`chunk ${chunk.index}: cached (${cached.segments.length} segments)`);
1841
1868
  return tagWith(cached, chunk);
1842
1869
  }
1843
- const chunkPath = `${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}.flac`;
1870
+ const chunkPath = `${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}.mp3`;
1844
1871
  if (!existsSync2(chunkPath) || forceAll) {
1845
- await extractChunk(audioPath, chunkPath, chunk.start, chunk.end, { format: "flac" });
1872
+ await extractChunk(audioPath, chunkPath, chunk.start, chunk.end, AUDIO_OPTS);
1846
1873
  }
1847
1874
  let previousTail;
1848
1875
  if (chunk.index > 0) {
@@ -1853,7 +1880,9 @@ async function transcribe(opts2) {
1853
1880
  previousTail = prev.segments.slice(-6).map((s) => `${s.speaker}: ${s.text}`).join("\n");
1854
1881
  }
1855
1882
  }
1856
- logger.info(`chunk ${chunk.index}: transcribing [${chunk.start.toFixed(0)}-${chunk.end.toFixed(0)}]s...`);
1883
+ logger.info(
1884
+ `chunk ${chunk.index}: transcribing [${chunk.start.toFixed(0)}-${chunk.end.toFixed(0)}]s...`
1885
+ );
1857
1886
  const result2 = await transcribeChunk(
1858
1887
  client,
1859
1888
  models.transcribe,
@@ -1870,7 +1899,10 @@ async function transcribe(opts2) {
1870
1899
  { chunkDurationSec: chunk.end - chunk.start, validationRetries: 1 }
1871
1900
  );
1872
1901
  writeJson(parsedPath, result2);
1873
- writeFileSync(`${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}_raw.json`, result2.raw);
1902
+ writeFileSync(
1903
+ `${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}_raw.json`,
1904
+ result2.raw
1905
+ );
1874
1906
  return tagWith(result2, chunk);
1875
1907
  });
1876
1908
  const errored = llmChunkResults.filter((r) => r.error);
@@ -1905,19 +1937,24 @@ async function transcribe(opts2) {
1905
1937
  if (provider === "whisper-groq") {
1906
1938
  logger.info("=== timestamped (Groq Whisper \u2014 no diarization) ===");
1907
1939
  if (!keys.groq) throw new Error("GROQ_API_KEY is required for whisper-groq");
1908
- const mp3Path = `${options.intermediatesDir}/audio.mp3`;
1909
- if (!existsSync2(mp3Path) || options.force) {
1910
- await extractAudio(options.input, mp3Path, { format: "mp3", bitrate: "64k" });
1940
+ if (!existsSync2(audioPath) || forceAll) {
1941
+ await extractAudio(options.input, audioPath, AUDIO_OPTS);
1911
1942
  }
1912
1943
  const { readFile: readFile2 } = await import("fs/promises");
1913
- const buf = await readFile2(mp3Path);
1944
+ const buf = await readFile2(audioPath);
1914
1945
  const groq = new WhisperGroqClient(keys.groq);
1915
1946
  asrResult = await groq.transcribe(buf);
1916
1947
  writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);
1917
1948
  } else {
1918
1949
  logger.info("=== timestamped (AssemblyAI) ===");
1919
- if (!keys.assemblyai) throw new Error("ASSEMBLYAI_API_KEY is required for the timestamped pass (or use --timestamped whisper-groq)");
1920
- const aai = new AssemblyAIProvider({ apiKey: keys.assemblyai, cacheDir: `${options.intermediatesDir}/assemblyai` });
1950
+ if (!keys.assemblyai)
1951
+ throw new Error(
1952
+ "ASSEMBLYAI_API_KEY is required for the timestamped pass (or use --timestamped whisper-groq)"
1953
+ );
1954
+ const aai = new AssemblyAIProvider({
1955
+ apiKey: keys.assemblyai,
1956
+ cacheDir: `${options.intermediatesDir}/assemblyai`
1957
+ });
1921
1958
  asrResult = await aai.transcribe(audioPath);
1922
1959
  writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);
1923
1960
  }
@@ -1961,7 +1998,11 @@ async function transcribe(opts2) {
1961
1998
  }
1962
1999
  if (options.diarizationLevel >= 3 && has(passes2, "identify") && keys.deepseek && description) {
1963
2000
  logger.info("=== identify (DeepSeek) ===");
1964
- const dsClient = OpenAICompatClient.fromProvider("deepseek", keys.deepseek, models.reasoner);
2001
+ const dsClient = OpenAICompatClient.fromProvider(
2002
+ "deepseek",
2003
+ keys.deepseek,
2004
+ models.reasoner
2005
+ );
1965
2006
  const id = await identifySpeakers(
1966
2007
  dsClient,
1967
2008
  models.reasoner,
@@ -1970,7 +2011,9 @@ async function transcribe(opts2) {
1970
2011
  description.roster,
1971
2012
  options.knownSpeakers
1972
2013
  );
1973
- logger.info(`identified ${Object.keys(id.nameMap).length} speakers: ${JSON.stringify(id.nameMap)}`);
2014
+ logger.info(
2015
+ `identified ${Object.keys(id.nameMap).length} speakers: ${JSON.stringify(id.nameMap)}`
2016
+ );
1974
2017
  writeJson(`${options.intermediatesDir}/identified.json`, id);
1975
2018
  segments = segments.map(
1976
2019
  (s) => id.nameMap[s.speaker] ? { ...s, speakerName: id.nameMap[s.speaker] } : s
@@ -2001,9 +2044,18 @@ async function transcribe(opts2) {
2001
2044
  const result = { segments: finalSegments, speakers, metadata };
2002
2045
  for (const fmt of options.formats) {
2003
2046
  const base = basename3(options.input, ext(options.input));
2004
- if (fmt === "srt") writeFileSync(`${options.outputDir}/${base}.srt`, formatSrt(result, { title: base }));
2005
- if (fmt === "md") writeFileSync(`${options.outputDir}/${base}.md`, formatMarkdown(result, { title: base }));
2006
- if (fmt === "json") writeFileSync(`${options.outputDir}/${base}.json`, formatJson(result));
2047
+ if (fmt === "srt")
2048
+ writeFileSync(
2049
+ `${options.outputDir}/${base}.srt`,
2050
+ formatSrt(result, { title: base })
2051
+ );
2052
+ if (fmt === "md")
2053
+ writeFileSync(
2054
+ `${options.outputDir}/${base}.md`,
2055
+ formatMarkdown(result, { title: base })
2056
+ );
2057
+ if (fmt === "json")
2058
+ writeFileSync(`${options.outputDir}/${base}.json`, formatJson(result));
2007
2059
  }
2008
2060
  logger.info(`outputs written to ${options.outputDir}`);
2009
2061
  return result;
@@ -2022,10 +2074,10 @@ try {
2022
2074
  } catch {
2023
2075
  }
2024
2076
  var program = new Command();
2025
- 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", "./output").option(
2077
+ 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(
2026
2078
  "-i, --intermediates <dir>",
2027
2079
  "intermediates directory (default: auto-derived per input file so caches never collide)"
2028
- ).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", "srt,md,json").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");
2080
+ ).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");
2029
2081
  program.parse();
2030
2082
  var opts = program.opts();
2031
2083
  var input = program.args[0];
@@ -2038,6 +2090,7 @@ var level = parseInt(opts.level, 10);
2038
2090
  transcribe({
2039
2091
  input,
2040
2092
  outputDir: opts.output,
2093
+ // undefined → defaults to the input file's directory
2041
2094
  intermediatesDir: opts.intermediates,
2042
2095
  instructions: opts.instructions,
2043
2096
  passes,
@@ -2045,7 +2098,8 @@ transcribe({
2045
2098
  chunkOverlapSec: parseInt(opts.overlapSeconds, 10),
2046
2099
  concurrency: parseInt(opts.concurrency, 10),
2047
2100
  screenshotCount: parseInt(opts.screenshots, 10),
2048
- formats: opts.formats.split(","),
2101
+ formats: opts.formats ? opts.formats.split(",") : void 0,
2102
+ // undefined → defaults to ["md"]
2049
2103
  diarizationLevel: level,
2050
2104
  model: opts.model,
2051
2105
  reasoner: opts.reasoner,