automatic-speech-recognition · audio · ONNX Runtime Web (WASM) · ~360 MB
The English wav2vec2 demo speaks one language, the Russian XLSR demo another, and the Polish and Finnish VoxPopuli demos two more. This one recognises Romanian. It is wav2vec2-base pre-trained self-supervised on 10,000 hours of unlabelled European-Parliament audio (VoxPopuli) and then fine-tuned on Romanian — a compact ~95M-param CTC recogniser whose output alphabet carries the Romanian 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 Romanian.
| Model | OpenVoiceOS/wav2vec2-base-10k-voxpopuli-ft-ro-onnx (ONNX export of facebook/wav2vec2-base-10k-voxpopuli-ft-ro) |
|---|---|
| Task / pipeline | automatic-speech-recognition — a wav2vec2 CTC model; we run the raw ONNX graph 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 Romanian. CTC head over a 37-symbol Latin-Romanian vocab (blank + "▁" boundary + 26 letters + ă â î ș ț). No decoder. |
| Language | Romanian (ro) — this is a language-specialised recogniser; other languages produce Romanian-phonetic gibberish |
| Not XLSR-53 | the canonical large wav2vec2-XLSR-53 Romanian checkpoints (e.g. anton-l/wav2vec2-large-xlsr-53-romanian, gigant/romanian-wav2vec2) are PyTorch/Flax only — no browser ONNX export, so they can't run in a browser today. This demo honestly uses the smaller wav2vec2-base VoxPopuli Romanian model that does ship a real, runnable CTC ONNX, rather than relabel a different language's model. |
| Runtime | ONNX Runtime Web (WASM) — not transformers.js. The OpenVoiceOS export is an onnx-asr graph: its config.json declares model_type: "wav2vec2-ctc" (which transformers.js doesn't register), the graph takes input_values + input_lengths and emits logprobs, and feature normalisation is baked in. So we drive the raw graph directly on ORT Web — the same engine transformers.js uses underneath. |
| Quantization | fp32 (model.onnx + model.onnx.data, ~360 MB) — the export ships no int8/q4 variant (onnxruntime's quantizer can't process this dynamo-exported graph, per the model card), so we honestly run and disclose the full-precision weights |
| Layout | onnx-asr export: a small model.onnx graph + external model.onnx.data weights + vocab.txt (token-id format, word delimiter ▁, blank <blk>). We fetch both, register the external data with ORT Web, and CTC-decode the log-probs ourselves. |
| Backend | WebAssembly (single-thread — GitHub Pages can't set COOP/COEP for threads). No GPU required. |
| Download | ~360 MB (fp32 encoder), cached in Cache Storage after first load — heavy, so it's a one-off on Wi-Fi |
| License | CC BY-NC 4.0 (non-commercial) — inherited from the Meta-AI base model facebook/wav2vec2-base-10k-voxpopuli-ft-ro |
| Web APIs | WebAssembly, Web Workers, Web Audio (decode + resample), Cache Storage, MediaRecorder (mic) |
Choose Romanian 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 Romanian speech. First load is a ~360 MB fp32 download (no smaller export exists yet), then it's cached for offline reuse.
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 Romanian.
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 Romanian from a modest amount of labelled data. The model learned what human speech sounds like before it ever saw a Romanian transcript. That is what puts a usable Romanian 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 Romanian clip in, Romanian text out — and the per-frame strip that produced it.
Forced alignment: real per-word Romanian timings, straight from the CTC frames.
Feed it English and watch a Romanian-only model transliterate the sounds.
Transcribe Romanian → OPUS-MT translates it to English, all on-device.
The Romanian ONNX export is packaged for the onnx-asr toolkit, not transformers.js — its config.json declares
model_type: "wav2vec2-ctc", so transformers.js's AutoModelForCTC refuses it
(Unsupported model type). Instead we drive the raw graph directly on
ONNX Runtime Web — feature normalisation is baked in, so we feed the raw 16 kHz
waveform and CTC-decode the log-probs ourselves:
import * as ort from "onnxruntime-web";
const base = "https://huggingface.co/OpenVoiceOS/wav2vec2-base-10k-voxpopuli-ft-ro-onnx/resolve/main/";
const graph = new Uint8Array(await (await fetch(base + "model.onnx")).arrayBuffer());
const data = new Uint8Array(await (await fetch(base + "model.onnx.data")).arrayBuffer()); // ~360 MB fp32
const session = await ort.InferenceSession.create(graph, {
executionProviders: ["wasm"],
externalData: [{ path: "model.onnx.data", data }], // register the external weights
});
// audio = raw 16 kHz mono Float32Array (normalisation is inside the graph)
const { logprobs } = await session.run({
input_values: new ort.Tensor("float32", audio, [1, audio.length]),
input_lengths: new ort.Tensor("int64", BigInt64Array.from([BigInt(audio.length)]), [1]),
});
// logprobs shape [1, frames, 37] ← 37 Latin-Romanian symbols, log-softmax
// greedy CTC decode: argmax per frame, merge duplicates, drop the blank (id 0), '▁' → space
const ids = argmaxPerFrame(logprobs);
const text = collapse(ids); // Romanian text — 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.