Focus on speedup and not hanging on large audio files.

This commit is contained in:
Lucas Winther committed 2026-07-15 13:01:22 +02:00
1 parent cba27fc728
commit 0bd5d326a5
7 files changed
+366 -2

No files matched your search

+13 -1
View File
@@ -4,7 +4,7 @@ import { ensureIcons, ICONS_DIR } from "../scripts/generate-icons.ts";
import { injectPrecacheManifest } from "./pwa/precache.ts";
import { auth } from "./server/auth.ts";
import { AUTH_ENABLED } from "./server/flags.ts";
import { transcribe } from "./server/transcribe.ts";
import { MAX_UPLOAD_BYTES, transcribe } from "./server/transcribe.ts";
import { liveWebSocket } from "./server/live.ts";
const ROOT = join(import.meta.dir, "..");
@@ -81,8 +81,17 @@ async function handleApiRequest(request: Request, server: any): Promise<Response
case "GET /api/auth/me":
return auth.me(request);
case "GET /api/transcribe/status":
// The first probe spawns the sidecar and waits for faster-whisper to
// import (READY_TIMEOUT_MS = 60 s) — give it headroom over Bun's 10 s
// default idle timeout.
server.timeout(request, 90);
return transcribe.status(request);
case "POST /api/transcribe":
// Long-running ndjson stream (D-021): quiet stretches (model
// load/download, slow decode windows) exceed Bun's 10 s idle timeout,
// which would reset the connection mid-transcription. Heartbeat lines
// (transcribe.ts) cover proxies; disable Bun's timer entirely here.
server.timeout(request, 0);
return transcribe.post(request);
case "GET /api/transcribe/live": {
const user = auth.getSessionUser(request);
@@ -261,6 +270,9 @@ async function developmentServeOptions(): Promise<ServeOptions> {
const options = IS_PRODUCTION ? await productionServeOptions() : await developmentServeOptions();
options.port = process.env.PORT || 3000;
// Bun's default cap is 128 MB, which would 4xx a /api/transcribe upload of
// more than ~35 minutes of raw PCM before the route's own limit applies.
options.maxRequestBodySize = MAX_UPLOAD_BYTES;
options.websocket = liveWebSocket as any;
const server = serve(options);