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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- ar
|
| 5 |
+
- en
|
| 6 |
+
tags:
|
| 7 |
+
- speech
|
| 8 |
+
- asr
|
| 9 |
+
- automatic-speech-recognition
|
| 10 |
+
- ctc
|
| 11 |
+
- conformer
|
| 12 |
+
- egyptian-arabic
|
| 13 |
+
- code-switching
|
| 14 |
+
- arabic
|
| 15 |
+
- audio
|
| 16 |
+
- pytorch
|
| 17 |
+
library_name: metro-asr
|
| 18 |
+
pipeline_tag: automatic-speech-recognition
|
| 19 |
+
datasets:
|
| 20 |
+
- AlaaSamir/custom-egy-tts
|
| 21 |
+
- OmarAhmedSobhy/egyption-with-emotion-dataset
|
| 22 |
+
- MightyStudent/Egyptian-ASR-MGB-3
|
| 23 |
+
- MAdel121/arabic-egy-cleaned
|
| 24 |
+
- MAdel121/Continuation-egy-for-ultravox-v1
|
| 25 |
+
- Raniahossam33/Egyptian_TTS3RS
|
| 26 |
+
- ahmedbasemdev/egyptain-tts-dataset
|
| 27 |
+
- MohamedRashad/arabic-english-code-switching
|
| 28 |
+
- librispeech_asr
|
| 29 |
+
metrics:
|
| 30 |
+
- wer
|
| 31 |
+
- cer
|
| 32 |
+
model-index:
|
| 33 |
+
- name: Metro-ASR Small
|
| 34 |
+
results:
|
| 35 |
+
- task:
|
| 36 |
+
type: automatic-speech-recognition
|
| 37 |
+
name: Speech Recognition
|
| 38 |
+
dataset:
|
| 39 |
+
type: custom
|
| 40 |
+
name: Egyptian Arabic + Code-Switching Test Set
|
| 41 |
+
config: all
|
| 42 |
+
split: test
|
| 43 |
+
metrics:
|
| 44 |
+
- type: wer
|
| 45 |
+
value: 46.85
|
| 46 |
+
name: WER (All)
|
| 47 |
+
- type: cer
|
| 48 |
+
value: 28.41
|
| 49 |
+
name: CER (All)
|
| 50 |
+
- type: wer
|
| 51 |
+
value: 37.24
|
| 52 |
+
name: WER (Arabic)
|
| 53 |
+
- type: cer
|
| 54 |
+
value: 17.45
|
| 55 |
+
name: CER (Arabic)
|
| 56 |
+
- type: wer
|
| 57 |
+
value: 36.32
|
| 58 |
+
name: WER (Code-Switching)
|
| 59 |
+
- type: cer
|
| 60 |
+
value: 17.44
|
| 61 |
+
name: CER (Code-Switching)
|
| 62 |
+
---
|
| 63 |
+
|
| 64 |
+
<h1 align="center">Metro-ASR Small (61M)</h1>
|
| 65 |
+
|
| 66 |
+
<p align="center">
|
| 67 |
+
<strong>Non-Autoregressive CTC Speech Recognition for Egyptian Arabic + Code-Switching</strong>
|
| 68 |
+
</p>
|
| 69 |
+
|
| 70 |
+
<p align="center">
|
| 71 |
+
<a href="https://github.com/mohammedaly22/Metro-ASR"><img src="https://img.shields.io/badge/GitHub-Repository-blue?style=for-the-badge&logo=github" alt="GitHub"></a>
|
| 72 |
+
<a href="https://pypi.org/project/metro-asr/"><img src="https://img.shields.io/pypi/v/metro-asr?style=for-the-badge&logo=pypi&logoColor=white&color=blue" alt="PyPI"></a>
|
| 73 |
+
<a href="https://huggingface.co/spaces/mohammedaly22/metro-asr"><img src="https://img.shields.io/badge/%F0%9F%A4%97_Space-Demo-orange?style=for-the-badge" alt="Space"></a>
|
| 74 |
+
</p>
|
| 75 |
+
|
| 76 |
+
## Model Description
|
| 77 |
+
|
| 78 |
+
**Metro-ASR Small** is a 61M parameter non-autoregressive CTC-based ASR model built on a modern Conformer encoder. It is specifically designed for **Egyptian Arabic** (العامية المصرية) with native **Arabic-English code-switching** support.
|
| 79 |
+
|
| 80 |
+
### Architecture
|
| 81 |
+
|
| 82 |
+
| Component | Details |
|
| 83 |
+
|-----------|---------|
|
| 84 |
+
| Encoder | Conformer (12 layers, d_model=384, 6 heads) |
|
| 85 |
+
| Position Encoding | RoPE (Rotary Position Embeddings) |
|
| 86 |
+
| Feed-Forward | SwiGLU (Macaron-style dual FFN) |
|
| 87 |
+
| Normalization | RMSNorm (Pre-norm) |
|
| 88 |
+
| Convolution | SE-Gated Depthwise Separable (kernel=31) |
|
| 89 |
+
| Regularization | Stochastic Depth (rate=0.05) |
|
| 90 |
+
| Auxiliary Loss | Intermediate CTC at layer 6 |
|
| 91 |
+
| Tokenizer | BPE (SentencePiece, vocab=5000) |
|
| 92 |
+
| Decoding | CTC Greedy / Beam Search + KenLM |
|
| 93 |
+
| Parameters | 61.6M |
|
| 94 |
+
|
| 95 |
+
### Performance
|
| 96 |
+
|
| 97 |
+
| Split | WER (%) | CER (%) |
|
| 98 |
+
|-------|---------|---------|
|
| 99 |
+
| All | 46.85 | 28.41 |
|
| 100 |
+
| Arabic Only | 37.24 | 17.45 |
|
| 101 |
+
| Code-Switching | 36.32 | 17.44 |
|
| 102 |
+
|
| 103 |
+
**Speed:** RTF ~0.002 on CPU (500x faster than real-time)
|
| 104 |
+
|
| 105 |
+
## Usage
|
| 106 |
+
|
| 107 |
+
### Install
|
| 108 |
+
|
| 109 |
+
```bash
|
| 110 |
+
pip install metro-asr
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
### Quick Start
|
| 114 |
+
|
| 115 |
+
```python
|
| 116 |
+
from metro_asr import MetroASREngine
|
| 117 |
+
|
| 118 |
+
engine = MetroASREngine.from_pretrained("small") # Auto-downloads this model
|
| 119 |
+
result = engine.transcribe("audio.wav")
|
| 120 |
+
print(result.text)
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
### With Language Model (Beam Search)
|
| 124 |
+
|
| 125 |
+
```python
|
| 126 |
+
engine = MetroASREngine.from_pretrained(
|
| 127 |
+
"small",
|
| 128 |
+
lm_path="lm_5gram.bin", # Download from this repo
|
| 129 |
+
beam_width=100,
|
| 130 |
+
lm_alpha=0.5,
|
| 131 |
+
lm_beta=5.0,
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
result = engine.transcribe("audio.wav", beam_search=True)
|
| 135 |
+
print(result.text)
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
### Batch Transcription
|
| 139 |
+
|
| 140 |
+
```python
|
| 141 |
+
results = engine.transcribe_batch(["audio1.wav", "audio2.wav", "audio3.wav"])
|
| 142 |
+
for r in results:
|
| 143 |
+
print(f"{r.text} (RTF={r.rtf:.4f})")
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
## Files in this Repository
|
| 147 |
+
|
| 148 |
+
| File | Description | Size |
|
| 149 |
+
|------|-------------|------|
|
| 150 |
+
| `model.pt` | Model checkpoint (weights + optimizer state) | ~706MB |
|
| 151 |
+
| `config.yaml` | Model architecture configuration | <1KB |
|
| 152 |
+
| `bpe.model` | SentencePiece BPE tokenizer model | ~200KB |
|
| 153 |
+
| `bpe.vocab` | BPE vocabulary file | ~100KB |
|
| 154 |
+
| `lm_5gram.bin` | KenLM 5-gram language model (optional) | ~6GB |
|
| 155 |
+
|
| 156 |
+
## Training
|
| 157 |
+
|
| 158 |
+
Trained on a combination of open-source Egyptian Arabic datasets and custom YouTube data:
|
| 159 |
+
|
| 160 |
+
- **Audio data:** 130K+ samples from 8 datasets + YouTube Egyptian Arabic content
|
| 161 |
+
- **Text data:** 1.9M Egyptian sentences for LM training
|
| 162 |
+
- **Training:** 440K steps, batch size 32, 4x gradient accumulation, AdamW + Cosine LR
|
| 163 |
+
- **Hardware:** Single GPU training
|
| 164 |
+
|
| 165 |
+
## Limitations
|
| 166 |
+
|
| 167 |
+
- Optimized for Egyptian Arabic dialect; MSA and other dialects may have higher error rates
|
| 168 |
+
- Code-switching support is Arabic-English only
|
| 169 |
+
- Best performance on audio 0.5s-30s in duration
|
| 170 |
+
- The language model significantly improves accuracy but adds ~6GB to download
|
| 171 |
+
|
| 172 |
+
## Citation
|
| 173 |
+
|
| 174 |
+
```bibtex
|
| 175 |
+
@software{metro-asr-2025,
|
| 176 |
+
title = {Metro-ASR: Non-Autoregressive CTC-based ASR for Egyptian Arabic and Code-Switching},
|
| 177 |
+
author = {Mohammed Aly},
|
| 178 |
+
year = {2025},
|
| 179 |
+
url = {https://github.com/mohammedaly22/Metro-ASR}
|
| 180 |
+
}
|
| 181 |
+
```
|
| 182 |
+
|
| 183 |
+
## License
|
| 184 |
+
|
| 185 |
+
MIT
|