offmute-v2 0.0.4 → 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
@@ -4,14 +4,14 @@
4
4
  import { Command } from "commander";
5
5
  import { readFileSync as readFileSync2 } from "fs";
6
6
  import { fileURLToPath } from "url";
7
- import { dirname as dirname3, join } from "path";
7
+ import { dirname as dirname4, join } from "path";
8
8
 
9
9
  // src/core/pipeline.ts
10
10
  import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
11
11
 
12
12
  // src/core/config.ts
13
13
  import { createHash } from "crypto";
14
- import { basename, resolve } from "path";
14
+ import { basename, dirname, resolve } from "path";
15
15
  import { statSync } from "fs";
16
16
  import { tmpdir } from "os";
17
17
  var DEFAULT_PASSES = [
@@ -27,12 +27,14 @@ var MODELS = {
27
27
  gemini25Pro: "gemini-2.5-pro",
28
28
  gemini25Flash: "gemini-2.5-flash",
29
29
  gemini3Pro: "gemini-3-pro-preview",
30
+ gemini31Pro: "gemini-3.1-pro-preview",
31
+ geminiFlashLatest: "gemini-flash-latest",
30
32
  deepseek: "deepseek-chat",
31
33
  deepseekReasoner: "deepseek-reasoner",
32
34
  gpt4o: "gpt-4o",
33
35
  claudeSonnet: "claude-sonnet-4-5"
34
36
  };
35
- var DEFAULT_TRANSCRIBE_MODEL = MODELS.gemini25Flash;
37
+ var DEFAULT_TRANSCRIBE_MODEL = MODELS.gemini31Pro;
36
38
  var DEFAULT_REASONER_MODEL = MODELS.deepseek;
37
39
  function resolveKeys(injected) {
38
40
  const env = process.env;
@@ -49,7 +51,8 @@ function resolveKeys(injected) {
49
51
  function resolveOptions(opts2) {
50
52
  return {
51
53
  input: opts2.input,
52
- 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)),
53
56
  intermediatesDir: opts2.intermediatesDir ?? deriveIntermediatesDir(opts2.input),
54
57
  instructions: opts2.instructions,
55
58
  knownSpeakers: opts2.knownSpeakers,
@@ -69,7 +72,7 @@ function resolveOptions(opts2) {
69
72
  screenshotCount: opts2.screenshotCount ?? 6,
70
73
  concurrency: opts2.concurrency ?? 4,
71
74
  saveIntermediates: opts2.saveIntermediates ?? true,
72
- formats: opts2.formats ?? ["srt", "md", "json"],
75
+ formats: opts2.formats ?? ["md"],
73
76
  diarizationLevel: opts2.diarizationLevel ?? 2,
74
77
  apiKeys: opts2.apiKeys,
75
78
  model: opts2.model,
@@ -171,7 +174,7 @@ var logger = {
171
174
  // src/audio/ffmpeg.ts
172
175
  import { spawn } from "child_process";
173
176
  import { mkdir } from "fs/promises";
174
- import { dirname } from "path";
177
+ import { dirname as dirname2 } from "path";
175
178
  function run(cmd, args, _opts = {}) {
176
179
  return new Promise((resolve3, reject) => {
177
180
  const child = spawn(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
@@ -242,12 +245,12 @@ function audioArgs(opts2) {
242
245
  }
243
246
  }
244
247
  async function extractAudio(input2, output, opts2 = {}) {
245
- await mkdir(dirname(output), { recursive: true });
248
+ await mkdir(dirname2(output), { recursive: true });
246
249
  const args = ["-y", "-i", input2, ...audioArgs(opts2), output];
247
250
  await run("ffmpeg", args);
248
251
  }
249
252
  async function extractChunk(input2, output, startSec, endSec, opts2 = {}) {
250
- await mkdir(dirname(output), { recursive: true });
253
+ await mkdir(dirname2(output), { recursive: true });
251
254
  const duration = Math.max(0, endSec - startSec);
252
255
  const args = [
253
256
  "-y",
@@ -578,7 +581,7 @@ import { AssemblyAI } from "assemblyai";
578
581
  import { createHash as createHash2 } from "crypto";
579
582
  import { readFile, mkdir as mkdir2, writeFile } from "fs/promises";
580
583
  import { existsSync } from "fs";
581
- import { dirname as dirname2 } from "path";
584
+ import { dirname as dirname3 } from "path";
582
585
  async function fileHash(path) {
583
586
  const buf = await readFile(path);
584
587
  return createHash2("sha256").update(buf).digest("hex").slice(0, 24);
@@ -617,7 +620,7 @@ var AssemblyAIProvider = class {
617
620
  }
618
621
  const result = this.mapTranscript(transcript, hash);
619
622
  if (cachePath) {
620
- await mkdir2(dirname2(cachePath), { recursive: true });
623
+ await mkdir2(dirname3(cachePath), { recursive: true });
621
624
  await writeFile(cachePath, JSON.stringify(result, null, 2));
622
625
  }
623
626
  logger.info(
@@ -1697,10 +1700,9 @@ function has(passes2, p) {
1697
1700
  }
1698
1701
  async function transcribe(opts2) {
1699
1702
  if (!opts2 || typeof opts2.input !== "string" || opts2.input.length === 0) {
1700
- throw new Error("transcribe(options): 'input' (path to the audio/video file) is required");
1701
- }
1702
- if (typeof opts2.outputDir !== "string" || opts2.outputDir.length === 0) {
1703
- 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
+ );
1704
1706
  }
1705
1707
  const options = resolveOptions(opts2);
1706
1708
  const keys = resolveKeys(options.apiKeys);
@@ -1710,12 +1712,16 @@ async function transcribe(opts2) {
1710
1712
  }
1711
1713
  mkdirSync(options.intermediatesDir, { recursive: true });
1712
1714
  mkdirSync(options.outputDir, { recursive: true });
1713
- logger.info(`intermediates: ${resolve2(options.intermediatesDir)} (file://${resolve2(options.intermediatesDir)})`);
1715
+ logger.info(
1716
+ `intermediates: ${resolve2(options.intermediatesDir)} (file://${resolve2(options.intermediatesDir)})`
1717
+ );
1714
1718
  setLlmLogPath(options.llmLog ? `${options.intermediatesDir}/llm-calls.jsonl` : null);
1715
1719
  const sourcePath = `${options.intermediatesDir}/source.json`;
1716
1720
  const sig = inputSignature(options.input);
1717
1721
  const cfgSig = configSignature(opts2);
1718
- const prevSig = readJson(sourcePath);
1722
+ const prevSig = readJson(
1723
+ sourcePath
1724
+ );
1719
1725
  const inputChanged = !prevSig || prevSig.signature !== sig;
1720
1726
  const configChanged = !prevSig || prevSig.config !== cfgSig;
1721
1727
  if (inputChanged && prevSig) {
@@ -1799,7 +1805,13 @@ async function transcribe(opts2) {
1799
1805
  if (existsSync2(p)) files.push({ path: p });
1800
1806
  }
1801
1807
  }
1802
- 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
+ );
1803
1815
  writeJson(descPath, description);
1804
1816
  logger.info(`description: ${description.description.slice(0, 120)}...`);
1805
1817
  }
@@ -1812,27 +1824,39 @@ async function transcribe(opts2) {
1812
1824
  let silences = [];
1813
1825
  try {
1814
1826
  silences = await detectSilence(audioPath, { noiseDb: -15, minDuration: 0.3 });
1815
- 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 });
1816
1829
  } catch {
1817
1830
  }
1818
1831
  chunks = planChunks(duration, options.chunkDurationSec, options.chunkOverlapSec);
1819
1832
  if (silences.length > 3) {
1820
1833
  chunks = chunks.map((c) => {
1821
- 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
+ );
1822
1839
  return { ...c, start: snapped, trustedStart: snapped + c.overlapWithPrevious };
1823
1840
  });
1824
1841
  }
1825
1842
  }
1826
1843
  const tagWith = (r, chunk) => ({
1827
1844
  ...r,
1828
- 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
+ }))
1829
1850
  });
1830
1851
  let llmChunkResults = [];
1831
1852
  if (has(passes2, "llm-transcribe")) {
1832
1853
  logger.info("=== llm-transcribe ===");
1833
1854
  let runChunks = chunks;
1834
- if (options.onlyChunk !== void 0) runChunks = chunks.filter((c) => c.index === options.onlyChunk);
1835
- 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
+ );
1836
1860
  const client = new GeminiClient(keys.gemini);
1837
1861
  const llmDir = `${options.intermediatesDir}/llm`;
1838
1862
  mkdirSync(llmDir, { recursive: true });
@@ -1856,7 +1880,9 @@ async function transcribe(opts2) {
1856
1880
  previousTail = prev.segments.slice(-6).map((s) => `${s.speaker}: ${s.text}`).join("\n");
1857
1881
  }
1858
1882
  }
1859
- 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
+ );
1860
1886
  const result2 = await transcribeChunk(
1861
1887
  client,
1862
1888
  models.transcribe,
@@ -1873,7 +1899,10 @@ async function transcribe(opts2) {
1873
1899
  { chunkDurationSec: chunk.end - chunk.start, validationRetries: 1 }
1874
1900
  );
1875
1901
  writeJson(parsedPath, result2);
1876
- 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
+ );
1877
1906
  return tagWith(result2, chunk);
1878
1907
  });
