offmute-v2 0.1.0 → 0.2.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/dist/browser.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /**
2
- * Gemini provider (multimodal). Handles file upload + processing poll, text and
3
- * structured-JSON generation, retries, token tracking, and uploaded-file cleanup.
4
- *
5
- * Uses `@google/genai` v1 SDK. Audio is uploaded via the Files API (supports large
6
- * files) and referenced by URI in the generate request.
2
+ * Gemini token usage, shared by the SDK client (node) and the fetch client (browser).
3
+ * Dependency-free so the browser bundle can import it without the SDK.
7
4
  */
8
-
9
5
  interface GeminiUsage {
10
6
  inputTokens: number;
7
+ /** Billed output: the visible answer plus thinking (both are charged at the output
8
+ * rate). Leaving thinking out under-reported 3.1 Pro spend by ~16% in real runs. */
11
9
  outputTokens: number;
10
+ /** The thinking share of `outputTokens`, kept for the call log. */
11
+ thoughtTokens?: number;
12
12
  totalTokens: number;
13
13
  }
14
14
 
@@ -22,6 +22,9 @@ interface GeminiFetchOptions {
22
22
  apiKey: string;
23
23
  /** Override base URL (e.g. a proxy). */
24
24
  baseUrl?: string;
25
+ /** Ask Google to store nothing (default true): a top-level `store: false` on every
26
+ * request (see GeminiClientOptions.zeroStorage). */
27
+ zeroStorage?: boolean;
25
28
  }
