Fix model selection.
This commit is contained in:
+6
-2
@@ -193,7 +193,11 @@ export const MODELS: readonly WhisperModel[] = [
|
||||
defaults: { wasm: WASM_Q8, webgpu: WEBGPU_FP16_Q4, webnn: WEBNN_FP16 },
|
||||
},
|
||||
{
|
||||
id: "onnx-community/whisper-medium.en",
|
||||
// onnx-community has no plain "whisper-medium.en"/"whisper-medium" repos
|
||||
// (the Hub answers 401 "Unauthorized" for missing repos) — the medium
|
||||
// conversions live under these names instead. Verified to carry the full
|
||||
// q4/q8/fp16 encoder + merged-decoder variant set.
|
||||
id: "onnx-community/whisper-medium.en_timestamped",
|
||||
fasterWhisperModel: "medium.en",
|
||||
displayName: "Whisper Medium (English)",
|
||||
multilingual: false,
|
||||
@@ -202,7 +206,7 @@ export const MODELS: readonly WhisperModel[] = [
|
||||
defaults: { wasm: WASM_Q4, webgpu: WEBGPU_FP16_Q4, webnn: WEBNN_FP16 },
|
||||
},
|
||||
{
|
||||
id: "onnx-community/whisper-medium",
|
||||
id: "onnx-community/whisper-medium-ONNX",
|
||||
fasterWhisperModel: "medium",
|
||||
displayName: "Whisper Medium",
|
||||
multilingual: true,
|
||||
|
||||
+15
-7
@@ -13,6 +13,11 @@ import {
|
||||
|
||||
// Pure catalog data (D-006) — no browser, no network.
|
||||
|
||||
/** Hub repo-name decorations that follow the Whisper size suffix. */
|
||||
function stripRepoDecorations(id: string): string {
|
||||
return id.replace(/(_timestamped|-ONNX)$/, "");
|
||||
}
|
||||
|
||||
describe("MODELS catalog", () => {
|
||||
test("contains the curated D-006 lineup from the onnx-community org", () => {
|
||||
const ids = MODELS.map((model) => model.id);
|
||||
@@ -23,8 +28,8 @@ describe("MODELS catalog", () => {
|
||||
"onnx-community/whisper-base",
|
||||
"onnx-community/whisper-small.en",
|
||||
"onnx-community/whisper-small",
|
||||
"onnx-community/whisper-medium.en",
|
||||
"onnx-community/whisper-medium",
|
||||
"onnx-community/whisper-medium.en_timestamped",
|
||||
"onnx-community/whisper-medium-ONNX",
|
||||
"onnx-community/whisper-large-v3-turbo",
|
||||
]);
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
@@ -32,7 +37,9 @@ describe("MODELS catalog", () => {
|
||||
|
||||
test(".en variants are English-only; the rest are multilingual", () => {
|
||||
for (const model of MODELS) {
|
||||
expect(model.multilingual).toBe(!model.id.endsWith(".en"));
|
||||
// Hub repo names may carry decorations (e.g. "_timestamped", "-ONNX")
|
||||
// after the size suffix — judge English-ness on the undecorated name.
|
||||
expect(model.multilingual).toBe(!stripRepoDecorations(model.id).endsWith(".en"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -64,10 +71,11 @@ describe("MODELS catalog", () => {
|
||||
test("every model maps to a faster-whisper name for the server engine (D-013)", () => {
|
||||
for (const model of MODELS) {
|
||||
// The onnx-community ids and faster-whisper's aliases share the same
|
||||
// size suffix ("tiny.en", …, "large-v3-turbo"); keeping them aligned is
|
||||
// what lets one catalog drive both engines.
|
||||
// size suffix ("tiny.en", …, "large-v3-turbo") once repo-name
|
||||
// decorations ("_timestamped", "-ONNX") are stripped; keeping them
|
||||
// aligned is what lets one catalog drive both engines.
|
||||
expect(model.fasterWhisperModel).toBe(
|
||||
model.id.replace("onnx-community/whisper-", ""),
|
||||
stripRepoDecorations(model.id).replace("onnx-community/whisper-", ""),
|
||||
);
|
||||
}
|
||||
expect(getFasterWhisperModel(DEFAULT_MODEL_ID)).toBe("tiny.en");
|
||||
@@ -81,7 +89,7 @@ describe("resolveDefaultDtype", () => {
|
||||
test("WASM defaults: q8 for small models, q4 for large ones", () => {
|
||||
expect(resolveDefaultDtype("onnx-community/whisper-tiny.en", "wasm")).toBe("q8");
|
||||
expect(resolveDefaultDtype("onnx-community/whisper-small", "wasm")).toBe("q8");
|
||||
expect(resolveDefaultDtype("onnx-community/whisper-medium", "wasm")).toBe("q4");
|
||||
expect(resolveDefaultDtype("onnx-community/whisper-medium-ONNX", "wasm")).toBe("q4");
|
||||
expect(resolveDefaultDtype("onnx-community/whisper-large-v3-turbo", "wasm")).toBe("q4");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user