@dornick/parsers-audio
v0.1.0
Published
Lazy Whisper (transformers.js) parser for Dornick. Transcribes audio uploads in the browser.
Readme
@dornick/parsers-audio
Lazy Whisper (transformers.js) parser for Dornick — transcribe audio uploads in the browser.
Capability-gated on WebGPU + crossOriginIsolated. Auto-hides on browsers that can't run it efficiently.
Install
npm i @dornick/parsers-audioDepends on @huggingface/transformers. On first use, downloads the model (~40 MB for whisper-tiny.en); cached thereafter.
Use
import { Dornick } from "@dornick/core";
import { whisperParser, whisperParserFor } from "@dornick/parsers-audio";
const dornick = new Dornick({ config, transport });
dornick.parsers.add(whisperParser); // tiny.en default
dornick.parsers.add(whisperParserFor("Xenova/whisper-base")); // larger modelPaths produced
| Path | Content |
|---|---|
| transcript.txt | The plain-text transcription |
| chunks.jsonl | One JSON object per chunk: { text, timestamp: [start, end] } |
Capability gate
requires: ["webgpu", "crossOriginIsolated"]
- WebGPU — without it, Whisper takes orders of magnitude longer per minute of audio. The gate hides the parser where it'd be too slow to be useful.
crossOriginIsolated— required forSharedArrayBuffer, which transformers.js uses for performant inference. To enable: serve your page with the headersCross-Origin-Opener-Policy: same-originandCross-Origin-Embedder-Policy: require-corp.
Hosting headers (quick reference)
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corpWithout these, the parser silently disappears from paths() and dornick.capabilities.has("crossOriginIsolated") is false.
Models
| Model | Size | Quality | Use it for |
|---|---|---|---|
| Xenova/whisper-tiny.en (default) | ~40 MB | OK | English-only quick transcripts |
| Xenova/whisper-base.en | ~75 MB | Good | English, noisier audio |
| Xenova/whisper-small.en | ~250 MB | Great | Demanding English transcripts |
| Xenova/whisper-tiny | ~40 MB | OK | Multilingual |
Pass the model name to whisperParserFor(name).
See also
- Concept: Capabilities — why the gate matters
- Concept: Parsers
- Use case: KYC / AML intake — voice-confirm step
- Use case: SaaS copilot — dictation-driven replies
License
MIT — © Dipankar Sarkar
