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.cjs
CHANGED
|
@@ -64,12 +64,14 @@ var MODELS = {
|
|
|
64
64
|
gemini25Pro: "gemini-2.5-pro",
|
|
65
65
|
gemini25Flash: "gemini-2.5-flash",
|
|
66
66
|
gemini3Pro: "gemini-3-pro-preview",
|
|
67
|
+
gemini31Pro: "gemini-3.1-pro-preview",
|
|
68
|
+
geminiFlashLatest: "gemini-flash-latest",
|
|
67
69
|
deepseek: "deepseek-chat",
|
|
68
70
|
deepseekReasoner: "deepseek-reasoner",
|
|
69
71
|
gpt4o: "gpt-4o",
|
|
70
72
|
claudeSonnet: "claude-sonnet-4-5"
|
|
71
73
|
};
|
|
72
|
-
var DEFAULT_TRANSCRIBE_MODEL = MODELS.
|
|
74
|
+
var DEFAULT_TRANSCRIBE_MODEL = MODELS.gemini31Pro;
|
|
73
75
|
var DEFAULT_REASONER_MODEL = MODELS.deepseek;
|
|
74
76
|
function resolveKeys(injected) {
|
|
75
77
|
const env = process.env;
|
|
@@ -86,7 +88,8 @@ function resolveKeys(injected) {
|
|
|
86
88
|
function resolveOptions(opts) {
|
|
87
89
|
return {
|
|
88
90
|
input: opts.input,
|
|
89
|
-
|
|
91
|
+
// Default: write next to the input file (e.g. meeting.md beside meeting.mp4) — no ./output folder.
|
|
92
|
+
outputDir: opts.outputDir ?? (0, import_node_path.dirname)((0, import_node_path.resolve)(opts.input)),
|
|
90
93
|
intermediatesDir: opts.intermediatesDir ?? deriveIntermediatesDir(opts.input),
|
|
91
94
|
instructions: opts.instructions,
|
|
92
95
|
knownSpeakers: opts.knownSpeakers,
|
|
@@ -106,7 +109,7 @@ function resolveOptions(opts) {
|
|
|
106
109
|
screenshotCount: opts.screenshotCount ?? 6,
|
|
107
110
|
concurrency: opts.concurrency ?? 4,
|
|
108
111
|
saveIntermediates: opts.saveIntermediates ?? true,
|
|
109
|
-
formats: opts.formats ?? ["
|
|
112
|
+
formats: opts.formats ?? ["md"],
|
|
110
113
|
diarizationLevel: opts.diarizationLevel ?? 2,
|
|
111
114
|
apiKeys: opts.apiKeys,
|
|
112
115
|
model: opts.model,
|
|
@@ -1749,10 +1752,9 @@ function has(passes, p) {
|
|
|
1749
1752
|
}
|
|
1750
1753
|
async function transcribe(opts) {
|
|
1751
1754
|
if (!opts || typeof opts.input !== "string" || opts.input.length === 0) {
|
|
1752
|
-
throw new Error(
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
throw new Error("transcribe(options): 'outputDir' (directory for outputs) is required");
|
|
1755
|
+
throw new Error(
|
|
1756
|
+
"transcribe(options): 'input' (path to the audio/video file) is required"
|
|
1757
|
+
);
|
|
1756
1758
|
}
|
|
1757
1759
|
const options = resolveOptions(opts);
|
|
1758
1760
|
const keys = resolveKeys(options.apiKeys);
|
|
@@ -1762,12 +1764,16 @@ async function transcribe(opts) {
|
|
|
1762
1764
|
}
|
|
1763
1765
|
(0, import_node_fs4.mkdirSync)(options.intermediatesDir, { recursive: true });
|
|
1764
1766
|
(0, import_node_fs4.mkdirSync)(options.outputDir, { recursive: true });
|
|
1765
|
-
logger.info(
|
|
1767
|
+
logger.info(
|
|
1768
|
+
`intermediates: ${(0, import_node_path5.resolve)(options.intermediatesDir)} (file://${(0, import_node_path5.resolve)(options.intermediatesDir)})`
|
|
1769
|
+
);
|
|
1766
1770
|
setLlmLogPath(options.llmLog ? `${options.intermediatesDir}/llm-calls.jsonl` : null);
|
|
1767
1771
|
const sourcePath = `${options.intermediatesDir}/source.json`;
|
|
1768
1772
|
const sig = inputSignature(options.input);
|
|
1769
1773
|
const cfgSig = configSignature(opts);
|
|
1770
|
-
const prevSig = readJson(
|
|
1774
|
+
const prevSig = readJson(
|
|
1775
|
+
sourcePath
|
|
1776
|
+
);
|
|
1771
1777
|
const inputChanged = !prevSig || prevSig.signature !== sig;
|
|
1772
1778
|
const configChanged = !prevSig || prevSig.config !== cfgSig;
|
|
1773
1779
|
if (inputChanged && prevSig) {
|
|
@@ -1851,7 +1857,13 @@ async function transcribe(opts) {
|
|
|
1851
1857
|
if ((0, import_node_fs4.existsSync)(p)) files.push({ path: p });
|
|
1852
1858
|
}
|
|
1853
1859
|
}
|
|
1854
|
-
description = await describeMeeting(
|
|
1860
|
+
description = await describeMeeting(
|
|
1861
|
+
client,
|
|
1862
|
+
models.transcribe,
|
|
1863
|
+
files,
|
|
1864
|
+
(0, import_node_path5.basename)(options.input),
|
|
1865
|
+
options.instructions
|
|
1866
|
+
);
|
|
1855
1867
|
writeJson(descPath, description);
|
|
1856
1868
|
logger.info(`description: ${description.description.slice(0, 120)}...`);
|
|
1857
1869
|
}
|
|
@@ -1864,27 +1876,39 @@ async function transcribe(opts) {
|
|
|
1864
1876
|
let silences = [];
|
|
1865
1877
|
try {
|
|
1866
1878
|
silences = await detectSilence(audioPath, { noiseDb: -15, minDuration: 0.3 });
|
|
1867
|
-
if (silences.length < 3)
|
|
1879
|
+
if (silences.length < 3)
|
|
1880
|
+
silences = await detectSilence(audioPath, { noiseDb: -12, minDuration: 0.25 });
|
|
1868
1881
|
} catch {
|
|
1869
1882
|
}
|
|
1870
1883
|
chunks = planChunks(duration, options.chunkDurationSec, options.chunkOverlapSec);
|
|
1871
1884
|
if (silences.length > 3) {
|
|
1872
1885
|
chunks = chunks.map((c) => {
|
|
1873
|
-
const snapped = snapToSilence(
|
|
1886
|
+
const snapped = snapToSilence(
|
|
1887
|
+
c.start,
|
|
1888
|
+
silences,
|
|
1889
|
+
Math.min(10, options.chunkOverlapSec / 2)
|
|
1890
|
+
);
|
|
1874
1891
|
return { ...c, start: snapped, trustedStart: snapped + c.overlapWithPrevious };
|
|
1875
1892
|
});
|
|
1876
1893
|
}
|
|
1877
1894
|
}
|
|
1878
1895
|
const tagWith = (r, chunk) => ({
|
|
1879
1896
|
...r,
|
|
1880
|
-
segments: r.segments.map((s) => ({
|
|
1897
|
+
segments: r.segments.map((s) => ({
|
|
1898
|
+
...s,
|
|
1899
|
+
chunkIndex: chunk.index,
|
|
1900
|
+
trustedStart: chunk.trustedStart
|
|
1901
|
+
}))
|
|
1881
1902
|
});
|
|
1882
1903
|
let llmChunkResults = [];
|
|
1883
1904
|
if (has(passes, "llm-transcribe")) {
|
|
1884
1905
|
logger.info("=== llm-transcribe ===");
|
|
1885
1906
|
let runChunks = chunks;
|
|
1886
|
-
if (options.onlyChunk !== void 0)
|
|
1887
|
-
|
|
1907
|
+
if (options.onlyChunk !== void 0)
|
|
1908
|
+
runChunks = chunks.filter((c) => c.index === options.onlyChunk);
|
|
1909
|
+
logger.info(
|
|
1910
|
+
`${runChunks.length} chunks (${options.chunkDurationSec}s, ${options.chunkOverlapSec}s overlap)`
|
|
1911
|
+
);
|
|
1888
1912
|
const client = new GeminiClient(keys.gemini);
|
|
1889
1913
|
const llmDir = `${options.intermediatesDir}/llm`;
|
|
1890
1914
|
(0, import_node_fs4.mkdirSync)(llmDir, { recursive: true });
|
|
@@ -1908,7 +1932,9 @@ async function transcribe(opts) {
|
|
|
1908
1932
|
previousTail = prev.segments.slice(-6).map((s) => `${s.speaker}: ${s.text}`).join("\n");
|
|
1909
1933
|
}
|
|
1910
1934
|
}
|
|
1911
|
-
logger.info(
|
|
1935
|
+
logger.info(
|
|
1936
|
+
`chunk ${chunk.index}: transcribing [${chunk.start.toFixed(0)}-${chunk.end.toFixed(0)}]s...`
|
|
1937
|
+
);
|
|
1912
1938
|
const result2 = await transcribeChunk(
|
|
1913
1939
|
client,
|
|
1914
1940
|
models.transcribe,
|
|
@@ -1925,7 +1951,10 @@ async function transcribe(opts) {
|
|
|
1925
1951
|
{ chunkDurationSec: chunk.end - chunk.start, validationRetries: 1 }
|
|
1926
1952
|
);
|
|
1927
1953
|
writeJson(parsedPath, result2);
|
|
1928
|
-
(0, import_node_fs4.writeFileSync)(
|
|
1954
|
+
(0, import_node_fs4.writeFileSync)(
|
|
1955
|
+
`${llmDir}/chunk_${String(chunk.index).padStart(2, "0")}_raw.json`,
|
|
1956
|
+
result2.raw
|
|
1957
|
+
);
|
|
1929
1958
|
return tagWith(result2, chunk);
|
|
1930
1959
|
});
|
|
1931
1960
|
const errored = llmChunkResults.filter((r) => r.error);
|
|
@@ -1970,8 +1999,14 @@ async function transcribe(opts) {
|
|
|
1970
1999
|
writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);
|
|
1971
2000
|
} else {
|
|
1972
2001
|
logger.info("=== timestamped (AssemblyAI) ===");
|
|
1973
|
-
if (!keys.assemblyai)
|
|
1974
|
-
|
|
2002
|
+
if (!keys.assemblyai)
|
|
2003
|
+
throw new Error(
|
|
2004
|
+
"ASSEMBLYAI_API_KEY is required for the timestamped pass (or use --timestamped whisper-groq)"
|
|
2005
|
+
);
|
|
2006
|
+
const aai = new AssemblyAIProvider({
|
|
2007
|
+
apiKey: keys.assemblyai,
|
|
2008
|
+
cacheDir: `${options.intermediatesDir}/assemblyai`
|
|
2009
|
+
});
|
|
1975
2010
|
asrResult = await aai.transcribe(audioPath);
|
|
1976
2011
|
writeJson(`${options.intermediatesDir}/timestamped.json`, asrResult);
|
|
1977
2012
|
}
|
|
@@ -2015,7 +2050,11 @@ async function transcribe(opts) {
|
|
|
2015
2050
|
}
|
|
2016
2051
|
if (options.diarizationLevel >= 3 && has(passes, "identify") && keys.deepseek && description) {
|
|
2017
2052
|
logger.info("=== identify (DeepSeek) ===");
|
|
2018
|
-
const dsClient = OpenAICompatClient.fromProvider(
|
|
2053
|
+
const dsClient = OpenAICompatClient.fromProvider(
|
|
2054
|
+
"deepseek",
|
|
2055
|
+
keys.deepseek,
|
|
2056
|
+
models.reasoner
|
|
2057
|
+
);
|
|
2019
2058
|
const id = await identifySpeakers(
|
|
2020
2059
|
dsClient,
|
|
2021
2060
|
models.reasoner,
|
|
@@ -2024,7 +2063,9 @@ async function transcribe(opts) {
|
|
|
2024
2063
|
description.roster,
|
|
2025
2064
|
options.knownSpeakers
|
|
2026
2065
|
);
|
|
2027
|
-
logger.info(
|
|
2066
|
+
logger.info(
|
|
2067
|
+
`identified ${Object.keys(id.nameMap).length} speakers: ${JSON.stringify(id.nameMap)}`
|
|
2068
|
+
);
|
|
2028
2069
|
writeJson(`${options.intermediatesDir}/identified.json`, id);
|
|
2029
2070
|
segments = segments.map(
|
|
2030
2071
|
(s) => id.nameMap[s.speaker] ? { ...s, speakerName: id.nameMap[s.speaker] } : s
|
|
@@ -2055,9 +2096,18 @@ async function transcribe(opts) {
|
|
|
2055
2096
|
const result = { segments: finalSegments, speakers, metadata };
|
|
2056
2097
|
for (const fmt of options.formats) {
|
|
2057
2098
|
const base = (0, import_node_path5.basename)(options.input, ext(options.input));
|
|
2058
|
-
if (fmt === "srt")
|
|
2059
|
-
|
|
2060
|
-
|
|
2099
|
+
if (fmt === "srt")
|
|
2100
|
+
(0, import_node_fs4.writeFileSync)(
|
|
2101
|
+
`${options.outputDir}/${base}.srt`,
|
|
2102
|
+
formatSrt(result, { title: base })
|
|
2103
|
+
);
|
|
2104
|
+
if (fmt === "md")
|
|
2105
|
+
(0, import_node_fs4.writeFileSync)(
|
|
2106
|
+
`${options.outputDir}/${base}.md`,
|
|
2107
|
+
formatMarkdown(result, { title: base })
|
|
2108
|
+
);
|
|
2109
|
+
if (fmt === "json")
|
|
2110
|
+
(0, import_node_fs4.writeFileSync)(`${options.outputDir}/${base}.json`, formatJson(result));
|
|
2061
2111
|
}
|
|
2062
2112
|
logger.info(`outputs written to ${options.outputDir}`);
|
|
2063
2113
|
return result;
|