Netra Lab


GitHub | PyPI | Docker Image | karna-large

karna-base

Streaming-native Khmer and English speech recognition that also works offline. karna-base is a 71M-parameter CTC model. It encodes each chunk of audio once (160 ms to 1.28 s, 640 ms by default) against a bounded cache, so text settles about half a second after it is spoken, nothing is ever rewritten, and the cost per chunk stays flat however long the stream runs. Given a whole file it uses full context instead: 1.7% CER on DDD, 10.7% on FLEURS-km and 10.0% WER on LibriSpeech test-clean. One set of weights does both.

It runs on ONNX Runtime with the netra-karna package, on a CPU, without PyTorch. The encoder is a structurally pruned Omnilingual ASR omniASR_CTC_300M (about 80% encoder sparsity), trained with dynamic chunk training on about 2,200 hours of Khmer and English with noise, reverb and phone augmentation.

Licence note. Two of the training corpora have unsettled terms: khm-asr-open declares no licence, and grkpp is research-only. They were used at the maintainers' risk. Check before commercial use.

Usage

pip install "netra-karna[cpu]"          # 1.4.0 or later: native streaming
import karna

asr = karna.load_model("karna-base")
print(asr.transcribe("speech.wav"))          # whole file, full context

live = asr.stream(chunk_ms=640)              # native streaming
for chunk in chunks:                         # 16 kHz mono float32, any block size
    for event in live.feed(chunk):
        print(event["type"], event["text"])
live.finish()

asr.stream(final="rescore") decodes each closed utterance again in full context (the S3 system below): more accurate, and a line may be rewritten when it closes. norm_tau_s=20 makes the input normalisation follow level changes. karna serve uses native streaming automatically for this model (/v1/stream); the Docker image does not include it yet.

Results

All numbers are for karna-base (71M) unless stated, on held-out test sets, in %. Lower is better.

Accuracy on test sets

Greedy CTC, no language model. Full context gives the model the whole utterance (offline); the other columns run the same weights in chunk mode, with the chunk size as the latency, and unlimited left context.

Test set Utterances Metric Full context 1,280 ms 640 ms 320 ms 160 ms
DDD 1,993 CER 1.7 1.8 2.0 2.4 3.0
FLEURS-km 771 CER 10.7 12.2 13.2 14.9 17.4
km-speech-corpus (held-out videos) 581 CER 18.3 18.9 18.4 19.3 22.4
iany (held-out speakers) 166 CER 9.0 8.9 11.1 12.8 15.6
OpenSLR 42 (held-out speakers) 224 CER 6.6 5.9 7.1 8.8 10.5
khm-asr-open 753 CER 11.2 12.8 13.9 15.3 17.8
grkpp 40 CER 5.7 6.2 7.5 8.1 9.4
nxkmer 187 CER 6.3 4.7 5.0 5.7 7.2
FLEURS-en 647 WER 26.7 31.2 34.4 38.6 44.8
LibriSpeech test-clean 2,620 WER 10.0 11.8 13.7 16.8 21.4
LibriSpeech test-other 2,939 WER 21.6 25.4 28.3 32.8 38.8
  • Offline: 1.7% CER on DDD, 10.7% on FLEURS-km and 10.0% / 21.6% WER on LibriSpeech test-clean / test-other.
  • Streaming: at 640 ms the Khmer sets are within 3 points of full context (DDD 1.7 → 2.0, FLEURS-km 10.7 → 13.2; the long nxkmer clips are better chunked). English loses more (test-clean 10.0 → 13.7, and 11.8 at 1,280 ms).
  • Chunk size is a latency knob. On the FLEURS-km dev set, the error relative to full context is +15% at 1,280 ms, +24% at 640 ms, +43% at 320 ms and +65% at 160 ms; 640 ms is the default. A left context of 2.56 s costs about 7% relative against an unbounded one, and keeps the state constant.
  • Test sets held out by speaker, video or block. The test sets of the added Khmer corpora are in-domain (their training splits are in the mix).

karna-large (217M, offline only, greedy): DDD 1.33% CER, FLEURS-km 10.20% CER, LibriSpeech test-clean 5.44% WER.

Streaming benchmark

