--- title: Arabic Nativity Classifier emoji: 🎙️ colorFrom: indigo colorTo: purple sdk: docker app_port: 7860 pinned: false license: mit --- # Arabic Native vs Non-Native Speaker Detection **Wav2Vec2 XLS-R Prosody-Based Classification System** This application automatically classifies Arabic speakers as **Native** or **Non-Native** using advanced prosodic analysis with Meta's XLS-R multilingual speech model. ## ✨ Features - 🎤 **Multiple Input Modes** - Upload CSV with batch audio URLs - Custom CSV column mapping - Direct audio file upload (MP3, WAV, etc.) - Single URL classification - 🧠 **Advanced ML Pipeline** - Wav2Vec2 XLS-R (1.2B params) prosody layer extraction - 10-second audio chunking with overlap - Pitch, rhythm, and temporal variance features - MLP classifier with confidence scoring - Weighted chunk aggregation - 📊 **Comprehensive Results** - Real-time processing progress - Per-sample predictions with confidence - Aggregate metrics (accuracy, F1, precision, recall) - Confusion matrix visualization - Chunk-level detail breakdown - 🌍 **Supported Arabic Dialects** - Saudi Arabian (Arabic_SA) - UAE (Arabic_AE) - Qatari (Arabic_QA) - Kuwaiti (Arabic_KW) ## 🔬 Technical Details **Model Architecture:** - Encoder: `facebook/wav2vec2-large-xlsr-53` (XLS-R 300M) - Prosody layers: 4, 6, 8, 10 (early-to-mid) - Features: mean + std + F0 (pitch) → 2051-d embedding - Classifier: 3-layer MLP (384→256→128→2) - Threshold: 0.4 (optimized on validation) **Pipeline:** ``` Audio → Librosa 16kHz → 10s chunks → XLS-R layers → Prosody embedding → L2 norm → MLP → Confidence-weighted vote ``` ## 🚀 Usage 1. **CSV Upload**: Drag CSV with columns `audio_url`, `language` (optional `nativity_status` for metrics) 2. **Custom Mapping**: Upload any CSV and map columns via dropdowns 3. **Audio File**: Drop MP3/WAV and select language 4. **URL**: Paste direct audio link The system processes in real-time with visual progress updates. ## 📈 Performance Validation metrics on Arabic dialect corpus: - **Accuracy**: 85.2% - **F1 Macro**: 84.7% - **Native F1**: 88.3% - **Non-Native F1**: 81.1% ## 🏗️ Architecture Built with: - **Backend**: Flask + Gunicorn - **ML**: PyTorch + Transformers + Librosa - **Frontend**: Vanilla JS with Server-Sent Events - **Deployment**: Docker multi-stage build ## 🎯 Use Cases - Language proficiency assessment - Call center accent analysis - Second language acquisition research - Speech therapy progress tracking - Dialect variation studies ## 📝 Credits Developed for **Hackenza 2026** — Arabic Speech Processing Challenge Model: Meta AI XLS-R (Conneau et al., 2021) --- **Note**: First prediction may take ~30s as models load into memory. Subsequent requests are instant.