Keep Parakeet on WASM unless WebGPU is chosen explicitly, and never offer it on phones

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Lucas Winther
2026-10-29 21:51:26 +01:00
co-authored by Claude Opus 5.5
parent 827e9a8dae
commit c5a57cd33a
4 changed files with 99 additions and 1 deletions
+25
View File
@@ -19,6 +19,8 @@
* advance, so a benchmark probe would cost more than it saves.
*/
import type { WhisperModel } from "./models";
export interface MobileMemoryHint {
/** `navigator.userAgent`, or undefined outside a browser (tests, SSR). */
userAgent: string | undefined;
@@ -86,3 +88,26 @@ export function shouldWarnBeforeLoad(hint: MobileMemoryHint, peakBytes: number):
}
return peakBytes > MOBILE_FALLBACK_RISK_THRESHOLD_BYTES;
}
/**
* Desktop-only models (D-WS7a): Parakeet's ~1.3 GB load peak (2 × the
* 652 MB int8 encoder, D-027's arithmetic) exceeds every phone budget the
* D-029 table considers safe, even at deviceMemory 8 (800 MB). Unlike the
* Whisper models — where a confirm lets the user judge their device — it is
* not offered at all on phones and tablets: no amount of RAM a phone reports
* makes it safe, so a "Continue anyway?" would only invite the crash.
*/
export function isModelAllowedOnDevice(
model: Pick<WhisperModel, "family">,
hint: Pick<MobileMemoryHint, "userAgent" | "maxTouchPoints">,
): boolean {
return model.family !== "parakeet" || !isLikelyMobile(hint);
}
/** The catalog as offered on this device (order preserved). */
export function modelsForDevice<T extends Pick<WhisperModel, "family">>(
models: readonly T[],
hint: Pick<MobileMemoryHint, "userAgent" | "maxTouchPoints">,
): T[] {
return models.filter((model) => isModelAllowedOnDevice(model, hint));
}