Download scripts/benchmark_whisper.sh from NabuxAi/buddi-asr-source-code: direct link, hf CLI and curl.
- Browser
- Download file 3.65 kB
-
https://huggingface.co/datasets/NabuxAi/buddi-asr-source-code/resolve/main/scripts/benchmark_whisper.sh
- Command line
-
hf download hf://datasets/NabuxAi/buddi-asr-source-code/scripts/benchmark_whisper.sh
-
curl -L -o benchmark_whisper.sh https://huggingface.co/datasets/NabuxAi/buddi-asr-source-code/resolve/main/scripts/benchmark_whisper.sh
3.65 kB
| # Score a set of Whisper checkpoints on one held-out split, the way | |
| # arXiv:2510.23319 scored eight variants on Levantine child speech. | |
| # | |
| # The point is the comparison, so every checkpoint must see the same | |
| # utterances: the sample is drawn once, by seed, and reused for all of them. | |
| # | |
| # Usage: ./scripts/benchmark_whisper.sh [OPTIONS] [MODEL ...] | |
| set -Eeuo pipefail | |
| script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| project_root="$(cd "$script_dir/.." && pwd)" | |
| cd "$project_root" | |
| # The multilingual family only. The .en checkpoints cannot emit Arabic, so | |
| # including them would report a floor for the tokenizer, not for the model. | |
| default_models=( | |
| openai/whisper-tiny | |
| openai/whisper-base | |
| openai/whisper-small | |
| openai/whisper-medium | |
| openai/whisper-large-v3-turbo | |
| openai/whisper-large-v3 | |
| ) | |
| manifest="data/manifests/splits/test.jsonl" | |
| output_root="reports/benchmark" | |
| limit=600 | |
| seed=42 | |
| batch_size=16 | |
| device="auto" | |
| usage() { | |
| cat <<'EOF' | |
| Usage: ./scripts/benchmark_whisper.sh [OPTIONS] [MODEL ...] | |
| Options: | |
| --manifest PATH Split to score (default: data/manifests/splits/test.jsonl) | |
| --output-dir PATH Where per-model reports land (default: reports/benchmark) | |
| --limit N Speaker-stratified sample size; 0 scores everything (default: 600) | |
| --seed N Sampling seed, shared by every model (default: 42) | |
| --batch-size N Utterances per forward pass (default: 16) | |
| --device NAME auto|cpu|cuda|mps (default: auto) | |
| -h, --help Show this help | |
| Any trailing arguments replace the default model list. A local path works | |
| wherever a Hub id does, so a fine-tuned adapter can be compared against the | |
| stock checkpoints in the same table: | |
| ./scripts/benchmark_whisper.sh artifacts/tiny-lora/final openai/whisper-tiny | |
| EOF | |
| } | |
| while [[ $# -gt 0 ]]; do | |
| case "$1" in | |
| --manifest) manifest="${2:?missing value}"; shift 2 ;; | |
| --output-dir) output_root="${2:?missing value}"; shift 2 ;; | |
| --limit) limit="${2:?missing value}"; shift 2 ;; | |
| --seed) seed="${2:?missing value}"; shift 2 ;; | |
| --batch-size) batch_size="${2:?missing value}"; shift 2 ;; | |
| --device) device="${2:?missing value}"; shift 2 ;; | |
| -h|--help) usage; exit 0 ;; | |
| --*) echo "Unknown option: $1" >&2; usage >&2; exit 2 ;; | |
| *) break ;; | |
| esac | |
| done | |
| models=("$@") | |
| [[ ${#models[@]} -eq 0 ]] && models=("${default_models[@]}") | |
| for value in "$limit" "$seed" "$batch_size"; do | |
| [[ "$value" =~ ^[0-9]+$ ]] || { echo "Numeric options must be integers" >&2; exit 2; } | |
| done | |
| [[ -f "$manifest" ]] || { echo "Missing manifest: $manifest" >&2; exit 2; } | |
| mkdir -p "$output_root" | |
| echo "Manifest: $manifest" | |
| echo "Sample: ${limit:-all} utterances, seed $seed" | |
| echo "Models: ${#models[@]}" | |
| echo | |
| for model in "${models[@]}"; do | |
| # A Hub id contains a slash and a local checkpoint is a path; both need | |
| # flattening into one directory name. | |
| slug="${model//\//__}" | |
| destination="$output_root/$slug" | |
| if [[ -f "$destination/metrics.json" ]]; then | |
| echo "== $model -- already scored, skipping" | |
| continue | |
| fi | |
| echo "== $model" | |
| # One failure should not discard the models that already succeeded: a large | |
| # checkpoint can exhaust VRAM on a small GPU, and the rest of the sweep is | |
| # still worth having. | |
| # Module form, not the console script: see the note in train_gpu.sh. | |
| if ! python -m buddi_asr.cli evaluate "$model" "$manifest" "$destination" \ | |
| --device "$device" --batch-size "$batch_size" --limit "$limit" --seed "$seed"; then | |
| echo " failed; continuing" >&2 | |
| rm -rf "$destination" | |
| fi | |
| echo | |
| done | |
| python3 "$script_dir/summarize_benchmark.py" "$output_root" | |