#!/usr/bin/env bash # Convert a RAVDESS speech-only extraction directory tree into a # rtx-csm manifest.jsonl with proper emotion_tag, transcript, and # speaker fields (parsed from the filename encoding). # # RAVDESS download (208 MB, no auth): # curl -L -O https://zenodo.org/records/1188976/files/Audio_Speech_Actors_01-24.zip # unzip Audio_Speech_Actors_01-24.zip -d /tmp/ravdess # # Filename convention (e.g. `03-01-04-01-02-01-12.wav`): # modality (01=AV, 02=video, 03=audio-only) # vocal channel (01=speech, 02=song) # emotion (01=neutral, 02=calm, 03=happy, 04=sad, 05=angry, 06=fearful, 07=disgust, 08=surprised) # intensity (01=normal, 02=strong; neutral has no strong) # statement (01="Kids are talking by the door", 02="Dogs are sitting by the door") # repetition (01, 02) # actor (01..24; odd = male, even = female) # # Output schema matches what `examples/steering_extract` expects: # {"wav": "", "transcript": "...", "emotion_tag": "[neutral]", # "speaker": 0|1} # # Usage: # scripts/build_ravdess_manifest.sh /tmp/ravdess > /tmp/ravdess/manifest.jsonl set -euo pipefail ROOT="${1:?usage: $0 }" if [[ ! -d "$ROOT" ]]; then echo "not a directory: $ROOT" >&2 exit 1 fi # zsh's `read` doesn't have -a, so spawn bash explicitly. bash -c ' ROOT="$1" for wav in "$ROOT"/Actor_*/*.wav; do base=$(basename "$wav" .wav) IFS="-" read -ra parts <<< "$base" emo_code="${parts[2]}" stmt_code="${parts[4]}" actor="${parts[6]}" case "$emo_code" in 01) e="neutral" ;; 02) e="calm" ;; 03) e="happy" ;; 04) e="sad" ;; 05) e="angry" ;; 06) e="fearful" ;; 07) e="disgust" ;; 08) e="surprised" ;; *) e="unknown" ;; esac case "$stmt_code" in 01) t="Kids are talking by the door." ;; 02) t="Dogs are sitting by the door." ;; *) t="" ;; esac spk=$((10#$actor % 2)) jq -nc --arg w "$wav" --arg t "$t" --arg e "$e" --argjson s "$spk" \ "{wav: \$w, transcript: \$t, emotion_tag: (\"[\" + \$e + \"]\"), speaker: \$s}" done ' _ "$ROOT"