perf: also warm STT during the popup so the first hold-to-ask is fast (Whisper is CPU, no quota)
Browse files- frontend/app.js +3 -1
frontend/app.js
CHANGED
|
@@ -144,7 +144,9 @@ async function warmup() {
|
|
| 144 |
if (!client) { warmedSession = false; return; } // let it retry if the connection failed
|
| 145 |
const c = document.createElement("canvas"); c.width = 32; c.height = 32;
|
| 146 |
const blob = await new Promise((r) => c.toBlob(r, "image/jpeg", 0.6));
|
| 147 |
-
if (blob) client.predict("/describe", { image: handle_file(blob), lang }).catch(() => {}); //
|
|
|
|
|
|
|
| 148 |
} catch (e) { warmedSession = false; }
|
| 149 |
}
|
| 150 |
|
|
|
|
| 144 |
if (!client) { warmedSession = false; return; } // let it retry if the connection failed
|
| 145 |
const c = document.createElement("canvas"); c.width = 32; c.height = 32;
|
| 146 |
const blob = await new Promise((r) => c.toBlob(r, "image/jpeg", 0.6));
|
| 147 |
+
if (blob) client.predict("/describe", { image: handle_file(blob), lang }).catch(() => {}); // warm the VLM on the GPU; discard the result
|
| 148 |
+
// also warm speech-to-text (Whisper, CPU) so the first "hold to ask" is fast too
|
| 149 |
+
try { const wav = await (await fetch(SILENT)).blob(); client.predict("/detect_lang", { audio: handle_file(wav) }).catch(() => {}); } catch (e) {}
|
| 150 |
} catch (e) { warmedSession = false; }
|
| 151 |
}
|
| 152 |
|