26
29
  interface GeminiFetchGenerateOptions {
27
30
  temperature?: number;
@@ -38,6 +41,7 @@ interface GeminiFetchResult {
38
41
  declare class GeminiFetchClient {
39
42
  private apiKey;
40
43
  private baseUrl;
44
+ private zeroStorage;
41
45
  constructor(opts: GeminiFetchOptions);
42
46
  /** Generate from a prompt + inline file parts (ArrayBuffer + mimeType). */
43
47
  generate(model: string, prompt: string, files: {
@@ -167,6 +171,34 @@ interface TranscriptMetadata {
167
171
  inputTokens: number;
168
172
  outputTokens: number;
169
173
  };
174
+ /** How much of the recording the LLM transcript covered, chunk by chunk, and what was
175
+ * done where it didn't. "Every run reported success" was true of runs that silently
176
+ * lost minutes; this says where text came from the ASR instead. */
177
+ quality?: TranscriptQuality;
178
+ /** Whether this run asked providers to keep nothing (PipelineOptions.zeroStorage). */
179
+ zeroStorage?: boolean;
180
+ }
181
+ /** One LLM chunk's coverage against the ASR. */
182
+ interface ChunkQuality {
183
+ chunk: number;
184
+ start: number;
185
+ end: number;
186
+ /** ok · retried (re-transcribed in halves, now fine) · low-coverage (still short after any
187
+ * retry; the ASR filled what it could) · dropped-loop (a repetition loop, replaced by ASR) */
188
+ status: "ok" | "retried" | "low-coverage" | "dropped-loop";
189
+ /** Transcript words per ASR word (null when the ASR heard nothing here). */
190
+ coverage: number | null;
191
+ llmWords: number;
192
+ asrWords: number;
193
+ /** Few of its content words were also heard by the ASR (flagged, kept as transcribed). */
194
+ ungrounded?: boolean;
195
+ }
196
+ interface TranscriptQuality {
197
+ chunks: ChunkQuality[];
198
+ /** Words inserted from the ASR where no transcript segment covered its speech. */
199
+ gapFilledWords: number;
200
+ /** The ASR heard far fewer words than the transcript holds (often: another language). */
201
+ asrMissedSpeech: boolean;
170
202
  }
171
203
 
172
204
  /**
@@ -184,9 +216,15 @@ interface AssemblyAIFetchResult {
184
216
  }
185
217
  declare class AssemblyAIFetchClient {
186
218
  private apiKey;
187
- constructor(apiKey: string);
219
+ private zeroStorage;
220
+ /** `zeroStorage` (default true): delete the transcript from AssemblyAI once its words
221
+ * are read. AssemblyAI otherwise keeps it for 30 days. */
222
+ constructor(apiKey: string, opts?: {
223
+ zeroStorage?: boolean;
224
+ });
188
225
  transcribe(audio: Blob, opts?: {
189
226
  speakersExpected?: number;
227
+ language?: string;
190
228
  }): Promise<AssemblyAIFetchResult>;
191
229
  }
192
230
 
@@ -210,7 +248,18 @@ interface ChatOptions {
210
248
  /** What this call is for (logged): identify | … */
211
249
  logKind?: string;
212
250
  }
213
- declare class OpenAICompatClient {
251
+ /** The text-reasoning surface the naming and summary passes use. Implemented by
252
+ * OpenAICompatClient (DeepSeek, OpenAI, GLM, Kimi, Claude, …) and GeminiChatClient
253
+ * (Gemini over its native API). */
254
+ interface ChatClient {
255
+ chat(model: string | undefined, messages: ChatMessage[], opts?: ChatOptions): Promise<ChatResult>;
256
+ chatJson<T = unknown>(model: string | undefined, messages: ChatMessage[], opts?: ChatOptions): Promise<{
257
+ data: T | null;
258
+ raw: string;
259
+ error?: string;
260
+ }>;
261
+ }
262
+ declare class OpenAICompatClient implements ChatClient {
214
263
  private baseUrl;
215
264
  private apiKey;
216
265
  private defaultModel;
@@ -284,8 +333,6 @@ interface ChunkContext {
284
333
  description?: string;
285
334
  /** Speaker roster / hints. */
286
335
  roster?: string;
287
- /** Tail of the previous chunk's transcript for continuity (last few segments). */
288
- previousTail?: string;
289
336
  /** Chunk index (1-based) and total. */
290
337
  index: number;
291
338
  total: number;
@@ -295,8 +342,9 @@ interface ChunkContext {
295
342
  declare function transcriptionPrompt(ctx: ChunkContext): string;
296
343
 
297
344
  /**
298
- * Per-chunk LLM transcription: call Gemini, parse relative mm:ss timestamps to
299
- * absolute seconds (chunk offset), validate span + monotonicity, retry on failure.
345
+ * Per-chunk LLM transcription: call Gemini (streamed), parse relative mm:ss timestamps to
346
+ * absolute seconds (chunk offset), validate span + reject repetition loops, retry on
347
+ * failure (hotter after a loop).
300
348
  */
301
349
 
302
350
  interface ParsedLlmSegment {
@@ -315,6 +363,10 @@ interface ParsedLlmSegment {
315
363
  * owned by the previous chunk. Segments whose center is before this are dropped to
316
364
  * avoid double-printing the overlap region. */
317
365
  trustedStart?: number;
366
+ /** Absolute audio range of the source chunk (set by the pipeline): the only audio
367
+ * this segment can have been heard in. Alignment keeps its words inside it. */
368
+ chunkStart?: number;
369
+ chunkEnd?: number;
318
370
  }
319
371
  /** Parse + offset-adjust raw LLM segments. Drops unparseable ones (with a warning). */
320
372
  declare function parseLlmSegments(data: LlmTranscriptJson, chunkOffsetSec: number): {
@@ -411,7 +463,7 @@ interface IdentifyResult {
411
463
  reasoning: string;
412
464
  }
413
465
  /** Identify speakers via a text reasoner. Returns a name map (speaker id → name). */
414
- declare function identifySpeakers(client: OpenAICompatClient, model: string, segments: IdentifySegment[], speakers: SpeakerInfo[], roster: string, knownSpeakers?: string[], nameHints?: Record<string, string>, sourceFileName?: string): Promise<IdentifyResult>;
466
+ declare function identifySpeakers(client: ChatClient, model: string, segments: IdentifySegment[], speakers: SpeakerInfo[], roster: string, knownSpeakers?: string[], nameHints?: Record<string, string>, sourceFileName?: string): Promise<IdentifyResult>;
415
467
 
416
468
  /**
417
469
  * Finalize: dedup chunk-overlap duplicates, fix timestamp overlaps, clamp durations,
@@ -422,12 +474,10 @@ declare function identifySpeakers(client: OpenAICompatClient, model: string, seg
422
474
  * (ipgu noted clamping can re-introduce overlaps but didn't re-check).
423
475
  */
424
476
 
425
- interface FinalizeOptions {
426
- /** Drop segments shorter than this (seconds). */
427
- minSegmentSec?: number;
428
- }
429
- /** Convert aligned+consistent segments into the final Segment list (renumbered, deduped, clamped). */
430
- declare function finalizeSegments(segments: AlignedSegment[], opts?: FinalizeOptions): Segment[];
477
+ /** Convert aligned+consistent segments into the final Segment list (renumbered, deduped,
478
+ * clamped). Segments are dropped only when they have no text: a one-word interjection the
479
+ * aligner could only place at a point in time is still something somebody said. */
480
+ declare function finalizeSegments(segments: AlignedSegment[]): Segment[];
431
481
 
432
482
  /**
433
483
  * Output formatting: diarized SRT (with tone), Markdown transcript, plain text, and JSON.
@@ -527,7 +577,10 @@ interface TranscribeBrowserOptions {
527
577
  assemblyaiApiKey: string;
528
578
  /** Audio file extension for MIME detection (default "flac"). */
529
579
  audioExt?: string;
580
+ /** Transcription model (default gemini-4-hydrogen, as the CLI). */
530
581
  model?: string;
582
+ /** Ask providers to keep nothing (default true), as PipelineOptions.zeroStorage. */
583
+ zeroStorage?: boolean;
531
584
  instructions?: string;
532
585
  level?: 1 | 2 | 3;
533
586
  deepseekApiKey?: string;