← All models

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

wav2vec2-XLSR-53 β€” Thai speech, one character per frame

The English wav2vec2 demo speaks one language, the Russian XLSR demo another, the Chinese and Japanese demos two more. This is another 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 Thai. That shared foundation is what makes a solid Thai recogniser trainable from a modest amount of labelled speech. Same CTC mechanics as the other models, but the output alphabet is the Thai script β€” consonants, vowels and tone marks. Thai is written without spaces between words, so the model also learned a | word-boundary symbol, which we render as a space. Pick a clip and watch the frames collapse into Thai.

At a glance

ModelBlackHand013/Wav2Vec2-large-xlsr-53-th-onnx (ONNX export of base: airesearch/wav2vec2-large-xlsr-53-th)
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 Thai. CTC head over a 70-symbol Thai vocab (blank [PAD] + | word boundary + Thai consonants, vowels and tone marks). No decoder.
LanguageThai (th) β€” a language-specialised recogniser; other languages produce Thai-phonetic gibberish. Thai has no inter-word spaces; the model emits a | boundary symbol we render as a space.
Quantizationfp32 (full precision) ONNX β€” a single wav2vec2-large-xlsr-53-th.onnx at the repo root (no q8/q4 export exists for this model, so we load fp32 with subfolder:"" + model_file_name)
Config & inputthe ONNX-export repo ships no config.json and no vocab, so we load the architecture config from the base airesearch repo, normalise the audio ourselves, and CTC-decode from the base repo's 70-symbol vocab. The ONNX graph's input node is named input (not the usual input_values).
BackendWebAssembly (WebGPU when a real adapter is present), honest fallback
Download~1.26 GB (single fp32 encoder), cached after first load β€” a big one-time transfer
LicenseCC-BY-SA-4.0 (base airesearch model and the ONNX-export repo)
Web APIsWebAssembly / WebGPU, Web Workers, Web Audio (decode + resample), MediaRecorder (mic)

Run it

Choose Thai audio β€” record from your mic, upload a file, or pick a 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 Thai speech. Heads up: this model has no quantized export, so the first load is a ~1.26 GB fp32 download.

or a sample:
Thai β€” Common Voice (CC0, ~6s)

Transcript (Thai)

Transcribe a clip to see the Thai text here.

See inside β€” the CTC collapse over Thai characters

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 character. The transcript is produced by two mechanical rules, no decoder involved: (1) merge consecutive duplicates, (2) drop the blanks. The | boundary symbol (␣) marks where the model thinks one word ends and the next begins.

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 Thai 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 Thai clip in, Thai text out β€” and the per-frame strip that produced it.

Practical

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

Wild

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

Multi-model

Transcribe Thai 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 vocab and keeps its ONNX at the repo root under a non-standard filename, 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 = "BlackHand013/Wav2Vec2-large-xlsr-53-th-onnx";
// the export repo has no config.json β†’ borrow the architecture config from the base repo
const config = await AutoConfig.from_pretrained("airesearch/wav2vec2-large-xlsr-53-th");
const model = await AutoModelForCTC.from_pretrained(model_id, {
  device: "wasm", dtype: "fp32",              // the only export is a single fp32 file…
  subfolder: "",                              // …at the repo ROOT…
  model_file_name: "wav2vec2-large-xlsr-53-th", // …under this non-standard name
  config,
});

// audio = 16 kHz mono Float32Array β†’ normalise to zero mean / unit variance (wav2vec2 feature step)
const x = normalize(audio);
// NOTE: this graph's input node is named `input`, not the usual `input_values`
const { logits } = await model({ input: new Tensor("float32", x, [1, x.length]) });
// logits shape [1, frames, 70]  ← 70 Thai symbols

// greedy CTC decode: argmax per frame, merge duplicates, drop the blank ([PAD]=69); | β†’ space
const ids  = argmaxPerFrame(logits);
const text = collapse(ids);             // Thai words, space-separated at | boundaries

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