Audio Processing Tutorial
# africomplings-audio-processing-labo
Audio analysis tools for speech corpora — compute corpus statistics and benchmark ASR models.
## Scripts
### `africomplings_compute_corpus_stats.py`
Compute audio statistics for a corpus of WAV files and generate summary plots.
#### What it computes per file
| Column | Source | Description |
|--------|--------|-------------|
| `Filename` | — | Basename of the WAV file |
| `Sample_Rate` | `soundfile.read()` | Audio sample rate (Hz) |
| `Duration_s` | `len(samples) / sr` | Duration in seconds |
| `Loudness_LUFS` | `pyloudnorm.Meter.integrated_loudness()` | Integrated loudness (ITU-R BS.1770) |
| `LRA_dB` | `pyloudnorm.Meter.loudness_range()` | Loudness Range (ITU-R BS.1770-4, G90-G10 percentile spread) |
| `Pitch_Hz` | `librosa.yin(fmin=75, fmax=600)` | Median fundamental frequency of voiced frames |
#### Plots generated
2×2 grid saved as PNG:
- Duration histogram + KDE curve
- Loudness (LUFS) histogram + KDE curve
- LRA (dB) histogram + KDE curve
- Loudness vs LRA scatter plot
#### Usage
```bash
# Scan audio/ directory, skip plots
python africomplings_compute_corpus_stats.py -d audio/ --no-plot
# Custom output file with plots
python africomplings_compute_corpus_stats.py -d /path/to/audio -o my_stats.tsv
```
| Argument | Description | Default |
|----------|-------------|---------|
| `-d, --audio-dir` | Directory to scan for `.wav` files (recursive) | `./audio` |
| `-o, --output` | Output TSV file path | `corpus_stats.tsv` |
| `--no-plot` | Skip plotting, only write TSV | `False` |
---
### `bench_asr.py`
Benchmark ASR models on a transcribed corpus — compare accuracy and speed.
#### What it reports
**Per-file table:** WER for each audio file per model.
**Aggregate summary:**
| Metric | Description |
|--------|-------------|
| **WER** (Word Error Rate) | 0 = perfect, lower is better |
| **RTF** (Realtime Factor) | `< 1.0` means faster than real-time |
| **Avg Latency** | Mean processing time per file |
#### Usag …