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/README.md +49 -44
- package/dist/cli.cjs +79 -27
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +87 -35
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +74 -24
- 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 +80 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -119,8 +119,8 @@ interface ApiKeys {
|
|
|
119
119
|
interface PipelineOptions {
|
|
120
120
|
/** Input file path. */
|
|
121
121
|
input: string;
|
|
122
|
-
/** Output directory. */
|
|
123
|
-
outputDir
|
|
122
|
+
/** Output directory. Defaults to the input file's own directory. */
|
|
123
|
+
outputDir?: string;
|
|
124
124
|
/** Directory for intermediates (resumable). If omitted, derived per-input so
|
|
125
125
|
* different files never share a cache (see deriveIntermediatesDir). */
|
|
126
126
|
intermediatesDir?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -119,8 +119,8 @@ interface ApiKeys {
|
|
|
119
119
|
interface PipelineOptions {
|
|
120
120
|
/** Input file path. */
|
|
121
121
|
input: string;
|
|
122
|
-
/** Output directory. */
|
|
123
|
-
outputDir
|
|
122
|
+
/** Output directory. Defaults to the input file's own directory. */
|
|
123
|
+
outputDir?: string;
|
|
124
124
|
/** Directory for intermediates (resumable). If omitted, derived per-input so
|
|
125
125
|
* different files never share a cache (see deriveIntermediatesDir). */
|
|
126
126
|
intermediatesDir?: string;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } fro
|
|
|
3
3
|
|
|
4
4
|
// src/core/config.ts
|
|
5
5
|
import { createHash } from "crypto";
|
|
6
|
-
import { basename, resolve } from "path";
|
|
6
|
+
import { basename, dirname, resolve } from "path";
|
|
7
7
|
import { statSync } from "fs";
|
|
8
8
|
import { tmpdir } from "os";
|
|
9
9
|
var DEFAULT_PASSES = [
|
|
@@ -19,12 +19,14 @@ var MODELS = {
|
|
|
19
19
|
gemini25Pro: "gemini-2.5-pro",
|
|
20
20
|
gemini25Flash: "gemini-2.5-flash",
|
|
21
21
|
gemini3Pro: "gemini-3-pro-preview",
|
|
22
|
+
gemini31Pro: "gemini-3.1-pro-preview",
|
|
23
|
+
geminiFlashLatest: "gemini-flash-latest",
|
|
22
24
|
deepseek: "deepseek-chat",
|
|
23
25
|
deepseekReasoner: "deepseek-reasoner",
|
|
24
26
|
gpt4o: "gpt-4o",
|
|
25
27
|
claudeSonnet: "claude-sonnet-4-5"
|
|
26
28
|
};
|
|
27
|
-
var DEFAULT_TRANSCRIBE_MODEL = MODELS.
|
|
29
|
+
var DEFAULT_TRANSCRIBE_MODEL = MODELS.gemini31Pro;
|
|
28
30
|
var DEFAULT_REASONER_MODEL = MODELS.deepseek;
|
|
29
31
|
function resolveKeys(injected) {
|
|
30
32
|
const env = process.env;
|
|
@@ -41,7 +43,8 @@ function resolveKeys(injected) {
|
|
|
41
43
|
function resolveOptions(opts) {
|
|
42
44
|
return {
|
|
43
45
|
input: opts.input,
|
|
44
|
-
|
|
46
|
+
// Default: write next to the input file (e.g. meeting.md beside meeting.mp4) — no ./output folder.
|
|
47
|
+
outputDir: opts.outputDir ?? dirname(resolve(opts.input)),
|
|
45
48
|
intermediatesDir: opts.intermediatesDir ?? deriveIntermediatesDir(opts.input),
|
|
46
49
|
instructions: opts.instructions,
|
|
47
50
|
knownSpeakers: opts.knownSpeakers,
|
|
@@ -61,7 +64,7 @@ function resolveOptions(opts) {
|
|
|
61
64
|
screenshotCount: opts.screenshotCount ?? 6,
|
|
62
65
|
concurrency: opts.concurrency ?? 4,
|
|
63
66
|
saveIntermediates: opts.saveIntermediates ?? true,
|
|
64
|
-
formats: opts.formats ?? ["
|
|
67
|
+
formats: opts.formats ?? ["md"],
|
|
65
68
|
diarizationLevel: opts.diarizationLevel ?? 2,
|
|
66
69
|
apiKeys: opts.apiKeys,
|
|
67
70
|
model: opts.model,
|
|
@@ -163,7 +166,7 @@ var logger = {
|
|
|
163
166
|
// src/audio/ffmpeg.ts
|
|
164
167
|
import { spawn } from "child_process";
|
|
165
168
|
import { mkdir } from "fs/promises";
|
|
166
|
-
import { dirname } from "path";
|
|
169
|
+
import { dirname as dirname2 } from "path";
|
|
167
170
|
function run(cmd, args, _opts = {}) {
|
|
168
171
|
return new Promise((resolve3, reject) => {
|
|
169
172
|
const child = spawn(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
@@ -234,12 +237,12 @@ function audioArgs(opts) {
|
|
|
234
237
|
}
|
|
235
238
|
}
|
|
236
239
|
async function extractAudio(input, output, opts = {}) {
|
|
237
|
-
await mkdir(
|
|
240
|
+
await mkdir(dirname2(output), { recursive: true });
|
|
238
241
|
const args = ["-y", "-i", input, ...audioArgs(opts), output];
|
|
239
242
|
await run("ffmpeg", args);
|
|
240
243
|
}
|
|
241
244
|
async function extractChunk(input, output, startSec, endSec, opts = {}) {
|
|
242
|
-
await mkdir(
|
|
245
|
+
await mkdir(dirname2(output), { recursive: true });
|
|
243
246
|
const duration = Math.max(0, endSec - startSec);
|
|
244
247
|
const args = [
|
|
245
248
|
"-y",
|
|
@@ -570,7 +573,7 @@ import { AssemblyAI } from "assemblyai";
|
|
|
570
573
|
import { createHash as createHash2 } from "crypto";
|
|
571
574
|
import { readFile, mkdir as mkdir2, writeFile } from "fs/promises";
|
|
572
575
|
import { existsSync } from "fs";
|
|
573
|
-
import { dirname as
|
|
576
|
+
import { dirname as dirname3 } from "path";
|
|
574
577
|
async function fileHash(path) {
|
|
575
578
|
const buf = await readFile(path);
|
|
576
579
|
return createHash2("sha256").update(buf).digest("hex").slice(0, 24);
|
|
@@ -609,7 +612,7 @@ var AssemblyAIProvider = class {
|
|
|
609
612
|
}
|
|
610
613
|
const result = this.mapTranscript(transcript, hash);
|
|
611
614
|
if (cachePath) {
|
|
612
|
-
await mkdir2(
|
|
615
|
+
await mkdir2(dirname3(cachePath), { recursive: true });
|
|
613
616
|
await writeFile(cachePath, JSON.stringify(result, null, 2));
|
|
614
617
|
}
|
|
615
618
|
logger.info(
|
|
@@ -1704,10 +1707,9 @@ function has(passes, p) {
|
|
|
1704
1707
|
}
|
|
1705
1708
|
async function transcribe(opts) {
|
|
1706
1709
|
if (!opts || typeof opts.input !== "string" || opts.input.length === 0) {
|
|
1707
|
-
throw new Error(
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
throw new Error("transcribe(options): 'outputDir' (directory for outputs) is required");
|
|
1710
|
+
throw new Error(
|
|
1711
|
+
"transcribe(options): 'input' (path to the audio/video file) is required"
|
|
1712
|
+
);
|
|
1711
1713
|
}
|
|
1712
1714
|
const options = resolveOptions(opts);
|
|
1713
1715
|
const keys = resolveKeys(options.apiKeys);
|
|
@@ -1717,12 +1719,16 @@ async function transcribe(opts) {
|
|
|
1717
1719
|
}
|
|
1718
1720
|
mkdirSync(options.intermediatesDir, { recursive: true });
|
|
1719
1721
|
mkdirSync(options.outputDir, { recursive: true });
|
|
1720
|
-
logger.info(
|
|
1722
|
+
logger.info(
|
|
1723
|
+
`intermediates: ${resolve2(options.intermediatesDir)} (file://${resolve2(options.intermediatesDir)})`
|
|
1724
|
+
);
|
|
1721
1725
|
setLlmLogPath(options.llmLog ? `${options.intermediatesDir}/llm-calls.jsonl` : null);
|
|
1722
1726
|
const sourcePath = `${options.intermediatesDir}/source.json`;
|
|
1723
1727
|
const sig = inputSignature(options.input);
|
|
1724
1728
|
const cfgSig = configSignature(opts);
|
|
1725
|
-
const prevSig = readJson(
|
|
1729
|
+
const prevSig = readJson(
|
|
1730
|
+
sourcePath
|
|
1731
|
+
);
|
|
1726
1732
|
const inputChanged = !prevSig || prevSig.signature !== sig;
|
|
1727
1733
|
const configChanged = !prevSig || prevSig.config !== cfgSig;
|
|
1728
1734
|
if (inputChanged && prevSig) {
|
|
@@ -1806,7 +1812,13 @@ async function transcribe(opts) {
|
|
|
1806
1812
|
if (existsSync2(p)) files.push({ path: p });
|
|
1807
1813
|
}
|
|
1808
1814
|
}
|
|
1809
|
-
description = await describeMeeting(
|
|
1815
|
+
description = await describeMeeting(
|
|
1816
|
+
client,
|
|
1817
|
+
models.transcribe,
|
|
1818
|
+
files,
|
|
1819
|
+
basename3(options.input),
|
|
1820
|
+
options.instructions
|
|
1821
|
+
);
|
|
1810
1822
|
writeJson(descPath, description);
|
|
1811
1823
|
logger.info(`description: ${description.description.slice(0, 120)}...`);
|
|
1812
1824
|
}
|
|
@@ -1819,27 +1831,39 @@ async function transcribe(opts) {
|
|
|
1819
1831
|
let silences = [];
|
|
1820
1832
|
try {
|
|
1821
1833
|
silences = await detectSilence(audioPath, { noiseDb: -15, minDuration: 0.3 });
|
|
1822
|
-
if (silences.length < 3)
|
|
1834
|
+
if (silences.length < 3)
|
|
1835
|
+
silences = await detectSilence(audioPath, { noiseDb: -12, minDuration: 0.25 });
|
|
1823
1836
|
} catch {
|
|
1824
1837
|
}
|
|
1825
1838
|
chunks = planChunks(duration, options.chunkDurationSec, options.chunkOverlapSec);
|
|
1826
1839
|
if (silences.length > 3) {
|
|
1827
1840
|
chunks = chunks.map((c) => {
|
|
1828
|
-
const snapped = snapToSilence(
|
|
1841
|
+
const snapped = snapToSilence(
|
|
1842
|
+
c.start,
|
|
1843
|
+
silences,
|
|
1844
|
+
Math.min(10, options.chunkOverlapSec / 2)
|
|
1845
|
+
);
|
|
1829
1846
|
return { ...c, start: snapped, trustedStart: snapped + c.overlapWithPrevious };
|
|
1830
1847
|
});
|
|
1831
1848
|
}
|
|
1832
1849
|
}
|
|
1833
1850
|
const tagWith = (r, chunk) => ({
|
|
1834
1851
|
...r,
|
|
1835
|
-
segments: r.segments.map((s) => ({
|
|
1852
|
+
segments: r.segments.map((s) => ({
|
|
1853
|
+
...s,
|
|
1854
|
+
chunkIndex: chunk.index,
|
|
1855
|
+
trustedStart: chunk.trustedStart
|
|
1856
|
+
}))
|
|
1836
1857
|
});
|
|
1837
1858
|
let llmChunkResults = [];
|
|
1838
1859
|
if (has(passes, "llm-transcribe")) {
|
|
1839
1860
|
logger.info("=== llm-transcribe ===");
|
|
1840
1861
|
let runChunks = chunks;
|
|
1841
|
-
if (options.onlyChunk !== void 0)
|
|
1842
|
-
|
|
1862
|
+
if (options.onlyChunk !== void 0)
|
|
1863
|
+
runChunks = chunks.filter((c) => c.index === options.onlyChunk);
|
|
1864
|
+
logger.info(
|
|
1865
|
+
`${runChunks.length} chunks (${options.chunkDurationSec}s, ${options.chunkOverlapSec}s overlap)`
|
|
1866
|
+
);
|
|
1843
1867
|
const client = new GeminiClient(keys.gemini);
|
|
1844
1868
|
const llmDir = `${options.intermediatesDir}/llm`;
|
|
1845
1869
|
mkdirSync(llmDir, { recursive: true });
|
|
@@ -1863,7 +1887,9 @@ async function transcribe(opts) {
|
|
|
1863
1887
|
previousTail = prev.segments.slice(-6).map((s) => `${s.speaker}: ${s.text}`).join("\n");
|
|
1864
1888
|
}
|
|
1865
1889
|
}
|
|
1866
|
-
logger.info(
|
|
1890
|
+
logger.info(
|
|
1891
|
+
`chunk ${chunk.index}: transcribing [${chunk.start.toFixed(0)}-${chunk.end.toFixed(0)}]s...`
|
|
1892
|
+
);
|
|
1867
1893
|
const result2 = await transcribeChunk(
|
|
1868
1894
|
client,
|
|
1869
1895
|
models.transcribe,
|
|
@@ -1880,7 +1906,10 @@ async function transcribe(opts) {
|
|
|
1880
1906
|
{ chunkDurationSec: chunk.end - chunk.start, validationRetries: 1 }
|
|
1881
1907
|
);
|
|
1882
1908
|
writeJson(parsedPath, result2);
|
|
1883
|
-
writeFileSync(
|
|
1909
|
+
writeFileSync(
|
|
1910
|
+
`${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}_raw.json`,
|
|
1911
|
+
result2.raw
|
|
1912
|
+
);
|
|
1884
1913
|
return tagWith(result2, chunk);
|
|
1885
1914
|
});
|
|
1886
1915
|
const errored = llmChunkResults.filter((r) => r.error);
|
|
@@ -1925,8 +1954,14 @@ async function transcribe(opts) {
|
|
|
1925
1954
|
writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);
|
|
1926
1955
|
} else {
|
|
1927
1956
|
logger.info("=== timestamped (AssemblyAI) ===");
|
|
1928
|
-
if (!keys.assemblyai)
|
|
1929
|
-
|
|
1957
|
+
if (!keys.assemblyai)
|
|
1958
|
+
throw new Error(
|
|
1959
|
+
"ASSEMBLYAI_API_KEY is required for the timestamped pass (or use --timestamped whisper-groq)"
|
|
1960
|
+
);
|
|
1961
|
+
const aai = new AssemblyAIProvider({
|
|
1962
|
+
apiKey: keys.assemblyai,
|
|
1963
|
+
cacheDir: `${options.intermediatesDir}/assemblyai`
|
|
1964
|
+
});
|
|
1930
1965
|
asrResult = await aai.transcribe(audioPath);
|
|
1931
1966
|
writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);
|
|
1932
1967
|
}
|
|
@@ -1970,7 +2005,11 @@ async function transcribe(opts) {
|
|
|
1970
2005
|
}
|
|
1971
2006
|
if (options.diarizationLevel >= 3 && has(passes, "identify") && keys.deepseek && description) {
|
|
1972
2007
|
logger.info("=== identify (DeepSeek) ===");
|
|
1973
|
-
const dsClient = OpenAICompatClient.fromProvider(
|
|
2008
|
+
const dsClient = OpenAICompatClient.fromProvider(
|
|
2009
|
+
"deepseek",
|
|
2010
|
+
keys.deepseek,
|
|
2011
|
+
models.reasoner
|
|
2012
|
+
);
|
|
1974
2013
|
const id = await identifySpeakers(
|
|
1975
2014
|
dsClient,
|
|
1976
2015
|
models.reasoner,
|
|
@@ -1979,7 +2018,9 @@ async function transcribe(opts) {
|
|
|
1979
2018
|
description.roster,
|
|
1980
2019
|
options.knownSpeakers
|
|
1981
2020
|
);
|
|
1982
|
-
logger.info(
|
|
2021
|
+
logger.info(
|
|
2022
|
+
`identified ${Object.keys(id.nameMap).length} speakers: ${JSON.stringify(id.nameMap)}`
|
|
2023
|
+
);
|
|
1983
2024
|
writeJson(`${options.intermediatesDir}/identified.json`, id);
|
|
1984
2025
|
segments = segments.map(
|
|
1985
2026
|
(s) => id.nameMap[s.speaker] ? { ...s, speakerName: id.nameMap[s.speaker] } : s
|
|
@@ -2010,9 +2051,18 @@ async function transcribe(opts) {
|
|
|
2010
2051
|
const result = { segments: finalSegments, speakers, metadata };
|
|
2011
2052
|
for (const fmt of options.formats) {
|
|
2012
2053
|
const base = basename3(options.input, ext(options.input));
|
|
2013
|
-
if (fmt === "srt")
|
|
2014
|
-
|
|
2015
|
-
|
|
2054
|
+
if (fmt === "srt")
|
|
2055
|
+
writeFileSync(
|
|
2056
|
+
`${options.outputDir}/${base}.srt`,
|
|
2057
|
+
formatSrt(result, { title: base })
|
|
2058
|
+
);
|
|
2059
|
+
if (fmt === "md")
|
|
2060
|
+
writeFileSync(
|
|
2061
|
+
`${options.outputDir}/${base}.md`,
|
|
2062
|
+
formatMarkdown(result, { title: base })
|
|
2063
|
+
);
|
|
2064
|
+
if (fmt === "json")
|
|
2065
|
+
writeFileSync(`${options.outputDir}/${base}.json`, formatJson(result));
|
|
2016
2066
|
}
|
|
2017
2067
|
logger.info(`outputs written to ${options.outputDir}`);
|
|
2018
2068
|
return result;
|