Skip to content

Commit 34973f6

Browse files
committed
feat: Add more models
1 parent 46efa87 commit 34973f6

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

src/screens/editor/Editor.res

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ let make = React.memo((
209209
<div className="flex justify-center w-full flex-1 min-h-0 overflow-hidden">
210210
{layout.mediaControls
211211
->Belt.Option.map(size => {
212-
Js.Console.log(size)
213212
let showSideBySide = size.width >= 770.0
214213

215214
<div

src/screens/editor/Editor.res.mjs

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/transcriber/Constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ export const MODELS = {
2929
"onnx-community/whisper-tiny_timestamped": "Tiny (152 Mb)",
3030
"onnx-community/whisper-base_timestamped": "Base (291 Mb)",
3131
"onnx-community/whisper-small_timestamped": "Small (586 Mb)",
32+
"onnx-community/whisper-medium_timestamped": "Medium (769 Mb)",
33+
"onnx-community/whisper-large-v3-turbo_timestamped": "Turbo (561 Mb)",
3234
} as const;
3335

3436
export type Model = keyof typeof MODELS;
3537

3638
export const ALL_MODELS = Object.keys(MODELS) as Array<Model>;
37-
const DEFAULT_MODEL: Model = "onnx-community/whisper-base_timestamped";
39+
const DEFAULT_MODEL: Model = "onnx-community/whisper-large-v3-turbo_timestamped";
3840

3941
export const modelSerde: serde<Model> = {
4042
parse: function(input: string): Model {

src/transcriber/whisper-worker.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@ async function isWebGPUAvailable() {
2020
// env.localModelPath = "/models/";
2121
// env.allowRemoteModels = true;
2222

23+
// Large models that need aggressive quantization to fit in browser memory
24+
const LARGE_MODELS = [
25+
"onnx-community/whisper-large-v3-turbo",
26+
"onnx-community/whisper-large-v3-turbo_timestamped",
27+
"distil-whisper/distil-large-v3",
28+
];
29+
30+
// Get optimal dtype config based on model size
31+
function getDtypeConfig(modelName) {
32+
if (LARGE_MODELS.some(m => modelName.includes(m.replace("onnx-community/", "").replace("distil-whisper/", "")))) {
33+
// Use q4f16 for large models to fit in browser memory
34+
// q4f16 = 4-bit quantized weights with fp16 activations
35+
return {
36+
encoder_model: "q4f16",
37+
decoder_model_merged: "q4f16",
38+
};
39+
}
40+
// Default config for smaller models
41+
return {
42+
encoder_model: "fp32",
43+
decoder_model_merged: "q4", // or 'fp32' ('fp16' is broken)
44+
};
45+
}
46+
2347
// Define model factories
2448
// Ensures only one model is created of each type
2549
class PipelineFactory {
@@ -39,10 +63,7 @@ class PipelineFactory {
3963
this.instance = pipeline(this.task, this.model, {
4064
quantized: this.quantized,
4165
progress_callback,
42-
dtype: {
43-
encoder_model: "fp32",
44-
decoder_model_merged: "q4", // or 'fp32' ('fp16' is broken)
45-
},
66+
dtype: getDtypeConfig(this.model),
4667
device: await isWebGPUAvailable() ? "webgpu" : "wasm",
4768
});
4869
}

0 commit comments

Comments
 (0)