File size: 512 Bytes
5d2c0a9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #!/usr/bin/env bash
set -euo pipefail
if [ $# -lt 1 ]; then
echo "Usage: $0 <audio_root_dir>"
exit 1
fi
ROOT="$1"
find "$ROOT" -type f \( -iname "*.wav" -o -iname "*.mp3" -o -iname "*.m4a" -o -iname "*.mp4" \) | while IFS= read -r f; do
[ -e "$f" ] || continue
outf="${f%.*}.16k.wav"
if [ -f "$outf" ]; then
continue
fi
ffmpeg -hide_banner -loglevel error -y -i "$f" -ac 1 -ar 16000 -af loudnorm "$outf" || {
echo "Failed to normalize: $f" >&2
}
done
echo "Normalization complete."
|