Tiny Malaysian STT Transducer
Speech-to-text for Malaysian speech (Malay, English, Mandarin, Tamil and the switching between them) on one CPU thread:
41.7M parameters, 54.4 MB in 8 bits, 42x real time. Whole clips or live audio, through sherpa-onnx.
Models
- Zipformer encoder, transducer head (stateless decoder and joiner), 8-bit ONNX, every file under 50 MB.
- Trained from scratch on transcripts by a fine-tuned Whisper large-v3 and by people, with telephone-line augmentation. This model and the streaming models are the same weights: the average of the weights of 10 runs, each
b-v3 trained 66,000 h more with a causal encoder that looks back 2.56 s and its own seed.
Use
pip install sherpa-onnx soundfile huggingface_hub
import sherpa_onnx, soundfile as sf
from huggingface_hub import snapshot_download
d = snapshot_download("Scicom-intl/Tiny-Malaysian-STT-Transducer", allow_patterns=['encoder.int8.onnx', 'decoder.int8.onnx', 'joiner.int8.onnx', 'tokens.txt'])
rec = sherpa_onnx.OfflineRecognizer.from_transducer(
encoder=f"{d}/encoder.int8.onnx", decoder=f"{d}/decoder.int8.onnx", joiner=f"{d}/joiner.int8.onnx", tokens=f"{d}/tokens.txt",
num_threads=1, sample_rate=16000, feature_dim=80, decoding_method="greedy_search")
samples, rate = sf.read("clip.wav", dtype="float32", always_2d=True)
stream = rec.create_stream()
stream.accept_waveform(rate, samples[:, 0])
rec.decode_stream(stream)
print(stream.result.text)
- One clip at a time, up to about 30 s, any sampling rate; cut longer audio into turns with a VAD. Cased and punctuated output.
b-v3: allow_patterns="b-v3/*", then d += "/b-v3".
b-v2: allow_patterns="b-v2/*", then d += "/b-v2".
Live audio
import numpy as np
d = snapshot_download("Scicom-intl/Tiny-Malaysian-STT-Transducer", allow_patterns="streaming/160ms/*") + "/streaming/160ms"
rec = sherpa_onnx.OnlineRecognizer.from_transducer(
encoder=f"{d}/encoder.int8.onnx", decoder=f"{d}/decoder.int8.onnx", joiner=f"{d}/joiner.int8.onnx", tokens=f"{d}/tokens.txt",
num_threads=1, sample_rate=16000, feature_dim=80, decoding_method="greedy_search")
s = rec.create_stream()
for piece in microphone(): # float32 samples at 16 kHz, any length (20 ms is fine)
s.accept_waveform(16000, piece)
while rec.is_ready(s):
rec.decode_stream(s)
print(rec.get_result(s), end="\r")
s.accept_waveform(16000, np.zeros(int(0.66 * 16000), np.float32)) # at the end: flush the look-ahead
s.input_finished()
while rec.is_ready(s):
rec.decode_stream(s)
print(rec.get_result(s))
streaming/160ms or streaming/320ms or streaming/640ms: the same weights exported for three chunk sizes.
Results
Error rate (%), lower is better, 8 bits, greedy decoding.
- Malaysian benchmark: Revolab ASR-Benchmark-Public. Held out: test rows of our own data, not public; the calls pool 187 clips.
- Teacher: the fine-tuned Whisper large-v3 behind most training transcripts. Whisper large-v3 as released, 8 bits; part of its Malaysian Mandarin comes out in traditional characters, which count as errors.
- This model minus Whisper large-v3 on the benchmark: -0.1 (95% interval -1.2 to +0.8).
Phone lines
Size and speed
- Speed: seconds of audio per second, greedy decoding. Qwen3-ASR, Omnilingual ASR and Moonshine run in 32-bit floats (size at one byte a parameter).
Streaming latency
- 300 benchmark clips fed as a microphone delivers them, 20 ms at a time, one CPU core. A word's latency: when it is on screen
for good minus when it was spoken (the chunk filling up, the model's look-ahead and the compute).
Accuracy progress
s-r2c replaced b-v3 as the default. s-r2c minus b-v3, this head, whole clip: benchmark -0.3 (95% interval -0.8 to +0.1); FLEURS English -2.4 (95% interval -3.1 to -1.8); FLEURS Mandarin (CER) -14.3 (95% interval -15.2 to -13.4); call-centre calls -0.5 (95% interval -1.2 to +0.2).
- The streaming runs read the whole clip too (the CTC and transducer columns); the last two columns are the same weights in 320 ms chunks.
Limits
- None of the models says which language was spoken.
- Tamil and Mandarin were learned from fewer sources than Malay and English.
- Most training transcripts were written by a model, so it shares some of that model's errors.