fix(telegram-remote): poll Whishper through status 1 (processing)
Whishper job lifecycle: 0=created, 1=processing (tens of seconds), 2/3=finished. The poll loop treated any status != -1 as terminal and threw 'job finished without text (status 1)' mid-transcription. Keep polling on -1/0/1; only finished statuses with empty text are errors.
This commit is contained in:
@@ -6,8 +6,8 @@
|
|||||||
* POST {base}/api/transcriptions multipart fields: file, language,
|
* POST {base}/api/transcriptions multipart fields: file, language,
|
||||||
* modelSize, device (cuda|cpu), sourceUrl
|
* modelSize, device (cuda|cpu), sourceUrl
|
||||||
* GET {base}/api/transcriptions/{id}
|
* GET {base}/api/transcriptions/{id}
|
||||||
* Job status -1 = queued/running; statuses 0/1/2 = terminal; a successful
|
* Job status 0 = created/queued, 1 = processing, 2/3 = finished; a finished
|
||||||
* terminal job has a non-empty result.text.
|
* job has a non-empty result.text on success.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const POLL_INTERVAL_MS = 1500;
|
const POLL_INTERVAL_MS = 1500;
|
||||||
@@ -78,8 +78,12 @@ export async function transcribeAudio({ baseUrl, model, device, language, timeou
|
|||||||
}
|
}
|
||||||
const text = job?.result?.text;
|
const text = job?.result?.text;
|
||||||
if (typeof text === "string" && text.trim().length > 0) return text;
|
if (typeof text === "string" && text.trim().length > 0) return text;
|
||||||
if (job?.status !== -1) {
|
// Whishper lifecycle (verified on this server): 0 = created/queued,
|
||||||
throw new Error("whisper: job finished without text (status " + String(job?.status) + ")");
|
// 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) + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user