Simulated live sessions of 10 minutes (utterances with 0.3 to 2 s gaps, noise, reverb, far-field and phone conditions), the same endpointer for every system, CPU with 4 threads, a simulated clock. Settled delay is how long after a character was spoken it became final for good; rewritten is how many characters the screen showed and then changed, per final character.

Mode FLEURS-km clean CER noise far LibriSpeech test-other clean WER far Settled delay (clean) Rewritten CPU compute per audio s
Native streaming (640 ms) 12.8 24.8 39.9 30.2 68.2 0.46 s 0 0.043 s
Native + full-context final per utterance 11.4 21.3 37.1 23.8 55.7 4.5 s 0.8 0.079 s
  + beam search and character LM 10.3 18.4 34.4 17.3 46.9 4.4 s 0.8 0.085 s
Re-decoding mode (draft every 0.8 s, one final per utterance) 11.4 24.9 37.7 24.1 55.8 2.5 s 1.9 0.30 s
  • Native streaming settles text in half a second and never rewrites it, with about 7× less compute than re-decoding.
  • A full-context final per utterance (final="rescore") is the most accurate; its text is final only when the utterance closes, so choose it when accuracy matters more than a stable line.

Long streams

One hour of continuous speech (52.6 min, no endpointer and no reset, 640 ms chunks, 2.56 s left context): memory stayed flat (the cache and the process size did not grow), a chunk took 6.2 ms on a GPU and 31 ms on a CPU (0.048 s per audio second; 0.074 s with 320 ms chunks), no chunk was late, and accuracy did not drift (CER 24.8% in the first half, 23.9% in the second). An unbounded left context is not used: its state grows linearly and accuracy falls.

  • Level changes. The model normalises its input with the running statistics of the stream, as in training. A sudden 20 dB drop raised the second-half CER from 25% to 42%; norm_tau_s=20, a decaying window, restores it to 23%. It is off by default.

Scripts: scripts/eval_chunked.py, scripts/eval_longstream.py and scripts/test_table.py in the GitHub repository.

How it was made

  • Architecture: a wav2vec2-style CTC encoder (7-layer CNN, convolutional position encoder, 24 pre-LayerNorm transformer layers of width 1,024, CTC head over Omnilingual's 9,812 characters), with attention heads and FFN units pruned per layer (config.json lists them).
  • Dynamic chunk training: half of the batches use chunked attention (chunks of 160 ms to 1.28 s, left context none, 64, 128 or 256 frames), a positional convolution that sees nothing after the chunk, and chunked running input normalisation. One network therefore serves every chunk size and full context.
  • Data: DDD, FLEURS, LibriSpeech, nxkmer-tts-450 (188 h), khm-asr-open, grkpp, iany, km-speech-corpus and OpenSLR 42, normalised to one Khmer convention, 50/50 Khmer and English, with noise, reverb and phone-band augmentation.
  • Training: 200,000 steps, CTC only (no distillation from a teacher, no attention decoder), peak learning rate 5e-5 with a linear decay over the last 60,000 steps. A frozen earlier model gives a KL term on clean batches, so English stays accurate.

Files

File Contents
onnx/model.onnx the whole-utterance graph (fp32): audio and lengths in, per-frame ids out
onnx/stream.onnx one streaming step: a chunk plus the caches in, ids and the caches out
onnx/vocab.json, onnx/netra-model.json vocabulary; preprocessing, streaming settings and the sha256 of each file
model.safetensors, config.json, vocab.json PyTorch weights, for fine-tuning (load with the karna_train code in the GitHub repository)

The ONNX graphs give the same ids as PyTorch: model.onnx on 16 of 16 random batches and 4 of 4 real clips, stream.onnx on 3,377 of 3,377 frames of 68 s of speech.

License and attribution

  • Weights: derived from Meta's Omnilingual ASR omniASR_CTC_300M (Apache 2.0) through karna-base, and released under Apache 2.0.
  • Training data: DDD (CC BY-SA 4.0), FLEURS (CC BY 4.0), LibriSpeech (CC BY 4.0), nxkmer-tts-450 (CC BY 4.0), iany (CC BY-SA 4.0), km-speech-corpus (CC BY 4.0), OpenSLR 42 (CC BY-SA 4.0); khm-asr-open (no licence declared) and grkpp (research only).
Downloads last month
187
Safetensors
Model size
71.3M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Netra-Lab/karna-base

Quantized
(6)
this model

Datasets used to train Netra-Lab/karna-base