offmute-v2 0.0.1-opus.0
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 +120 -0
- package/dist/browser.d.ts +740 -0
- package/dist/browser.js +1494 -0
- package/dist/browser.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1529 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +513 -0
- package/dist/index.js +1533 -0
- package/dist/index.js.map +1 -0
- package/package.json +77 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core data model for offmute-v2.
|
|
3
|
+
*
|
|
4
|
+
* Two "tracks" get fused:
|
|
5
|
+
* - the TIMING track (from ASR): word/utterance level timestamps + candidate speaker turns.
|
|
6
|
+
* - the CONTENT track (from a multimodal LLM): clean diarized text, names, tone.
|
|
7
|
+
* Alignment maps timing onto content to produce the final Transcript.
|
|
8
|
+
*/
|
|
9
|
+
/** A single word with timing, as produced by an ASR provider. */
|
|
10
|
+
interface TimedWord {
|
|
11
|
+
text: string;
|
|
12
|
+
/** seconds from start of media */
|
|
13
|
+
start: number;
|
|
14
|
+
/** seconds from start of media */
|
|
15
|
+
end: number;
|
|
16
|
+
/** ASR speaker label if diarization was on (e.g. "A", "B") */
|
|
17
|
+
speaker?: string;
|
|
18
|
+
/** 0..1 ASR confidence */
|
|
19
|
+
confidence?: number;
|
|
20
|
+
}
|
|
21
|
+
/** An ASR utterance = a contiguous run of words by one ASR speaker. */
|
|
22
|
+
interface AsrUtterance {
|
|
23
|
+
text: string;
|
|
24
|
+
start: number;
|
|
25
|
+
end: number;
|
|
26
|
+
/** ASR speaker label (e.g. "A") */
|
|
27
|
+
speaker: string;
|
|
28
|
+
confidence?: number;
|
|
29
|
+
/** Per-utterance words — OPTIONAL on purpose: alignment uses the flat
|
|
30
|
+
* AsrResult.words instead, and not every provider/config populates this. */
|
|
31
|
+
words?: TimedWord[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Normalized result from any ASR provider. We keep TWO views of the same audio
|
|
35
|
+
* because they feed different consumers:
|
|
36
|
+
* - `words`: flat, ungrouped word stream — the substrate the LLM transcript is
|
|
37
|
+
* aligned against to read precise timings. (Required.)
|
|
38
|
+
* - `utterances`: speaker-grouped turns — used to build the prompt's "ASR hint"
|
|
39
|
+
* and to render the provider's own diarization. (Required.)
|
|
40
|
+
*/
|
|
41
|
+
interface AsrResult {
|
|
42
|
+
provider: string;
|
|
43
|
+
/** model / config used, for provenance */
|
|
44
|
+
model?: string;
|
|
45
|
+
words: TimedWord[];
|
|
46
|
+
utterances: AsrUtterance[];
|
|
47
|
+
/** distinct ASR speaker labels observed */
|
|
48
|
+
speakers: string[];
|
|
49
|
+
durationSeconds: number;
|
|
50
|
+
language?: string;
|
|
51
|
+
/** whether diarization (speaker labels) was actually available */
|
|
52
|
+
diarized: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** A diarized line as emitted by the LLM for a chunk (timestamps are rough/optional). */
|
|
55
|
+
interface LlmLine {
|
|
56
|
+
/** speaker as the LLM sees it — a name ("Hrishi") or anonymous ("Speaker 1") */
|
|
57
|
+
speaker: string;
|
|
58
|
+
text: string;
|
|
59
|
+
/** optional tone/emotion annotation, e.g. "hesitant", "laughing" */
|
|
60
|
+
tone?: string;
|
|
61
|
+
/** rough start (seconds, absolute) if the LLM provided one — NOT authoritative */
|
|
62
|
+
approxStart?: number;
|
|
63
|
+
approxEnd?: number;
|
|
64
|
+
/** which chunk this came from */
|
|
65
|
+
chunkIndex?: number;
|
|
66
|
+
}
|
|
67
|
+
type TimingSource = "asr" | "llm" | "interpolated";
|
|
68
|
+
/** A speaker in the final transcript. */
|
|
69
|
+
interface Speaker {
|
|
70
|
+
/** stable internal id, e.g. "S1" */
|
|
71
|
+
id: string;
|
|
72
|
+
/** display label — a resolved name ("Hrishi") or "Speaker A" */
|
|
73
|
+
label: string;
|
|
74
|
+
/** has this reached identification level 3 (real name)? */
|
|
75
|
+
named: boolean;
|
|
76
|
+
/** ASR labels that map to this speaker */
|
|
77
|
+
asrLabels?: string[];
|
|
78
|
+
/** short description (role/appearance/voice) if inferred */
|
|
79
|
+
description?: string;
|
|
80
|
+
}
|
|
81
|
+
/** The unit of the final transcript. */
|
|
82
|
+
interface TranscriptSegment {
|
|
83
|
+
id: number;
|
|
84
|
+
/** seconds, authoritative timing after alignment */
|
|
85
|
+
start: number;
|
|
86
|
+
end: number;
|
|
87
|
+
/** resolved speaker id (see Transcript.speakers) */
|
|
88
|
+
speakerId: string;
|
|
89
|
+
text: string;
|
|
90
|
+
/** tone/emotion annotation if any */
|
|
91
|
+
tone?: string;
|
|
92
|
+
timingSource: TimingSource;
|
|
93
|
+
/** 0..1 — how confident the text↔timing alignment was for this segment */
|
|
94
|
+
alignmentConfidence?: number;
|
|
95
|
+
}
|
|
96
|
+
/** A record of one LLM call, for debugging/inspection (prompt + response + usage). */
|
|
97
|
+
interface LlmCallRecord {
|
|
98
|
+
/** which stage made the call, e.g. "diarize", "diarize-chunk-2", "identify" */
|
|
99
|
+
label?: string;
|
|
100
|
+
model: string;
|
|
101
|
+
/** the text portion(s) of the prompt (files are noted, not inlined) */
|
|
102
|
+
promptText: string;
|
|
103
|
+
/** number of non-text (file/image) parts sent */
|
|
104
|
+
fileParts?: number;
|
|
105
|
+
responseText: string;
|
|
106
|
+
usage?: {
|
|
107
|
+
inputTokens?: number;
|
|
108
|
+
outputTokens?: number;
|
|
109
|
+
thoughtsTokens?: number;
|
|
110
|
+
};
|
|
111
|
+
error?: string;
|
|
112
|
+
}
|
|
113
|
+
interface TranscriptMetadata {
|
|
114
|
+
source: string;
|
|
115
|
+
durationSeconds: number;
|
|
116
|
+
processedAt: string;
|
|
117
|
+
asrProvider?: string;
|
|
118
|
+
llmModel?: string;
|
|
119
|
+
userInstructions?: string;
|
|
120
|
+
language?: string;
|
|
121
|
+
}
|
|
122
|
+
interface Transcript {
|
|
123
|
+
segments: TranscriptSegment[];
|
|
124
|
+
speakers: Speaker[];
|
|
125
|
+
metadata: TranscriptMetadata;
|
|
126
|
+
}
|
|
127
|
+
interface TimeChunk {
|
|
128
|
+
index: number;
|
|
129
|
+
startSeconds: number;
|
|
130
|
+
endSeconds: number;
|
|
131
|
+
}
|
|
132
|
+
interface MediaChunk extends TimeChunk {
|
|
133
|
+
/** path (node) or handle to the extracted audio for this chunk */
|
|
134
|
+
audioPath: string;
|
|
135
|
+
/** optional keyframe image paths covering this chunk */
|
|
136
|
+
keyframePaths?: string[];
|
|
137
|
+
}
|
|
138
|
+
interface MediaInfo {
|
|
139
|
+
durationSeconds: number;
|
|
140
|
+
hasVideo: boolean;
|
|
141
|
+
hasAudio: boolean;
|
|
142
|
+
width?: number;
|
|
143
|
+
height?: number;
|
|
144
|
+
videoCodec?: string;
|
|
145
|
+
audioCodec?: string;
|
|
146
|
+
sampleRate?: number;
|
|
147
|
+
channels?: number;
|
|
148
|
+
sizeBytes?: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Timestamp helpers. Browser-safe (no node deps). */
|
|
152
|
+
/** seconds -> "HH:MM:SS,mmm" (SRT style, comma decimal). */
|
|
153
|
+
declare function secondsToSrtTime(seconds: number): string;
|
|
154
|
+
/** "HH:MM:SS,mmm" or "HH:MM:SS.mmm" or "MM:SS" -> seconds. */
|
|
155
|
+
declare function srtTimeToSeconds(timestamp: string): number;
|
|
156
|
+
/** "mm:ss" relative timestamp -> seconds, or null. Tolerates "h:mm:ss" too. */
|
|
157
|
+
declare function relTimeToSeconds(timeStr: string): number | null;
|
|
158
|
+
/** seconds -> "M:SS" compact (for markdown headers). */
|
|
159
|
+
declare function secondsToCompact(seconds: number): string;
|
|
160
|
+
/** Format "start --> end" SRT timing line. */
|
|
161
|
+
declare function formatSrtTiming(start: number, end: number): string;
|
|
162
|
+
|
|
163
|
+
interface SrtCue {
|
|
164
|
+
id: number;
|
|
165
|
+
start: number;
|
|
166
|
+
end: number;
|
|
167
|
+
/** full text (may contain a leading "Speaker: " prefix) */
|
|
168
|
+
text: string;
|
|
169
|
+
/** speaker parsed from a leading "Name: " prefix, if present */
|
|
170
|
+
speaker?: string;
|
|
171
|
+
/** text with the speaker prefix stripped */
|
|
172
|
+
body: string;
|
|
173
|
+
}
|
|
174
|
+
/** Split a "Speaker: text" line into {speaker, body}. Heuristic, conservative. */
|
|
175
|
+
declare function splitSpeakerPrefix(text: string): {
|
|
176
|
+
speaker?: string;
|
|
177
|
+
body: string;
|
|
178
|
+
};
|
|
179
|
+
/** Parse an SRT string into cues. Lenient about blank lines / numbering. */
|
|
180
|
+
declare function parseSrt(content: string): SrtCue[];
|
|
181
|
+
interface SrtFormatOptions {
|
|
182
|
+
/** include "Speaker: " prefix in each cue body */
|
|
183
|
+
includeSpeaker?: boolean;
|
|
184
|
+
}
|
|
185
|
+
/** Format cues (with explicit speaker) into an SRT string. */
|
|
186
|
+
declare function formatSrt(cues: Array<{
|
|
187
|
+
start: number;
|
|
188
|
+
end: number;
|
|
189
|
+
speaker?: string;
|
|
190
|
+
text: string;
|
|
191
|
+
}>, options?: SrtFormatOptions): string;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Alignment layer — the crux of offmute-v2.
|
|
195
|
+
*
|
|
196
|
+
* The multimodal LLM gives high-quality diarized text but only coarse/sparse
|
|
197
|
+
* timestamps. The ASR gives precise word-level timings but unreliable diarization.
|
|
198
|
+
* We align the LLM's token stream to the ASR's word stream (both describe the same
|
|
199
|
+
* audio, so the sequences are ~90%+ similar) and read precise timings off the ASR
|
|
200
|
+
* words that match each LLM segment. This is "forced alignment" using an existing
|
|
201
|
+
* ASR transcript as the timing reference rather than an acoustic model.
|
|
202
|
+
*
|
|
203
|
+
* Browser-safe (pure functions, no deps).
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
/** Normalize a token for matching: lowercase, strip non-alphanumerics. */
|
|
207
|
+
declare function normalizeToken(s: string): string;
|
|
208
|
+
/** Split text into raw word tokens (keeps surface form). */
|
|
209
|
+
declare function tokenize(text: string): string[];
|
|
210
|
+
interface AlignPair {
|
|
211
|
+
/** index into sequence A (LLM tokens), or null if A had a gap (ASR-only word) */
|
|
212
|
+
ai: number | null;
|
|
213
|
+
/** index into sequence B (ASR words), or null if B had a gap (LLM-only token) */
|
|
214
|
+
bi: number | null;
|
|
215
|
+
/** true if ai and bi are a real (normalized-equal) match */
|
|
216
|
+
match: boolean;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Global sequence alignment (Needleman–Wunsch) of two token sequences `a` (LLM
|
|
220
|
+
* tokens) and `b` (ASR words). Returns the alignment path: a list of pairs that
|
|
221
|
+
* each consume one token from `a` (a diagonal/up move) and/or one from `b`
|
|
222
|
+
* (diagonal/left), so reading the pairs in order reconstructs how the two
|
|
223
|
+
* sequences line up. Reference: https://en.wikipedia.org/wiki/Needleman–Wunsch_algorithm
|
|
224
|
+
*
|
|
225
|
+
* How it works (textbook NW, O(n·m) time and space):
|
|
226
|
+
* 1. `score[i][j]` = best alignment score of a[0..i) against b[0..j). The first
|
|
227
|
+
* row/column are seeded with cumulative gap penalties (aligning a prefix to
|
|
228
|
+
* nothing costs one gap per token).
|
|
229
|
+
* 2. Fill each cell as the best of three moves:
|
|
230
|
+
* diagonal = score[i-1][j-1] + (a[i-1]==b[j-1] ? MATCH : MISMATCH) // consume both
|
|
231
|
+
* up = score[i-1][j] + GAP // consume a[i-1], skip b
|
|
232
|
+
* left = score[i][j-1] + GAP // consume b[j-1], skip a
|
|
233
|
+
* `back[i][j]` remembers which move won (0=diag, 1=up, 2=left); ties prefer diag.
|
|
234
|
+
* 3. Trace `back` from the bottom-right (n,m) to (0,0) and reverse to get the path.
|
|
235
|
+
*
|
|
236
|
+
* Matrices are flat Int32Array/Uint8Array (compact, ~5 bytes/cell) but this is
|
|
237
|
+
* still full O(n·m) memory — there is NO banding/Hirschberg here. That is fine per
|
|
238
|
+
* chunk (a few thousand tokens ⇒ tens of MB); whole-file alignment is done per
|
|
239
|
+
* chunk to keep n·m bounded. (Add a banded/Hirschberg variant only if single-shot
|
|
240
|
+
* alignment of very long inputs is ever needed.)
|
|
241
|
+
*/
|
|
242
|
+
declare function alignTokens(a: string[], b: string[]): AlignPair[];
|
|
243
|
+
interface AlignedToken {
|
|
244
|
+
/** original LLM surface token (with punctuation) */
|
|
245
|
+
surface: string;
|
|
246
|
+
norm: string;
|
|
247
|
+
/** index of the turn this token belongs to */
|
|
248
|
+
turnIndex: number;
|
|
249
|
+
/** matched ASR word time (seconds), or null if unmatched (filled by interpolation) */
|
|
250
|
+
start: number | null;
|
|
251
|
+
end: number | null;
|
|
252
|
+
matched: boolean;
|
|
253
|
+
/** ASR speaker label of the matched word (for voice-anchored identity) */
|
|
254
|
+
asrSpeaker?: string;
|
|
255
|
+
}
|
|
256
|
+
/** Something with text we can tokenize (an LLM turn). */
|
|
257
|
+
interface HasText {
|
|
258
|
+
text: string;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Align the concatenated LLM turn token stream to ASR words and return every LLM
|
|
262
|
+
* token tagged with its turn index and matched ASR time (null where unmatched).
|
|
263
|
+
*/
|
|
264
|
+
declare function alignLlmToAsr(turns: HasText[], asrWords: TimedWord[]): AlignedToken[];
|
|
265
|
+
/**
|
|
266
|
+
* Fill null token times by interpolating between matched neighbors. Tokens before
|
|
267
|
+
* the first match take the first matched start; after the last match take the last
|
|
268
|
+
* matched end. Returns the same array (mutated).
|
|
269
|
+
*/
|
|
270
|
+
declare function fillTokenTimes(tokens: AlignedToken[], totalDuration: number): AlignedToken[];
|
|
271
|
+
interface AlignedSegment {
|
|
272
|
+
turnIndex: number;
|
|
273
|
+
start: number;
|
|
274
|
+
end: number;
|
|
275
|
+
text: string;
|
|
276
|
+
/** fraction of tokens that matched an ASR word */
|
|
277
|
+
matchRatio: number;
|
|
278
|
+
tokenCount: number;
|
|
279
|
+
matchedTokens: number;
|
|
280
|
+
}
|
|
281
|
+
interface SegmentOptions {
|
|
282
|
+
/** split into display-sized cues (sentence / gap / length). Default false = one segment per turn. */
|
|
283
|
+
subSegment?: boolean;
|
|
284
|
+
/** max characters per display cue */
|
|
285
|
+
maxChars?: number;
|
|
286
|
+
/** max seconds per display cue */
|
|
287
|
+
maxDuration?: number;
|
|
288
|
+
/** split when the gap before the next token exceeds this (seconds) */
|
|
289
|
+
gapSplit?: number;
|
|
290
|
+
/** minimum characters before allowing a sentence-boundary split */
|
|
291
|
+
minChars?: number;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Group aligned tokens into output segments. Tokens already carry filled times.
|
|
295
|
+
* One segment per turn by default; if subSegment, cut turns into readable cues.
|
|
296
|
+
*/
|
|
297
|
+
declare function buildSegmentsFromTokens(turns: HasText[], tokens: AlignedToken[], options?: SegmentOptions): AlignedSegment[];
|
|
298
|
+
/**
|
|
299
|
+
* For each LLM turn label, count which ASR speakers its matched words belong to.
|
|
300
|
+
* Used for voice-anchored speaker canonicalization (labels sharing a dominant ASR
|
|
301
|
+
* speaker are likely the same person, even if the LLM labeled them inconsistently).
|
|
302
|
+
*/
|
|
303
|
+
declare function asrSpeakerByLabel(tokens: AlignedToken[], labelByTurn: string[]): Record<string, Record<string, number>>;
|
|
304
|
+
|
|
305
|
+
/** Output formatters: Transcript -> SRT / Markdown / JSON. Browser-safe. */
|
|
306
|
+
|
|
307
|
+
interface SrtOptions {
|
|
308
|
+
/** include "Speaker: " prefix (default true) */
|
|
309
|
+
includeSpeaker?: boolean;
|
|
310
|
+
/** include tone annotations inline (default false for SRT) */
|
|
311
|
+
includeTone?: boolean;
|
|
312
|
+
}
|
|
313
|
+
/** Make text safe for one SRT cue: collapse blank lines (they separate cues) + trim. */
|
|
314
|
+
declare function srtCueText(s: string): string;
|
|
315
|
+
declare function toSRT(transcript: Transcript, options?: SrtOptions): string;
|
|
316
|
+
interface MarkdownOptions {
|
|
317
|
+
includeTimestamps?: boolean;
|
|
318
|
+
includeTone?: boolean;
|
|
319
|
+
title?: string;
|
|
320
|
+
/** merge consecutive segments by the same speaker into one paragraph */
|
|
321
|
+
mergeBySpeaker?: boolean;
|
|
322
|
+
}
|
|
323
|
+
declare function toMarkdown(transcript: Transcript, options?: MarkdownOptions): string;
|
|
324
|
+
declare function toJSON(transcript: Transcript): string;
|
|
325
|
+
/** A compact plain-text transcript (no markdown). */
|
|
326
|
+
declare function toText(transcript: Transcript, options?: {
|
|
327
|
+
includeTimestamps?: boolean;
|
|
328
|
+
}): string;
|
|
329
|
+
|
|
330
|
+
/** Speaker canonicalization. Browser-safe (deterministic base; LLM pass lives in pipeline). */
|
|
331
|
+
|
|
332
|
+
declare function slugLabel(label: string): string;
|
|
333
|
+
declare function isProvisional(label: string): boolean;
|
|
334
|
+
interface BuildSpeakersOptions {
|
|
335
|
+
/** explicit canonical name per raw label (overrides) */
|
|
336
|
+
knownSpeakers?: Record<string, string>;
|
|
337
|
+
/** resolved-name map: raw label -> identified name (e.g. {"Speaker 1": "Rishi"}) from the identify pass */
|
|
338
|
+
resolvedNames?: Record<string, string>;
|
|
339
|
+
/** descriptions per canonical label */
|
|
340
|
+
descriptions?: Record<string, string>;
|
|
341
|
+
}
|
|
342
|
+
interface BuiltSpeakers {
|
|
343
|
+
speakers: Speaker[];
|
|
344
|
+
/** raw turn label -> speaker id */
|
|
345
|
+
labelToId: Map<string, string>;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Build canonical speakers from the raw turn labels (in order of first appearance).
|
|
349
|
+
* Applies resolvedNames (merge provisional labels into a name) and known-speaker overrides.
|
|
350
|
+
*/
|
|
351
|
+
declare function buildSpeakers(rawLabels: string[], options?: BuildSpeakersOptions): BuiltSpeakers;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Lenient parser for the LLM's diarized text format:
|
|
355
|
+
* [mm:ss] Speaker: (tone) text
|
|
356
|
+
* Tolerates missing timestamps, missing tone, and continuation lines.
|
|
357
|
+
* Browser-safe.
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
declare function parseDiarizedText(raw: string): LlmLine[];
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Prompt construction for the diarization (content) pass. Browser-safe.
|
|
364
|
+
*
|
|
365
|
+
* We ask for a plain-text diarized transcript in the format
|
|
366
|
+
* [mm:ss] Speaker: (tone) text
|
|
367
|
+
* rather than JSON: long transcripts can exceed output limits, and text degrades
|
|
368
|
+
* gracefully under truncation (you lose the tail, not the whole parse), whereas a
|
|
369
|
+
* truncated JSON array is unrecoverable. The lenient parser (parse-diarized.ts)
|
|
370
|
+
* tolerates the variations. (Hard-won lesson from ipgu's parser pain.)
|
|
371
|
+
*/
|
|
372
|
+
|
|
373
|
+
interface DiarizationPromptInput {
|
|
374
|
+
/** user instructions (speaker hints, focus, grouping rules) */
|
|
375
|
+
instructions?: string;
|
|
376
|
+
/** compact ASR diarized transcript used as a HINT (not authority) */
|
|
377
|
+
asrHint?: string;
|
|
378
|
+
/** for chunked processing: which chunk and how many */
|
|
379
|
+
chunk?: {
|
|
380
|
+
index: number;
|
|
381
|
+
total: number;
|
|
382
|
+
startSeconds: number;
|
|
383
|
+
};
|
|
384
|
+
/** tail of the previous chunk's transcript for continuity */
|
|
385
|
+
previousTail?: string;
|
|
386
|
+
}
|
|
387
|
+
declare const DIARIZATION_SYSTEM = "You are an expert meeting transcriptionist and diarizer. You transcribe verbatim (including filler words and false starts), attribute every utterance to the correct speaker, and you are careful and literal. You never invent content you cannot hear.";
|
|
388
|
+
declare function buildDiarizationPrompt(input: DiarizationPromptInput): string;
|
|
389
|
+
/** Build a compact ASR hint string from utterances, trimming long ones. */
|
|
390
|
+
declare function buildAsrHint(asr: AsrResult, maxUtterances?: number, maxCharsPerUtterance?: number): string;
|
|
391
|
+
|
|
392
|
+
interface ProgressEvent {
|
|
393
|
+
stage: string;
|
|
394
|
+
message: string;
|
|
395
|
+
pct?: number;
|
|
396
|
+
}
|
|
397
|
+
interface TranscribeOptions {
|
|
398
|
+
instructions?: string;
|
|
399
|
+
asr?: "assemblyai" | "none";
|
|
400
|
+
asrModel?: string;
|
|
401
|
+
llmModel?: string;
|
|
402
|
+
/** thinking level for the LLM (Gemini 3.x): MINIMAL|LOW|MEDIUM|HIGH (default MINIMAL).
|
|
403
|
+
* NOTE: LOW+ can over-think on long audio and starve the output — MINIMAL is reliable. */
|
|
404
|
+
llmThinkingLevel?: "MINIMAL" | "LOW" | "MEDIUM" | "HIGH";
|
|
405
|
+
useVideo?: boolean;
|
|
406
|
+
keyframeCount?: number;
|
|
407
|
+
/** split turns into display-sized cues (default true) */
|
|
408
|
+
subSegment?: boolean;
|
|
409
|
+
/** run the LLM speaker-identification/merge pass (default true) */
|
|
410
|
+
identifySpeakers?: boolean;
|
|
411
|
+
knownSpeakers?: Record<string, string>;
|
|
412
|
+
intermediatesDir?: string;
|
|
413
|
+
cache?: boolean;
|
|
414
|
+
onProgress?: (e: ProgressEvent) => void;
|
|
415
|
+
/** invoked once per LLM call with its prompt/response/usage (for inspection/debug) */
|
|
416
|
+
onLlmCall?: (rec: LlmCallRecord) => void;
|
|
417
|
+
/** write every LLM call (prompt + response) to intermediates/llm/ (default true) */
|
|
418
|
+
logLlm?: boolean;
|
|
419
|
+
/** cancel the run (cooperatively, at stage and chunk boundaries) */
|
|
420
|
+
signal?: AbortSignal;
|
|
421
|
+
apiKeys?: {
|
|
422
|
+
gemini?: string;
|
|
423
|
+
assemblyai?: string;
|
|
424
|
+
};
|
|
425
|
+
/** force chunking threshold in minutes (default 35; longer files are chunked) */
|
|
426
|
+
maxSinglePassMinutes?: number;
|
|
427
|
+
/** chunk length in minutes when chunking (default 15) */
|
|
428
|
+
chunkMinutes?: number;
|
|
429
|
+
/** overlap between chunks in minutes (default 2) */
|
|
430
|
+
chunkOverlapMinutes?: number;
|
|
431
|
+
}
|
|
432
|
+
interface TranscribeResult {
|
|
433
|
+
transcript: Transcript;
|
|
434
|
+
srt: string;
|
|
435
|
+
markdown: string;
|
|
436
|
+
json: string;
|
|
437
|
+
/** plain-text transcript (speaker-grouped) */
|
|
438
|
+
text: string;
|
|
439
|
+
intermediatesDir: string;
|
|
440
|
+
asr?: AsrResult;
|
|
441
|
+
}
|
|
442
|
+
declare function transcribe(input: string, options?: TranscribeOptions): Promise<TranscribeResult>;
|
|
443
|
+
|
|
444
|
+
interface AssemblyAiOptions {
|
|
445
|
+
apiKey?: string;
|
|
446
|
+
/** enable speaker diarization (default true) */
|
|
447
|
+
speakerLabels?: boolean;
|
|
448
|
+
/** hint for number of speakers (optional) */
|
|
449
|
+
speakersExpected?: number;
|
|
450
|
+
/** model tier / speech model, e.g. "best" | "nano" | "universal" (provider default if unset) */
|
|
451
|
+
speechModel?: string;
|
|
452
|
+
/** language code hint, e.g. "en" */
|
|
453
|
+
languageCode?: string;
|
|
454
|
+
}
|
|
455
|
+
declare function transcribeWithAssemblyAI(audioPath: string, options?: AssemblyAiOptions): Promise<{
|
|
456
|
+
asr: AsrResult;
|
|
457
|
+
raw: unknown;
|
|
458
|
+
}>;
|
|
459
|
+
|
|
460
|
+
interface UploadedFile {
|
|
461
|
+
uri: string;
|
|
462
|
+
mimeType: string;
|
|
463
|
+
name: string;
|
|
464
|
+
}
|
|
465
|
+
interface GeminiPart {
|
|
466
|
+
/** a local file path to upload, OR */
|
|
467
|
+
filePath?: string;
|
|
468
|
+
/** an already-uploaded file, OR */
|
|
469
|
+
uploaded?: UploadedFile;
|
|
470
|
+
/** plain text */
|
|
471
|
+
text?: string;
|
|
472
|
+
}
|
|
473
|
+
interface GeminiOptions {
|
|
474
|
+
apiKey?: string;
|
|
475
|
+
model?: string;
|
|
476
|
+
temperature?: number;
|
|
477
|
+
maxOutputTokens?: number;
|
|
478
|
+
/** JSON schema for structured output; if set, responseMimeType=application/json */
|
|
479
|
+
schema?: unknown;
|
|
480
|
+
/** system instruction */
|
|
481
|
+
systemInstruction?: string;
|
|
482
|
+
/** thinking budget in tokens (Gemini 2.5 family). Ignored by Gemini 3.x. */
|
|
483
|
+
thinkingBudget?: number;
|
|
484
|
+
/** thinking level (Gemini 3.x family): "MINIMAL" | "LOW" | "MEDIUM" | "HIGH". */
|
|
485
|
+
thinkingLevel?: "MINIMAL" | "LOW" | "MEDIUM" | "HIGH";
|
|
486
|
+
/** retries on transient API errors (default 4) */
|
|
487
|
+
retries?: number;
|
|
488
|
+
/** label for this call, surfaced in the onCall log record */
|
|
489
|
+
label?: string;
|
|
490
|
+
}
|
|
491
|
+
interface GeminiResult {
|
|
492
|
+
text: string;
|
|
493
|
+
usage?: {
|
|
494
|
+
inputTokens?: number;
|
|
495
|
+
outputTokens?: number;
|
|
496
|
+
thoughtsTokens?: number;
|
|
497
|
+
};
|
|
498
|
+
model: string;
|
|
499
|
+
raw: unknown;
|
|
500
|
+
}
|
|
501
|
+
declare class GeminiClient {
|
|
502
|
+
private ai;
|
|
503
|
+
/** if set, invoked once per generate() with the prompt/response/usage (for logging). */
|
|
504
|
+
onCall?: (rec: LlmCallRecord) => void;
|
|
505
|
+
constructor(apiKey?: string);
|
|
506
|
+
/** Upload a local file via the Files API and wait until it's ACTIVE. */
|
|
507
|
+
uploadFile(filePath: string, mimeType?: string): Promise<UploadedFile>;
|
|
508
|
+
deleteFile(name: string): Promise<void>;
|
|
509
|
+
/** Generate content from a mix of files (paths or pre-uploaded) and text. */
|
|
510
|
+
generate(parts: GeminiPart[], options?: GeminiOptions): Promise<GeminiResult>;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export { type AlignPair, type AlignedSegment, type AlignedToken, type AsrResult, type AsrUtterance, type BuildSpeakersOptions, type BuiltSpeakers, DIARIZATION_SYSTEM, type DiarizationPromptInput, GeminiClient, type HasText, type LlmCallRecord, type LlmLine, type MarkdownOptions, type MediaChunk, type MediaInfo, type ProgressEvent, type SegmentOptions, type Speaker, type SrtCue, type SrtFormatOptions, type SrtOptions, type TimeChunk, type TimedWord, type TimingSource, type TranscribeOptions, type TranscribeResult, type Transcript, type TranscriptMetadata, type TranscriptSegment, alignLlmToAsr, alignTokens, asrSpeakerByLabel, buildAsrHint, buildDiarizationPrompt, buildSegmentsFromTokens, buildSpeakers, fillTokenTimes, formatSrt, formatSrtTiming, isProvisional, normalizeToken, parseDiarizedText, parseSrt, relTimeToSeconds, secondsToCompact, secondsToSrtTime, slugLabel, splitSpeakerPrefix, srtCueText, srtTimeToSeconds, toJSON, toMarkdown, toSRT, toText, tokenize, transcribe, transcribeWithAssemblyAI };
|