diff --git a/packages/telegram-remote/lib/whisper.js b/packages/telegram-remote/lib/whisper.js index 0dcce6c..91c3833 100644 --- a/packages/telegram-remote/lib/whisper.js +++ b/packages/telegram-remote/lib/whisper.js @@ -6,8 +6,8 @@ * POST {base}/api/transcriptions multipart fields: file, language, * modelSize, device (cuda|cpu), sourceUrl * GET {base}/api/transcriptions/{id} - * Job status -1 = queued/running; statuses 0/1/2 = terminal; a successful - * terminal job has a non-empty result.text. + * Job status 0 = created/queued, 1 = processing, 2/3 = finished; a finished + * job has a non-empty result.text on success. */ const POLL_INTERVAL_MS = 1500; @@ -78,8 +78,12 @@ export async function transcribeAudio({ baseUrl, model, device, language, timeou } const text = job?.result?.text; if (typeof text === "string" && text.trim().length > 0) return text; - if (job?.status !== -1) { - throw new Error("whisper: job finished without text (status " + String(job?.status) + ")"); + // Whishper lifecycle (verified on this server): 0 = created/queued, + // 1 = processing (can last tens of seconds), 2/3 = finished. + const status = job?.status; + const running = status === -1 || status === 0 || status === 1; + if (!running) { + throw new Error("whisper: job finished without text (status " + String(status) + ")"); } } }