automatic-speech-recognition · audio · WASM (WebGPU when available) · ~90 MB
The English wav2vec2 demo speaks one language, the Russian XLSR demo another, and the Spanish and Italian demos two more. This one recognises Polish. It is wav2vec2-base pre-trained self-supervised on 10,000 hours of unlabelled European-Parliament audio (VoxPopuli) and then fine-tuned on Polish — a compact ~95M-param CTC recogniser whose output alphabet carries the Polish diacritics (ą ć ę ł ń ó ś ź ż). Same CTC mechanics as the other ASR demos: label every ~20 ms frame, then collapse the frames into text. Pick a clip and watch the frames collapse into Polish.
| Model | onnx-community/wav2vec2-base-10k-voxpopuli-ft-pl-ONNX (ONNX mirror of facebook/wav2vec2-base-10k-voxpopuli-ft-pl) |
|---|---|
| Task / pipeline | automatic-speech-recognition — loaded as AutoModelForCTC so we can see the frames |
| Architecture | wav2vec2-base: a ~95M-param wav2vec2 encoder (12 transformer layers) pre-trained on 10k h of unlabelled VoxPopuli audio, fine-tuned for Polish. CTC head over a 41-symbol Latin-Polish vocab (blank + "|" boundary + digit + 26 letters + ą ć ę ł ń ó ś ź ż). No decoder. |
| Language | Polish (pl) — this is a language-specialised recogniser; other languages produce Polish-phonetic gibberish |
| Not XLSR-53 | the canonical jonatasgrosman XLSR-53 Polish checkpoint is PyTorch/Flax only — no ONNX export exists anywhere on the Hub, so it can't run in a browser today. This demo honestly uses the smaller wav2vec2-base VoxPopuli Polish model that does ship a real browser-loadable CTC ONNX, rather than relabel a different language's model. |
| Quantization | q4 (4-bit, onnx/model_q4.onnx, ~90 MB) — verified in real headless Chrome to give cleaner, more accurate Polish than the q8/int8 export and far smaller than the 378 MB fp32 |
| Layout | standard transformers.js layout (config.json + preprocessor_config.json + onnx/ subfolder + tokenizer.json + vocab.json), so it loads directly as AutoModelForCTC — we still normalise the audio and CTC-decode ourselves to surface the per-frame strip |
| Backend | WebAssembly (WebGPU when a real adapter is present), honest fallback |
| Download | ~90 MB (q4 encoder), cached after first load |
| License | Apache-2.0 (base model, facebook/wav2vec2-base-10k-voxpopuli-ft-pl) |
| Web APIs | WebAssembly / WebGPU, Web Workers, Web Audio (decode + resample), MediaRecorder (mic) |
Choose Polish audio — record from your mic, upload a file, or pick the bundled sample. The page decodes it to 16 kHz mono, draws the waveform, and runs the CTC model in a Web Worker. It does best on clear Polish speech. First load is a ~90 MB q4 download, then it's cached.
This context didn't grant mic access (common in headless / embedded views). The model still works — use the sample above or Upload audio. For live recording, open this in a normal browser tab and allow the microphone when prompted, then speak Polish.
Below is the model's raw per-frame argmax: one cell per ~20 ms frame, showing the
single character it thinks is most likely there. Most frames are blank (·) — the model
saying "nothing new here". Where a sound lands you get a run of the same letter. The transcript is
produced by two mechanical rules, no decoder involved:
(1) merge consecutive duplicates, (2) drop the blanks. A run like
·· dd ·· oo o ·· mm ·· · collapses to dom.
Raw per-frame argmax (– frames · ~– ms each):
↓ merge duplicates, drop blanks ↓
Self-supervised pre-training on huge piles of unlabelled speech — here 10,000 hours of European-Parliament audio — is how you get a good recogniser for a language like Polish from a modest amount of labelled data. The model learned what human speech sounds like before it ever saw a Polish transcript. That is what puts a usable Polish recogniser inside a browser tab — private, offline once cached, no server, no key. And because it's CTC (frames, not generated tokens) it can't hallucinate an unspoken sentence, and every character is pinned to a moment in time.
One Polish clip in, Polish text out — and the per-frame strip that produced it.
Forced alignment: real per-word Polish timings, straight from the CTC frames.
Feed it English and watch a Polish-only model transliterate the sounds.
Transcribe Polish → OPUS-MT translates it to English, all on-device.
This repo ships the standard transformers.js layout, so the model loads directly as
AutoModelForCTC. We still normalise the audio and do the CTC collapse ourselves so we
can show the per-frame strip (the ASR pipeline does exactly this internally):
import { AutoModelForCTC, Tensor } from "@huggingface/transformers";
const model_id = "onnx-community/wav2vec2-base-10k-voxpopuli-ft-pl-ONNX";
const model = await AutoModelForCTC.from_pretrained(model_id, {
device: "wasm", dtype: "q4", // 4-bit export, ~90 MB — cleaner Polish than q8, tiny vs 378 MB fp32
});
// audio = 16 kHz mono Float32Array → normalise to zero mean / unit variance (wav2vec2 feature step)
const x = normalize(audio);
const { logits } = await model({ input_values: new Tensor("float32", x, [1, x.length]) });
// logits shape [1, frames, 41] ← 41 Latin-Polish symbols
// greedy CTC decode: argmax per frame, merge duplicates, drop the blank (id 0)
const ids = argmaxPerFrame(logits); // e.g. [0,0,18,18,0,8,20,...]
const text = collapse(ids); // "dom…" in Polish — no decoder involved
Inference runs in a Web Worker so the UI never janks. The worker returns the raw per-frame argmax and real per-word timings (from the frame each character was emitted at) — nothing is faked or pre-computed.