跳到正文
DEV Community· Vipul Singh·· 2 天前AI 評分53

在瀏覽器內執行 Whisper:免上傳、無檔案上限轉錄工具背後的 5 項設計取捨

Running Whisper in the browser: 5 decisions behind a no-upload, no-cap transcriber

AI 導讀

Vipul Singh 開發了一款完全在瀏覽器內執行 OpenAI Whisper 的轉錄工具,無須上傳或註冊,檔案數量、轉錄時長及單檔長度均不設上限。工具使用瀏覽器媒體引擎解碼,按需載入 Whisper/Transformers.js,並分開顯示模型下載與轉錄進度;説話者標記依據輪次變化,並非真正按聲音身份辨識説話者。

正文

I built a transcriber that runs OpenAI's Whisper entirely in the browser: no upload, no signup, no file cap. The AI part is mostly solved by the model. What took the time were the decisions around it. Here are the ones that mattered, including the tradeoffs.

1. Decode with the browser, not a bundled codec library

I didn't ship ffmpeg or any codec library. Audio and video are decoded with the browser's own media engine, so support follows whatever Chrome, Edge, Safari or Firefox can already play: MP3, WAV, M4A/AAC, OGG/Opus, and the audio track of MP4, MOV and WEBM.

The upside is a much lighter page and nothing extra to download. The downside is honest: Safari and Firefox can occasionally fail on an unusual codec inside an MP4/MOV/WEBM. So the tool shows a clear error instead of failing silently, and the fix is usually re-exporting as MP3 or WAV.

2. Don't load the model code until the user asks

The Whisper/Transformers.js code is lazy-loaded, so it only loads when someone actually starts a transcription. The pattern is simple:

button.addEventListener("click", async () => {
  // model code loads only now, not on page load
  const { pipeline } = await import("@huggingface/transformers");
  // ...create the pipeline and run it
});

A visitor who just reads the page never pays for a model library.

3. Show two progress bars, not one

The first run downloads the model, and later runs load it from cache. If that's one progress bar, a user stares at a stalled-looking screen and assumes it's broken. Separate bars for "model download" and "transcribing", plus an estimated time remaining, removed most of that confusion.

4. Be honest about speaker labels

The "identify speakers" option is turn-based change detection, not true voice-identity diarization. It marks where the speaker changes and labels them "Speaker 1 / Speaker 2" (renameable in one click). It can drift on long recordings or with 3+ speakers, and the UI says so, which beats a confident label that's wrong.

5. "Unlimited" means your device is the limit

There's no cap on files, minutes or length, because inference runs on the user's hardware. The real limits are the user's: speed (WebGPU on Chrome/Edge, a slower WASM path elsewhere) and memory on very long files (I show a warning above 3 hours). Saved transcripts live in IndexedDB, so clearing browser data loses them. That's why there are seven export formats (TXT, Word, PDF, SRT, VTT, CSV, JSON).

Try it

https://www.forgeplug.com/tools/transcribe-audio-to-text

If you've shipped on-device ML in the browser, I'd like to hear how you handle memory on long inputs, and whether you'd ship diarization with embeddings next.

來源:DEV Community · dev.to