#!/bin/bash
# Regenerate complete crow_t1 audio list from pickle file
# This will include ALL clips: main + stem + infill + other conditions

set -e

echo "=========================================="
echo "Regenerating Complete Crow T1 Audio List"
echo "=========================================="
echo ""

# Paths
INPUT_PKL="/home/tony/Data/Preference/crow_t1/interesting_clips_crow_t1_20251030_full_slice.pkl"
AUDIO_DIR="/app2/suno/data/dpo/audios/crow"
OUTPUT_JSONL="/home/tony/Data/Preference/crow_t1/crow_t1_audio_list_complete.jsonl"

echo "Input pickle: $INPUT_PKL"
echo "Audio dir:    $AUDIO_DIR"
echo "Output:       $OUTPUT_JSONL"
echo ""

# Run the script
python3 /home/tony/Work/tony/RealGen/create_crow_t1_audio_list.py \
    --input-pkl "$INPUT_PKL" \
    --audio-dir "$AUDIO_DIR" \
    --output "$OUTPUT_JSONL" \
    --verbose

echo ""
echo "=========================================="
echo "Complete audio list generated!"
echo "=========================================="
echo ""
echo "Next steps:"
echo "1. Compare with old list to find missing files"
echo "2. Run encoding ONLY on missing files"
echo ""
echo "To find missing encoded files:"
echo "  OLD_LIST=/home/tony/Data/Preference/crow_t1/crow_t1_audio_list.jsonl"
echo "  NEW_LIST=$OUTPUT_JSONL"
echo "  python3 -c \\"
echo "    import json"
echo "    old = set(json.loads(l)['id'] for l in open('$OLD_LIST'))"
echo "    new = set(json.loads(l)['id'] for l in open('$OUTPUT_JSONL'))"
echo "    missing = new - old"
echo "    print(f'Missing clips: {len(missing)}')"
echo "  \""


