📋 Overview
General-purpose multilingual ASR models often struggle with colloquial Egyptian Arabic (عامية مصرية), paralinguistic disfluencies, acoustic background noise, and orthographic variations (Alef variants, Alef Maksura, diacritics, and punctuation mismatches).
DeepArab provides a production-oriented fine-tuning, evaluation, quantization, and deployment notebook tailored for an NVIDIA L4 (24 GB VRAM) on Google Colab. It takes raw 16 kHz WAV audio and CSV transcripts all the way from data auditing and memory-safe on-the-fly log-Mel feature extraction to a merged FP16 transformers model, an ~850 MB CTranslate2 INT8 faster-whisper engine, and 500 MB Parquet dataset shards on Hugging Face Hub.
✨ Key Highlights
- 100+ Hour Egyptian Arabic Corpus: Trains on
50,715 broadcast/clean segments (97.44 hours) and benchmarks separately across adapt_clean (974 clips) and adapt_noisy (1,225 clips) conversational dialect splits (2.99 hours).
- Zero-Cache On-the-Fly Spectrograms: Precomputing 128-bin
(128, 3000) Whisper Large-v3-Turbo log-Mel spectrograms for 50k+ samples generates ~78 GB of cache and risks OOMing Colab workers. Instead, DataCollatorSpeechSeq2SeqWithPadding loads 16 kHz WAVs on-the-fly with a 30s (480,000 samples) safety cap, keeping disk & RAM overhead minimal.
- Dialect-Aware Arabic Normalizer:
clean_arabic_text strips paralinguistic tags (<fil>, <laugh>, <overlap>), diacritics/Tashkeel (\u064B-\u0652), Tatweel (ـ), typographic artifacts (=, ÷, ⁇), and punctuation while unifying Alef ([إأآا] → ا) and Alef Maksura (ى → ي) for consistent WER and CER scoring.
- L4-Optimized LoRA Training (
BF16): Fine-tunes q_proj and v_proj (r=32, lora_alpha=64, dropout=0.05) with bf16=True, gradient checkpointing, effective batch size 32, and automatic checkpoint resumption from Google Drive.
- Edge & Production Export (
faster-whisper): Merges the best LoRA adapter back into FP16 weights, quantizes to CTranslate2 INT8, benchmarks WER, CER, and Real-Time Factor (RTF) on clean vs. noisy splits, and pushes both models and Parquet audio shards to Hugging Face Hub.
🏗️ End-to-End Pipeline Architecture
flowchart LR
A["DeepArab Corpus<br/>train (97.44h) · adapt (2.99h)"] --> B["Arabic Normalizer<br/>Tag Strip · Alef/Yaa · No Punct"]
B --> C["Label Tokenization<br/>WhisperTokenizer (ar · transcribe)"]
C --> D["On-the-Fly Collator<br/>16kHz WAV · 30s Cap · 128-Mel BF16"]
D --> E["Whisper Large-v3-Turbo + LoRA<br/>q_proj, v_proj · r=32, α=64 · L4 BF16"]
E --> F["Dual-Condition Eval<br/>Clean vs. Noisy WER & CER"]
F --> G["Merge LoRA -> FP16<br/>Hugging Face Model Hub"]
G --> H["CTranslate2 INT8 Export<br/>faster-whisper + RTF Benchmark"]
B --> I["Parquet Shards (500 MB)<br/>Hugging Face Datasets Hub"]
📊 DeepArab Dataset Breakdown
All metrics below are verified directly against train.csv, adapt.csv, and the 16 kHz Mono 16-bit PCM .wav corpus:
| Split |
Raw Clips |
Cleaned Clips |
Total Duration |
Min / Mean / Max Length |
Acoustic Profile & Handling |
train |
50,715 |
50,702 |
97.44 hrs |
1.01s / 6.92s / 12.80s |
Clean / broadcast Egyptian Arabic; drops 6 null & tag-only rows (0 clips > 30s) |
adapt_clean |
974 |
974 |
~1.3 hrs |
0.36s – 37.68s (overall adapt) |
Conversational Egyptian dialect in clean studio/quiet conditions |
adapt_noisy |
1,225 |
1,224 |
~1.7 hrs |
0.36s – 37.68s (overall adapt) |
Conversational Egyptian dialect under real acoustic noise (6 adapt clips > 30s capped at 30s) |
| Total Corpus |
52,914 |
52,900 |
100.43 hrs |
16 kHz · Mono · 16-bit PCM |
Bypasses runtime resampling when audio is already 16 kHz mono |
Why raw .wav files aren’t stored in Git: The full audio corpus (train/ at 11 GB + adapt/ at 334 MB) exceeds GitHub’s repository storage limits. This repository tracks the training/quantization notebook and the transcript manifests (train.csv & adapt.csv), while Section 17 of the notebook packages the full audio corpus into 500 MB Parquet shards for Hugging Face Datasets Hub.
🧹 Arabic Orthographic Normalization
Auditing train.csv and adapt.csv revealed zero punctuation in ground-truth transcripts, 657 inline paralinguistic/markup tags (e.g., <fil>, <laugh>, <overlap>), and minor typographic noise. Because Whisper generates punctuation by default, scoring raw predictions would artificially inflate WER.
The clean_arabic_text() helper normalizes both references and hypotheses before computing WER/CER:
- Tag Removal: Strips
<...> and [...] transcription/paralinguistic tags.
- Diacritic Stripping: Removes Arabic Tashkeel/Harakat (
\u064B–\u0652).
- Alef Unification: Normalizes
أ, إ, آ → ا.
- Alef Maksura Normalization: Maps
ى → ي.
- Tatweel & Noise Removal: Removes Kashida (
ـ) and audit artifacts (=, ÷, ⁇).
- Punctuation Stripping & Whitespace Collapse: Removes both Latin and Arabic (
،, ؛, ؟, «, ») punctuation.
⚙️ Model, LoRA & Training Configuration
| Component |
Setting |
Rationale |
| Base Backbone |
openai/whisper-large-v3-turbo |
809M params, 128 mel bins, fast 4-layer decoder |
| Language / Task |
arabic / transcribe |
Enforces Arabic transcription (forced_decoder_ids = None) |
| PEFT Method |
LoRA (r=32, lora_alpha=64, dropout=0.05) |
Adapts q_proj and v_proj attention projections efficiently |
| Numeric Precision |
Native bfloat16 (bf16=True) |
Hardware-accelerated on NVIDIA L4 without FP16 overflow |
| Batching |
16 per device × 2 grad accum = 32 effective |
Balanced throughput and 24 GB VRAM headroom |
| Optimization |
lr=1e-4, warmup_steps=400, max_steps=4000 |
Smooth convergence with gradient_checkpointing=True |
| Validation & Saving |
Every 500 steps · save_total_limit=3 |
Tracks best checkpoint via eval_wer (greater_is_better=False) |
| Fault Tolerance |
Google Drive checkpoint-* auto-resume |
Automatically resumes from the latest checkpoint after Colab disconnects |
🚀 Quickstart
Option 1: Run on Google Colab (Recommended — NVIDIA L4 GPU)
- Click the Open in Colab badge at the top of this README.
- Set Runtime → Change runtime type → L4 GPU (24 GB VRAM).
- Place
DeepArab/ (or DeepArab.zip) in Google Drive at /content/drive/MyDrive/DeepArab — extracting the .zip onto Colab’s local NVMe SSD (/content/DeepArab) avoids Drive FUSE I/O bottlenecks across 50,715 files.
- Run Sections 1–17 in whisper_arabic_finetuning_colab.ipynb sequentially.
Option 2: Local Setup
git clone https://github.com/marwan679/DeepArab.git
cd DeepArab
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
jupyter notebook whisper_arabic_finetuning_colab.ipynb
📦 Inference with Exported Models
Once Sections 14–16 complete and push your artifacts to Hugging Face Hub, you can run inference using either Transformers (FP16) or faster-whisper (CTranslate2 INT8):
from transformers import pipeline
asr = pipeline(
"automatic-speech-recognition",
model="<your-hf-username>/whisper-large-v3-turbo-egyptian-arabic",
device="cuda",
)
result = asr(
"sample.wav",
generate_kwargs={"language": "arabic", "task": "transcribe"},
)
print(result["text"])
2. faster-whisper (Quantized CTranslate2 INT8)
from faster_whisper import WhisperModel
# Use compute_type="int8_float16" on CUDA GPU or "int8" on CPU
model = WhisperModel(
"<your-hf-username>/whisper-large-v3-turbo-egyptian-arabic-ct2-int8",
device="auto",
compute_type="int8",
)
segments, info = model.transcribe("sample.wav", language="ar", task="transcribe")
print(" ".join(seg.text for seg in segments))
📁 Repository Structure
DeepArab/
├── whisper_arabic_finetuning_colab.ipynb # Full 17-section Colab pipeline (EDA -> LoRA -> CT2 INT8 -> HF Hub)
├── train.csv # 50,715 training manifest rows (audio ID, transcript)
├── adapt.csv # 2,199 adaptation manifest rows (clean + noisy splits)
├── requirements.txt # Reproducible Python dependencies
├── LICENSE # MIT License
├── .gitignore # Excludes 11+ GB local audio folders, checkpoints & caches
└── README.md # Project documentation
📄 License
Distributed under the MIT License. See LICENSE for full details.
评论