A Bangla (Bengali) speech-to-text model that reuses google/embeddinggemma-2, a multimodal embedding model built for search, as a frozen audio encoder. Only a 19.9M-parameter Conformer-CTC head was trained. The encoder weights are unchanged.
The question behind this model: how much speech content does a retrieval embedding model keep inside its layers, and can a small head read it out as text?
Author: Md Hasibur Rahman (Evan): Hugging Face · GitHub · LinkedIn
google/fleurs, bn_in, test: 920 clips, 3.43 h)Out of domain for this model: read Wikipedia sentences, speakers and topics not seen in training.
| Decoding | CER | WER |
|---|---|---|
| Greedy CTC | 9.79% | 28.90% |
| Beam search (width 48) + word trigram LM | 8.51% | 25.69% |
| Decoding | CER | WER |
|---|---|---|
| Greedy CTC | 6.22% | 20.39% |
| Beam search + word trigram LM | 5.08% | 16.33% |
55 of these 500 validation sentences (11%) also occur in the training set, spoken by other speakers, so the validation numbers are somewhat optimistic. Use the FLEURS numbers for comparisons.
Scoring. References and hypotheses are both normalized the same way before scoring: Unicode NFC, then everything
outside the Bengali block (U+0980–U+09FF) is replaced by a space, then whitespace is collapsed. This removes
punctuation (including the danda ।) and Latin text. Published numbers that use a different normalization are not
directly comparable.
Measured on a laptop: NVIDIA RTX 2000 Ada Laptop GPU (8 GB), Intel Core i7-13800H, 14 PyTorch threads.
| Setup | Real-time factor | Speed | Greedy WER on the same 20 FLEURS clips |
|---|---|---|---|
| GPU, bf16 encoder + head | 0.0093 | 108x real time | 25.68% |
| CPU, fp32 | 0.0899 | 11.1x real time | 25.68% |
| CPU, int8 dynamic quantization (Linear layers) | 0.0510 | 19.6x real time | 26.67% |
Beam search with the LM runs on the CPU at about 1,100x real time.
16 kHz audio
-> EmbeddingGemma 2, frozen (audio tower + 24-layer backbone; vision tower not loaded)
-> hidden states of backbone layers 8, 16, 23 at the <|audio|> token positions (25 frames/s, 512-d)
-> fixed weighted mix: 0.3186 * L8 + 0.4617 * L16 + 0.2197 * L23, per-frame int8 rounding
-> Conformer head (trained): LayerNorm, Linear 512->320, 8 Conformer blocks, Linear 320->2500
-> CTC (blank = id 0) -> greedy, or beam search + word trigram LM
<|audio|> with the waveform, which is the processor's standard audio
placeholder. It expands to one token per 40 ms.<pad>) is
never produced by encode() and is used as the CTC blank, so the head has 2,500 outputs.pyctcdecode
shallow fusion with alpha 0.5, beta 1.0 and an OOV penalty of -10 (log10). KenLM was not used because it has no
Windows wheel. The LM was built from the transcripts of the training subset only (84,942 sentences, 63,925 words,
615,503 trigrams), after removing every sentence that appears in the validation set or in the FLEURS bn_in test set.
Alpha, beta and the OOV penalty were tuned on the validation set, not on FLEURS. The LM counts are not included in
this repo, because they are derived from the competition transcripts. build_lm.py rebuilds an LM from your own copy
of the competition train.csv.| Data | a 103.4 h subset (84,838 clips) of the Bengali.AI Speech Recognition competition data (OOD-Speech, Rakib et al., 2023), which has about 1,200 h in total. A subset was used because of compute and disk limits. Clips with more tokens than frames were removed |
| Text | the same normalization as in scoring |
| Objective | CTC |
| Optimizer | AdamW, lr 1e-3, weight decay 0.01, gradient clipping 1.0 |
| Schedule | linear warmup over 1,500 steps, then cosine decay to 0 |
| Batches | length-bucketed, up to 16,000 frames (about 640 s of audio) per batch (24,000 in epoch 1) |
| Regularization | dropout 0.1; SpecAugment-style masking: 2 time masks (up to 5% of frames) and 2 feature masks (up to 10% of channels) |
| Precision | bf16 autocast |
| Epochs | 35; checkpoint chosen by validation CER (epoch 33) |
| Hardware / time | one RTX 2000 Ada Laptop GPU (8 GB), about 2.5 h of training. Feature extraction (once) about 3 h |
The encoder was run once over the training subset and its features were cached. Training only reads the cached features.
The training subset is not published: the competition rules do not allow redistributing the competition data. Anyone who accepts the rules on Kaggle can download the full data.
| Greedy | Beam + LM | |
|---|---|---|
| Substitutions | 3,930 | 3,307 |
| Deletions | 269 | 258 |
| Insertions | 843 | 918 |
জানিয়েছিলেন -> জানিয়ে ছিলেন), which counts
as one substitution plus one insertion.OOV penalty sweep (alpha and beta re-tuned on validation for each value):
| OOV penalty | Val WER | FLEURS WER |
|---|---|---|
| -10 (used) | 16.33% | 25.69% |
| -6 | 16.41% | 25.22% |
| -4 | 16.63% | 24.89% |
| -2 | 16.90% | 25.51% |
A softer penalty is better on FLEURS but worse on validation. The reported number keeps the value chosen on validation.
pip install torch torchvision "transformers>=4.57" sentencepiece safetensors librosa soundfile huggingface_hub
# only for the LM:
pip install --no-deps pyctcdecode pygtrie sortedcontainers
python inference.py clip.wav --repo Noobbbbb/egemma2-bn-conformer-ctc # greedy
python inference.py clip.wav --repo Noobbbbb/egemma2-bn-conformer-ctc --lm --lm-path lm_trigram_counts.tsv.gz
python inference.py clip.wav --repo Noobbbbb/egemma2-bn-conformer-ctc --device cpu --int8
import sys
from huggingface_hub import snapshot_download
path = snapshot_download("Noobbbbb/egemma2-bn-conformer-ctc")
sys.path.insert(0, path)
from inference import BanglaSTT
stt = BanglaSTT(path)
print(stt.transcribe("clip.wav")) # greedy
Beam search with the LM needs the LM counts, which you build once from the competition transcripts (accept the rules
at https://www.kaggle.com/competitions/bengaliai-speech and download train.csv):
python build_lm.py path/to/train.csv # writes lm_trigram_counts.tsv.gz; FLEURS bn_in test sentences are removed
stt = BanglaSTT(path, lm_path="lm_trigram_counts.tsv.gz")
print(stt.transcribe("clip.wav", use_lm=True))
The reported LM numbers used an LM built from the 85k-sentence training subset. An LM built from the full train.csv
is larger, so its numbers will differ somewhat.
inference.py loads google/embeddinggemma-2 from the Hub. The encoder runs in bf16 on a GPU that supports it and
in fp32 otherwise. Do not run it in fp16: the base model card warns that fp16 gives NaN or degraded outputs. Audio
longer than 30 s is cut into 30 s pieces, and a word that falls on a cut can be split.
| File | |
|---|---|
model.safetensors |
Conformer-CTC head weights |
config.json |
feature layers and weights, head shape, decoding settings |
tokenizer.model |
2,500-piece SentencePiece model (blank = id 0) |
inference.py |
standalone inference (greedy and LM) |
build_lm.py |
builds the word trigram LM counts from the competition train.csv |
results/ |
the FLEURS result and the LM / CPU analysis as JSON |
@misc{rahman2026egemma2bnconformerctc,
title = {Bangla speech recognition on frozen EmbeddingGemma 2 features},
author = {Rahman, Md Hasibur},
year = {2026},
url = {https://huggingface.co/Noobbbbb/egemma2-bn-conformer-ctc}
}
@article{rakib2023oodspeech,
title = {{OOD-Speech: A Large Bengali Speech Recognition Dataset for Out-of-Distribution Benchmarking}},
author = {Rakib, Fazle Rabbi and Dip, Souhardya Saha and Alam, Samiul and Tasnim, Nazia and Shihab, Md Istiak Hossain and Ansary, Md Nazmuddoha and Hossen, Syed Mobassir and Meghla, Marsia Haque and Mamun, Mamunur and Sadeque, Farig and others},
journal = {Proc. Interspeech 2023},
year = {2023}
}
google/embeddinggemma-2