Fix model selection.
This commit is contained in:
+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