Focus on speedup and not hanging on large audio files.
This commit is contained in:
@@ -232,6 +232,18 @@ async function transcribe(message: TranscribeMessage): Promise<void> {
|
||||
chunk_length_s: CHUNK_LENGTH_S,
|
||||
stride_length_s: STRIDE_LENGTH_S,
|
||||
return_timestamps: true,
|
||||
// With return_timestamps and no explicit max_new_tokens, Transformers.js
|
||||
// 4.2's Whisper generate() takes a seek-loop path that re-decodes each
|
||||
// window's tail (1–3 generate passes per window). Under this pipeline's
|
||||
// own 30 s/5 s chunking that is pure overhead: ~1.4× slower on long
|
||||
// files, duplicated boundary text, on_finalize firing once per pass
|
||||
// (breaking TranscribeProgressTracker's one-finalize-per-window
|
||||
// assumption — the progress bar saturated early, then looked frozen),
|
||||
// and a potential infinite loop when a window's last boundary timestamp
|
||||
// is 0. Setting max_new_tokens selects the classic single-pass path;
|
||||
// 440 ≈ Whisper's 448 decoder positions minus prompt headroom, far more
|
||||
// than any real 30 s window produces.
|
||||
max_new_tokens: 440,
|
||||
};
|
||||
if (message.stream ?? message.requestId === undefined) {
|
||||
// File-flow pass (id-less, or routed through BrowserEngine with an
|
||||
|
||||
Reference in New Issue
Block a user