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 },
|
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",
|
fasterWhisperModel: "medium.en",
|
||||||
displayName: "Whisper Medium (English)",
|
displayName: "Whisper Medium (English)",
|
||||||
multilingual: false,
|
multilingual: false,
|
||||||
@@ -202,7 +206,7 @@ export const MODELS: readonly WhisperModel[] = [
|
|||||||
defaults: { wasm: WASM_Q4, webgpu: WEBGPU_FP16_Q4, webnn: WEBNN_FP16 },
|
defaults: { wasm: WASM_Q4, webgpu: WEBGPU_FP16_Q4, webnn: WEBNN_FP16 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "onnx-community/whisper-medium",
|
id: "onnx-community/whisper-medium-ONNX",
|
||||||
fasterWhisperModel: "medium",
|
fasterWhisperModel: "medium",
|
||||||
displayName: "Whisper Medium",
|
displayName: "Whisper Medium",
|
||||||
multilingual: true,
|
multilingual: true,
|
||||||
|
|||||||
+15
-7
@@ -13,6 +13,11 @@ import {
|
|||||||
|
|
||||||
// Pure catalog data (D-006) — no browser, no network.
|
// 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", () => {
|
describe("MODELS catalog", () => {
|
||||||
test("contains the curated D-006 lineup from the onnx-community org", () => {
|
test("contains the curated D-006 lineup from the onnx-community org", () => {
|
||||||
const ids = MODELS.map((model) => model.id);
|
const ids = MODELS.map((model) => model.id);
|
||||||
@@ -23,8 +28,8 @@ describe("MODELS catalog", () => {
|
|||||||
"onnx-community/whisper-base",
|
"onnx-community/whisper-base",
|
||||||
"onnx-community/whisper-small.en",
|
"onnx-community/whisper-small.en",
|
||||||
"onnx-community/whisper-small",
|
"onnx-community/whisper-small",
|
||||||
"onnx-community/whisper-medium.en",
|
"onnx-community/whisper-medium.en_timestamped",
|
||||||
"onnx-community/whisper-medium",
|
"onnx-community/whisper-medium-ONNX",
|
||||||
"onnx-community/whisper-large-v3-turbo",
|
"onnx-community/whisper-large-v3-turbo",
|
||||||
]);
|
]);
|
||||||
expect(new Set(ids).size).toBe(ids.length);
|
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", () => {
|
test(".en variants are English-only; the rest are multilingual", () => {
|
||||||
for (const model of MODELS) {
|
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)", () => {
|
test("every model maps to a faster-whisper name for the server engine (D-013)", () => {
|
||||||
for (const model of MODELS) {
|
for (const model of MODELS) {
|
||||||
// The onnx-community ids and faster-whisper's aliases share the same
|
// The onnx-community ids and faster-whisper's aliases share the same
|
||||||
// size suffix ("tiny.en", …, "large-v3-turbo"); keeping them aligned is
|
// size suffix ("tiny.en", …, "large-v3-turbo") once repo-name
|
||||||
// what lets one catalog drive both engines.
|
// decorations ("_timestamped", "-ONNX") are stripped; keeping them
|
||||||
|
// aligned is what lets one catalog drive both engines.
|
||||||
expect(model.fasterWhisperModel).toBe(
|
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");
|
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", () => {
|
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-tiny.en", "wasm")).toBe("q8");
|
||||||
expect(resolveDefaultDtype("onnx-community/whisper-small", "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");
|
expect(resolveDefaultDtype("onnx-community/whisper-large-v3-turbo", "wasm")).toBe("q4");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user