Krama Khmer ASR (krama-asr-khmer)
Krama Khmer ASR (krama-asr-khmer, 343.4M unique parameters / 345.0M untied in model.safetensors, Apache-2.0) is an open-source Khmer speech-to-text (Cambodian ASR) model trained on 1,568.77 hours across 8 domains for offline CPU, GPU, and browser inference.
Built atop Google's google/embeddinggemma-2 speech tower, it pairs a 6-layer Bidirectional RoPE InterCTC reader with a 3-layer causal cluster decoder (45k-step Phase 0 text pretraining + Stage 2A+ LM replay), adds microphone bandwidth/gain robustness, applies strict speaker and held-out prompt decontamination, and finishes with a Stage 2B Cycle-2 warm-restart SWA pass (75k total steps).
| Repository | Format / Runtime | Size | Decoding | Best For |
|---|---|---|---|---|
Nukthean/krama-asr-khmer (this repo) | PyTorch (bfloat16 SafeTensors) | 658.2 MiB | Greedy / Beam-5 | GPU / PyTorch pipelines & fine-tuning |
Nukthean/krama-asr-khmer-onnx | Dynamic INT8 ONNX (onnxruntime) | 358.3 MiB | Greedy / Beam-5 | Offline CPU (1.76× faster, zero PyTorch) |
Nukthean/krama-asr-khmer-demo | Static Space (onnxruntime-web WASM) | ~350 MB cached | Greedy | Instant client-side browser demo (no install) |
NukThean/krama-asr-khmer (GitHub) | Python CLI & self-hostable web/ | Source | Greedy / Beam-5 | Standalone inference code & offline web app |
Key Highlights
- Strong Generalization Across Domains & Unseen Speakers: Achieves
3.33%macro CER (51.4%exact match) across a 5-domain975-clip clean benchmark (2.69%CER on8unseeniAnyspeakers;6.32%CER across all755cleanFLEURS testclips). - 8-Domain Clean Corpus (
1,568.77 h): Trains acrossDDD,NXKMER,Slang,FLEURS,iAny,OpenSLR-42,MPWT, andGRKPP, with99.99411%orthographic cluster coverage (0 <unk>, zero spaces in transcripts). - Strict Leakage Guards: Frozen evaluation speakers (
8speakers /686clips fromiAny) and overlapping held-out prompts (52duplicate prompts fromNXKMER) are excluded from training pools. - Standalone Zero-Boilerplate API: Single-file
krama_asr.pywithload_model+transcribe,bfloat16weights on disk (658 MB, upcast tofloat32at load time for portable CPU/GPU inference), greedy CTC or beam-5 joint neural decoder rescoring. - Zero-PyTorch ONNX INT8 Version: Need CPU-only inference without
torchortransformers? SeeNukthean/krama-asr-khmer-onnx(358.3 MiBdynamic INT8 ONNX,3.34%Beam-5 macro CER,0.188 s/clipGreedy on Intel Core i5-13400F).
Model Architecture
| Component | Details |
|---|---|
| Audio Encoder | google/embeddinggemma-2 Audio Tower (12-layer Conformer, top 9 layers unfrozen in Stage 2B/3) |
| Adapter | Gemma4MultimodalEmbedder (1536 -> 512) |
| CTC Reader | 6-layer Bidirectional RoPE Self-Attention (d_model=512, 8 heads, d_ff=2048) with InterCTC taps at L2 & L4 |
| CTC Output Head | 2-layer SwiGLU bottleneck (512 -> 1024 -> 3,072) |
| Decoder Rescorer | 3-layer Causal Transformer (d_model=512, 8 heads, cross-attention to Reader L6, pretrained 45k steps on 573,689 Khmer sentences) |
| Vocabulary | 3,072 Khmer orthographic clusters (<blank>, <unk>, <s>, </s>, <pad> + 3,067 clusters) |
Quick Start
1. Install Dependencies (Python >= 3.11)
pip install "torch>=2.6" "transformers>=5.22" "safetensors>=0.8.0" soundfile soxr huggingface_hub
2. Run Inference in Python
Download the repository snapshot (or just krama_asr.py, model.safetensors, config.json, vocab.json) and pass your own Khmer audio file (WAV/FLAC/MP3 at any sample rate):
from huggingface_hub import hf_hub_download
import importlib.util
# Import standalone krama_asr.py from HF Hub (or local clone)
mod_path = hf_hub_download("Nukthean/krama-asr-khmer", "krama_asr.py")
spec = importlib.util.spec_from_file_location("krama_asr", mod_path)
krama_asr = importlib.util.module_from_spec(spec)
spec.loader.exec_module(krama_asr)
model, tokens = krama_asr.load_model("Nukthean/krama-asr-khmer")
# Fast CTC greedy decoding (~0.32s/clip median on Intel Core i5-13400F CPU)
# Replace with the path to your Khmer WAV/FLAC/MP3 audio file
text_fast = krama_asr.transcribe(model, tokens, "path/to/your_audio.wav")
print("Greedy:", text_fast)
# Beam-5 CTC + 3L Causal Decoder joint rescoring (recommended accuracy)
text_beam5 = krama_asr.transcribe(model, tokens, "path/to/your_audio.wav", use_decoder=True, beam_size=5)
print("Beam-5:", text_beam5)
Tip:
load_model(..., device="cpu")overrides auto-device selection (CUDA if available, else CPU), andtranscribe()also accepts an in-memorynp.ndarrayortorch.Tensorwaveform withsr=<sample_rate>.
Evaluation Benchmarks
All metrics below are normalized, space-free Khmer Character Error Rate (CER) (NFC normalization, ឲ្យ/អោយ -> ឱ្យ, whitespace and Khmer/ASCII punctuation stripped).
Cleaned & Audio-Verified Data: Public Khmer speech datasets often contain legacy encoding bugs, invalid character ordering, and transcript typos. Both training and evaluation splits use
Nukthean/krama-asr-khmer-corpus(repaired Unicode/subscript order, spoken Khmer numbers, Khmer transliteration of Latin loanwords, and audio-verified typo fixes —755validFLEURS testclips vs.771raw), so the model outputs valid Khmer script for real-world use and benchmarks measure recognition accuracy rather than dataset noise. (Note: scores on cleaned references are not directly comparable to raw upstream transcripts.)
Clean 5-Domain Benchmark (975 Clips / 136.4 min, Intel Core i5-13400F CPU)
| Split | Clips | Domain | Greedy CER | Greedy Exact | Greedy Latency | Beam-5 CER | Beam-5 Exact | Beam-5 Latency |
|---|---|---|---|---|---|---|---|---|
| DDD test | 200 | In-domain (seen speakers) | 3.53% | 36.0% | 0.31 s/clip | 3.20% | 45.0% | 0.36 s/clip |
| NXKMER test | 205 | In-domain | 4.28% | 31.7% | 0.41 s/clip | 4.12% | 34.6% | 0.49 s/clip |
| Slang val | 210 | In-domain (synthetic colloquial) | 0.69% | 78.6% | 0.27 s/clip | 0.49% | 87.1% | 0.32 s/clip |
| FLEURS test | 200 | Unseen speakers & text | 6.34% | 15.0% | 0.66 s/clip | 6.12% | 17.5% | 0.75 s/clip |
| iAny unseen | 160 | Unseen speakers (8 held-out) | 2.92% | 68.1% | 0.16 s/clip | 2.69% | 72.5% | 0.19 s/clip |
| All-5 Macro | 975 | All splits | 3.55% | 45.9% | 0.32 s/clip | 3.33% | 51.4% | 0.37 s/clip |
Full Split Evaluation (RTX 5090 bf16)
| Split | Clips | Greedy CER | Greedy Exact | Beam-5 CER | Beam-5 Exact |
|---|---|---|---|---|---|
| FLEURS test (unseen) | 755 | 6.50% | 12.2% | 6.32% | 15.0% |
| DDD test | 300 | 3.88% | 31.3% | 3.58% | 40.0% |
| NXKMER test | 205 | 4.28% | 32.7% | 4.13% | 34.1% |
| Slang val | 210 | 0.71% | 78.6% | 0.49% | 87.1% |
Training Data & Procedure
Training Corpus (1,568.77 h Total Across 8 Domains)
| Domain | Source | Train Clips | Train Hours | Notes |
|---|---|---|---|---|
DDD | Nukthean/krama-asr-khmer-corpus | 449,458 | 1,072.02 | 4,447 Parquet shards / 20 speakers (v38–v314) |
NXKMER | Nukthean/krama-asr-khmer-corpus | 122,089 | 442.91 | 52 held-out prompt duplicates excluded |
iAny | Nukthean/krama-asr-khmer-corpus | 4,938 | — | 70 train speakers (8 benchmark speakers / 686 clips held out; 5.29 h full pool) |
FLEURS | Nukthean/krama-asr-khmer-corpus | 1,675 | 7.10 | Train split |
OpenSLR-42 | Nukthean/krama-asr-khmer-corpus | 2,906 | 3.97 | Train split |
GRKPP | Nukthean/krama-asr-khmer-corpus | 722 | 3.23 | Train split |
MPWT | Nukthean/krama-asr-khmer-corpus | 2,058 | 1.90 | Train split |
Slang | Colloquial supplement | 15,903 | 24.97 | 14 everyday categories |
| Total | Public (1,543.80 h) + Slang (24.97 h) | 599,749 | 1,568.77 | 99.99411% cluster coverage (0 <unk>, zero spaces) |
Note: The public subtotal (1,543.80 h) reflects total duration across train, validation, and test splits in Nukthean/krama-asr-khmer-corpus (including iAny); per-domain rows report train-split hours.
Training Schedule (1× RTX 5090, bf16)
| Phase / Stage | Steps | Trainable Components & Objective |
|---|---|---|
| Phase 0 | 45,000 | 3L causal decoder text-only pretraining on 573,689 space-free decontaminated Khmer sentences (val_ppl=7.09) |
| Stage 1 | 1–3k | Adapters + 6L CTC Reader + decoder cross-attention |
| Stage 2A | 3–25k | + top 6 Conformer layers + full decoder + text LM replay |
| Stage 2B | 25–57k | + top 9 Conformer layers |
| Stage 3 (SWA) | 57–65k | SWA pass (50% augmentation, 1.0× speed) |
| Cycle-2 Flagship | +10k (75k total) | Warm restart from 65k SWA with Stage 2B LR schedule + Stage 3 SWA averaging (8 snapshots) |
Acoustic Augmentation
- Noise & Reverberation: Domain-tuned MUSAN background noise (
8–25 dBSNR) and OpenSLR RIRs & Noises room impulse responses. - Channel & Gain: Microphone bandwidth EQ roll-off and random gain (
-12 dBto+6 dB). - Time & Frequency: Speed perturbation (
0.9× / 1.0× / 1.1×) and SpecAugment (2frequency /4time masks). - Stage 3 SWA Annealing: Scaled to
50%augmentation strength with1.0×speed during Stage 3 SWA.
Limitations & Scope
- No Automatic Word Segmentation / Punctuation: Outputs clean space-free Khmer Unicode script (
vocab_cleaned-v9.json). Downstream word segmentation (e.g., Khmer word segmenter) or punctuation restoration can be applied if spaced display text is needed. - Long Audio (> 25s):
transcribe()chunks audio into 25-second windows automatically; boundary words right at exact 25s cuts are not overlapped in this standalone helper. - Vocabulary Normalization: Numerals, Latin tokens, and colloquial variants follow the training normalization (
ឲ្យ/អោយ -> ឱ្យ).
Krama Khmer ASR (krama-asr-khmer) គឺជាម៉ូដែលបំប្លែងសំឡេងជាអក្សរខ្មែរ (Khmer Speech-to-Text / ការស្គាល់សំឡេងភាសាខ្មែរ) បែប Open-Source (អាជ្ញាប័ណ្ណ Apache-2.0) ដែលមានប៉ារ៉ាម៉ែត្រ 343.4M និងត្រូវបានបណ្តុះបណ្តាលលើទិន្នន័យសំឡេងភាសាខ្មែរ 1,568.77 ម៉ោង ឆ្លងកាត់ 8 ប្រភេទទិន្នន័យ ដោយប្រើវាក្យសព្ទកន្សោមអក្សរខ្មែរ 3,072 ឯកតា។ ម៉ូដែលនេះអាចដំណើរការដោយគ្មានអ៊ីនធឺណិត (offline) លើ GPU, CPU (ONNX INT8) និងផ្ទាល់ក្នុងកម្មវិធីរុករកតាមអ៊ីនធឺណិត (browser) ដោយសម្រេចបានអត្រាខុសតួអក្សរ (Beam-5 CER) 6.32% លើ FLEURS test, 3.58% លើ DDD test, 2.69% លើអ្នកនិយាយថ្មី iAny និងមធ្យមភាគ 3.33% លើសំណុំតេស្ត 5-domain។
Citation
@misc{nukthean2026kramaasrkhmer,
title = {Krama Khmer ASR: Scaling Multi-Domain Khmer Speech Recognition},
author = {Nukthean},
year = {2026},
url = {https://huggingface.co/Nukthean/krama-asr-khmer}
}
Acknowledgments
Built atop Google's google/embeddinggemma-2 speech tower, open Khmer speech datasets from Digital Divide Data, Google FLEURS, OpenSLR-42, seanghay, sengtha, and community contributors, plus acoustic augmentation corpora MUSAN (OpenSLR-17) and RIRs & Noises (OpenSLR-28).