← All models

automatic-speech-recognition · audio · WASM (WebGPU when available) · ~1.2 GB

wav2vec2-XLSR-53 — Portuguese speech, one accented character per frame

The English wav2vec2 demo speaks one language, the Russian XLSR demo another, and the French, Spanish and Italian XLSR demos three more. This is a sixth specialisation of the same cross-lingual cousin: XLSR-53 was pre-trained on 53 languages (56,000 hours of multilingual audio) and then fine-tuned on Portuguese. That shared foundation is what makes a solid Portuguese recogniser trainable from a modest amount of labelled speech — the model already learned what human speech sounds like before it ever saw a Portuguese transcript. Same CTC mechanics as the English, Russian, French, Spanish and Italian models, but the output alphabet carries the Portuguese diacritics (à á â ã ç é ê í ó ô õ ú), including the nasal tildes (ã õ) and the cedilla (ç). Pick a clip and watch the frames collapse into Portuguese.

At a glance

ModelFinDIT-Studio/wav2vec2-large-xlsr-53-portuguese-onnx (base: jonatasgrosman/wav2vec2-large-xlsr-53-portuguese)
Task / pipelineautomatic-speech-recognition — loaded as AutoModelForCTC so we can see the frames
ArchitectureXLSR-53: wav2vec2-large cross-lingual encoder (24 transformer layers, ~315M params) pre-trained on 53 languages, fine-tuned for Portuguese. CTC head over a 46-symbol Latin-Portuguese vocab (blank + "|" boundary + apostrophe + hyphen + 26 letters + à á â ã ç é ê í ó ô õ ú ü). No decoder.
LanguagePortuguese (pt) — this is a language-specialised recogniser; other languages produce Portuguese-phonetic gibberish
Quantizationfp32 (full precision) ONNX — a single model.onnx at the repo root (no q8/q4 export exists for this model, so we load fp32 with subfolder:"")
Config & tokenizerthe ONNX-export repo ships no config.json and no preprocessor_config.json, so we load the architecture config from the base jonatasgrosman repo it was exported from, do the wav2vec2 feature normalisation ourselves, and CTC-decode from the repo's 46-symbol tokenizer.json vocab
BackendWebAssembly (WebGPU when a real adapter is present), honest fallback
Download~1.2 GB (single fp32 encoder), cached after first load — a big one-time transfer
LicenseApache-2.0 (base model) — the ONNX-export repo declares no license of its own
Web APIsWebAssembly / WebGPU, Web Workers, Web Audio (decode + resample), MediaRecorder (mic)

Run it

Choose Portuguese 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. XLSR-53 does best on clear Portuguese speech. Heads up: this model has no quantized export, so the first load is a ~1.2 GB fp32 download.

or a sample:
Portuguese — Castelo Branco, ‘Amor de Perdição’ (Public Domain, 12s)

Transcript (Portuguese)

Transcribe a clip to see the Portuguese text here.

See inside — the CTC collapse over Portuguese letters

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 ·· mm ·· ãã ·· oo collapses to mão.

emitted character ␣ word boundary · blank frame
Transcribe a clip to see its per-frame argmax and the collapse.

Why it matters

Most of the world's ~7,000 languages have little labelled speech data. Cross-lingual self-supervised pre-training is how the field reaches them: XLSR-53 learns speech structure from 53 languages at once, so fine-tuning to a new language needs far fewer transcripts. That is what puts a usable Portuguese 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.

Use cases

Basics

One Portuguese clip in, Portuguese text out — and the per-frame strip that produced it.

Practical

Forced alignment: real per-word Portuguese timings, straight from the CTC frames.

Wild

Feed it English and watch cross-lingual transfer break down into Portuguese phonetics.

Multi-model

Transcribe Portuguese with XLSR → OPUS-MT translates it to English, all on-device.

How the API works

Normally the one-liner is the ASR pipeline — but this repo ships no config.json or preprocessor_config.json and keeps its ONNX at the repo root, so we load the model with a config borrowed from the base repo, normalise the audio ourselves, and do the CTC collapse (which is exactly what the pipeline does internally):

import { AutoConfig, AutoModelForCTC, Tensor } from "@huggingface/transformers";

const model_id = "FinDIT-Studio/wav2vec2-large-xlsr-53-portuguese-onnx";
// the export repo has no config.json → borrow the architecture config from the base repo
const config = await AutoConfig.from_pretrained("jonatasgrosman/wav2vec2-large-xlsr-53-portuguese");
const model = await AutoModelForCTC.from_pretrained(model_id, {
  device: "wasm", dtype: "fp32",   // the only export is a single fp32 model.onnx…
  subfolder: "",                   // …at the repo ROOT, not the usual onnx/ subfolder
  config,
});

// 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, 46]  ← 46 Latin-Portuguese symbols

// greedy CTC decode: argmax per frame, merge duplicates, drop the blank (id 0)
const ids  = argmaxPerFrame(logits);    // e.g. [0,0,19,19,0,36,21,...]
const text = collapse(ids);             // "mão…" in Portuguese — 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.

References