automatic-speech-recognition Β· audio Β· WASM (WebGPU when available) Β· ~1.27 GB
The English wav2vec2 demo speaks one language, the Russian XLSR demo another, the Mandarin XLSR demo a third. This one takes the same cross-lingual cousin to Japanese: XLSR-53 was pre-trained on 53 languages (56,000 hours of multilingual audio) and then fine-tuned on Japanese. Its output alphabet spans all three Japanese scripts at once β hiragana, katakana and kanji β a ~2,300-symbol character vocab. Same CTC mechanics (label every frame, then collapse), but with no language model the acoustic head has to pick a specific character for each run of sound, so it makes the phonetic substitutions a listener would (a wrong kanji, a hiragana where a kanji was written). Pick a clip and watch the frames collapse into Japanese.
| Model | FinDIT-Studio/wav2vec2-large-xlsr-53-japanese-onnx (base: jonatasgrosman/wav2vec2-large-xlsr-53-japanese) |
|---|---|
| Task / pipeline | automatic-speech-recognition β loaded as AutoModelForCTC so we can see the frames |
| Architecture | XLSR-53: wav2vec2-large cross-lingual encoder (24 transformer layers, ~315M params) pre-trained on 53 languages, fine-tuned for Japanese. CTC head over a ~2,300-symbol character vocab (blank + "|" boundary + digits + Latin letters + hiragana + katakana + kanji). No decoder, no language model. |
| Language | Japanese (ja) β this is a language-specialised recogniser; other languages produce Japanese-phonetic character gibberish |
| Quantization | fp32 (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:""; ~1.27 GB) |
| Config & vocab | the 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 model's bundled ~2,300-entry vocab.json |
| Backend | WebAssembly (WebGPU when a real adapter is present), honest fallback |
| Download | ~1.27 GB (single fp32 encoder), cached after first load β a big one-time transfer |
| License | Apache-2.0 (base model) β the ONNX-export repo inherits the base license |
| Web APIs | WebAssembly / WebGPU, Web Workers, Web Audio (decode + resample), MediaRecorder (mic) |
Choose Japanese 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 Japanese speech. Heads up: this model has no quantized export, so the first load is a ~1.27 GB fp32 download.
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 Japanese.
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. A run like
Β·Β· γ«γ« Β·Β· γ»γ» Β·Β· γγ collapses to γ«γ»γ.
Raw per-frame argmax (β frames Β· ~β ms each):
β merge duplicates, drop blanks β
Japanese mixes three scripts and is written without spaces between words, which makes it a great stress-test for speech AI: the model has to segment continuous sound into characters and pick the right one from thousands, with no spaces to lean on. Cross-lingual self-supervised pre-training is how XLSR-53 gets there: it learns what human speech sounds like from 53 languages at once, so fine-tuning to Japanese needs far fewer transcripts. That is what puts a usable Japanese 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 Japanese clip in, Japanese text out β and the per-frame strip that produced it.
Per-character forced alignment: real per-character timings, straight from the CTC frames.
Feed it English and watch cross-lingual transfer break down into Japanese-phonetic characters.
Transcribe Japanese with XLSR β OPUS-MT translates it to English, all on-device.
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). Because the character vocab is ~2,300 entries, we
build the idβcharacter map from vocab.json:
import { AutoConfig, AutoModelForCTC, Tensor } from "@huggingface/transformers";
const model_id = "FinDIT-Studio/wav2vec2-large-xlsr-53-japanese-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-japanese");
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, ~2341] β one score per Japanese character per frame
// greedy CTC decode: argmax per frame, merge duplicates, drop the blank (id 0)
const ids = argmaxPerFrame(logits);
const text = collapse(ids, id2char); // "ζ₯ζ¬β¦" β 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-character timings (from the frame each character was emitted at) β nothing is faked or pre-computed.