1879
1908
  const errored = llmChunkResults.filter((r) => r.error);
@@ -1918,8 +1947,14 @@ async function transcribe(opts2) {
1918
1947
  writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);
1919
1948
  } else {
1920
1949
  logger.info("=== timestamped (AssemblyAI) ===");
1921
- if (!keys.assemblyai) throw new Error("ASSEMBLYAI_API_KEY is required for the timestamped pass (or use --timestamped whisper-groq)");
1922
- 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
+ });
1923
1958
  asrResult = await aai.transcribe(audioPath);
1924
1959
  writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);
1925
1960
  }
@@ -1963,7 +1998,11 @@ async function transcribe(opts2) {
1963
1998
  }
1964
1999
  if (options.diarizationLevel >= 3 && has(passes2, "identify") && keys.deepseek && description) {
1965
2000
  logger.info("=== identify (DeepSeek) ===");
1966
- const dsClient = OpenAICompatClient.fromProvider("deepseek", keys.deepseek, models.reasoner);
2001
+ const dsClient = OpenAICompatClient.fromProvider(
2002
+ "deepseek",
2003
+ keys.deepseek,
2004
+ models.reasoner
2005
+ );
1967
2006
  const id = await identifySpeakers(
1968
2007
  dsClient,
1969
2008
  models.reasoner,
@@ -1972,7 +2011,9 @@ async function transcribe(opts2) {
1972
2011
  description.roster,
1973
2012
  options.knownSpeakers
1974
2013
  );
1975
- 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
+ );
1976
2017
  writeJson(`${options.intermediatesDir}/identified.json`, id);
1977
2018
  segments = segments.map(
1978
2019
  (s) => id.nameMap[s.speaker] ? { ...s, speakerName: id.nameMap[s.speaker] } : s
@@ -2003,9 +2044,18 @@ async function transcribe(opts2) {
2003
2044
  const result = { segments: finalSegments, speakers, metadata };
2004
2045
  for (const fmt of options.formats) {
2005
2046
  const base = basename3(options.input, ext(options.input));
2006
- if (fmt === "srt") writeFileSync(`${options.outputDir}/${base}.srt`, formatSrt(result, { title: base }));
2007
- if (fmt === "md") writeFileSync(`${options.outputDir}/${base}.md`, formatMarkdown(result, { title: base }));
2008
- 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));
2009
2059
  }
2010
2060
  logger.info(`outputs written to ${options.outputDir}`);
2011
2061
  return result;
@@ -2018,16 +2068,16 @@ function ext(p) {
2018
2068
  // src/cli.ts
2019
2069
  var packageVersion = "0.0.0";
2020
2070
  try {
2021
- const here = dirname3(fileURLToPath(import.meta.url));
2071
+ const here = dirname4(fileURLToPath(import.meta.url));
2022
2072
  const pkg = JSON.parse(readFileSync2(join(here, "..", "package.json"), "utf-8"));
2023
2073
  packageVersion = pkg.version;
2024
2074
  } catch {
2025
2075
  }
2026
2076
  var program = new Command();
2027
- 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(
2028
2078
  "-i, --intermediates <dir>",
2029
2079
  "intermediates directory (default: auto-derived per input file so caches never collide)"
2030
- ).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");
2031
2081
  program.parse();
2032
2082
  var opts = program.opts();
2033
2083
  var input = program.args[0];
@@ -2040,6 +2090,7 @@ var level = parseInt(opts.level, 10);
2040
2090
  transcribe({
2041
2091
  input,
2042
2092
  outputDir: opts.output,
2093
+ // undefined → defaults to the input file's directory
2043
2094
  intermediatesDir: opts.intermediates,
2044
2095
  instructions: opts.instructions,
2045
2096
  passes,
@@ -2047,7 +2098,8 @@ transcribe({
2047
2098
  chunkOverlapSec: parseInt(opts.overlapSeconds, 10),
2048
2099
  concurrency: parseInt(opts.concurrency, 10),
2049
2100
  screenshotCount: parseInt(opts.screenshots, 10),
2050
- formats: opts.formats.split(","),
2101
+ formats: opts.formats ? opts.formats.split(",") : void 0,
2102
+ // undefined → defaults to ["md"]
2051
2103
  diarizationLevel: level,
2052
2104
  model: opts.model,
2053
2105
  reasoner: opts.reasoner,