Files
au_whisper_web/isolate_wer2.ts
T

16 lines
1.1 KiB
TypeScript

// TEMP (delete after use): which component's q4 hurts — encoder or decoder?
import { pipeline } from "@huggingface/transformers";
const audio = new Float32Array(await Bun.file(process.argv[2]!).arrayBuffer());
const S = "/tmp/claude-1000/-home-user-au-whisper-web/b192bada-c438-4a43-a29d-c2969ef71f6c/scratchpad";
async function run(label: string, dtype: any) {
const asr = await pipeline("automatic-speech-recognition", "onnx-community/whisper-large-v3-turbo", { dtype, progress_callback: () => {} });
const t0 = performance.now();
const out = await asr(audio, { chunk_length_s: 30, stride_length_s: 5, return_timestamps: true, max_new_tokens: 440, language: "en", task: "transcribe" });
const single = (Array.isArray(out) ? out[0] : out) as { text?: string };
console.log(`${label}: ${((performance.now() - t0) / 1000).toFixed(0)}s`);
await Bun.write(`${S}/out-${label}.txt`, (single.text ?? "").trim());
await asr.dispose();
}
await run("encq8-decq4", { encoder_model: "q8", decoder_model_merged: "q4" });
await run("encq4-decq8", { encoder_model: "q4", decoder_model_merged: "q8" });