| 1 | #!/bin/bash |
| 2 | set -e |
| 3 | export PYTHONWARNINGS="ignore::UserWarning,ignore::FutureWarning" |
| 4 | |
| 5 | # Configuration parameters |
| 6 | MODEL_NAME="F5TTS_v1_Base" |
| 7 | SEEDS=(0 1 2) |
| 8 | CKPTSTEPS=(1250000) |
| 9 | TASKS=("seedtts_test_zh" "seedtts_test_en" "ls_pc_test_clean") |
| 10 | LS_TEST_CLEAN_PATH="data/LibriSpeech/test-clean" |
| 11 | GPUS="[0,1,2,3,4,5,6,7]" |
| 12 | OFFLINE_MODE=false |
| 13 | |
| 14 | # Parse arguments |
| 15 | if [ $OFFLINE_MODE = true ]; then |
| 16 | LOCAL="--local" |
| 17 | else |
| 18 | LOCAL="" |
| 19 | fi |
| 20 | INFER_ONLY=false |
| 21 | while [[ $# -gt 0 ]]; do |
| 22 | case $1 in |
| 23 | --infer-only) |
| 24 | INFER_ONLY=true |
| 25 | shift |
| 26 | ;; |
| 27 | *) |
| 28 | echo "======== Unknown parameter: $1" |
| 29 | exit 1 |
| 30 | ;; |
| 31 | esac |
| 32 | done |
| 33 | |
| 34 | echo "======== Starting F5-TTS batch evaluation task..." |
| 35 | if [ "$INFER_ONLY" = true ]; then |
| 36 | echo "======== Mode: Execute infer tasks only" |
| 37 | else |
| 38 | echo "======== Mode: Execute full pipeline (infer + eval)" |
| 39 | fi |
| 40 | |
| 41 | # Function: Execute eval tasks |
| 42 | execute_eval_tasks() { |
| 43 | local ckptstep=$1 |
| 44 | local seed=$2 |
| 45 | local task_name=$3 |
| 46 | |
| 47 | local gen_wav_dir="results/${MODEL_NAME}_${ckptstep}/${task_name}/seed${seed}_euler_nfe32_vocos_ss-1_cfg2.0_speed1.0" |
| 48 | |
| 49 | echo ">>>>>>>> Starting eval task: ckptstep=${ckptstep}, seed=${seed}, task=${task_name}" |
| 50 | |
| 51 | case $task_name in |
| 52 | "seedtts_test_zh") |
| 53 | python src/f5_tts/eval/eval_seedtts_testset.py -e wer -l zh -g "$gen_wav_dir" -n "$GPUS" $LOCAL |
| 54 | python src/f5_tts/eval/eval_seedtts_testset.py -e sim -l zh -g "$gen_wav_dir" -n "$GPUS" $LOCAL |
| 55 | python src/f5_tts/eval/eval_utmos.py --audio_dir "$gen_wav_dir" |
| 56 | ;; |
| 57 | "seedtts_test_en") |
| 58 | python src/f5_tts/eval/eval_seedtts_testset.py -e wer -l en -g "$gen_wav_dir" -n "$GPUS" $LOCAL |
| 59 | python src/f5_tts/eval/eval_seedtts_testset.py -e sim -l en -g "$gen_wav_dir" -n "$GPUS" $LOCAL |
| 60 | python src/f5_tts/eval/eval_utmos.py --audio_dir "$gen_wav_dir" |
| 61 | ;; |
| 62 | "ls_pc_test_clean") |
| 63 | python src/f5_tts/eval/eval_librispeech_test_clean.py -e wer -g "$gen_wav_dir" -n "$GPUS" -p "$LS_TEST_CLEAN_PATH" $LOCAL |
| 64 | python src/f5_tts/eval/eval_librispeech_test_clean.py -e sim -g "$gen_wav_dir" -n "$GPUS" -p "$LS_TEST_CLEAN_PATH" $LOCAL |
| 65 | python src/f5_tts/eval/eval_utmos.py --audio_dir "$gen_wav_dir" |
| 66 | ;; |
| 67 | esac |
| 68 | |
| 69 | echo ">>>>>>>> Completed eval task: ckptstep=${ckptstep}, seed=${seed}, task=${task_name}" |
| 70 | } |
| 71 | |
| 72 | # Main execution loop |
| 73 | for ckptstep in "${CKPTSTEPS[@]}"; do |
| 74 | echo "======== Processing ckptstep: ${ckptstep}" |
| 75 | |
| 76 | for seed in "${SEEDS[@]}"; do |
| 77 | echo "-------- Processing seed: ${seed}" |
| 78 | |
| 79 | # Store eval task PIDs for current seed (if not infer-only mode) |
| 80 | if [ "$INFER_ONLY" = false ]; then |
| 81 | declare -a eval_pids |
| 82 | fi |
| 83 | |
| 84 | # Execute each infer task sequentially |
| 85 | for task in "${TASKS[@]}"; do |
| 86 | echo ">>>>>>>> Executing infer task: accelerate launch src/f5_tts/eval/eval_infer_batch.py -s ${seed} -n \"${MODEL_NAME}\" -t \"${task}\" -c ${ckptstep} $LOCAL" |
| 87 | |
| 88 | # Execute infer task (foreground execution, wait for completion) |
| 89 | accelerate launch src/f5_tts/eval/eval_infer_batch.py -s ${seed} -n "${MODEL_NAME}" -t "${task}" -c ${ckptstep} -p "${LS_TEST_CLEAN_PATH}" $LOCAL |
| 90 | |
| 91 | # If not infer-only mode, launch corresponding eval task |
| 92 | if [ "$INFER_ONLY" = false ]; then |
| 93 | # Launch corresponding eval task (background execution, non-blocking for next infer) |
| 94 | execute_eval_tasks $ckptstep $seed $task & |
| 95 | eval_pids+=($!) |
| 96 | fi |
| 97 | done |
| 98 | |
| 99 | # If not infer-only mode, wait for all eval tasks of current seed to complete |
| 100 | if [ "$INFER_ONLY" = false ]; then |
| 101 | echo ">>>>>>>> All infer tasks for seed ${seed} completed, waiting for corresponding eval tasks to finish..." |
| 102 | |
| 103 | for pid in "${eval_pids[@]}"; do |
| 104 | wait $pid |
| 105 | done |
| 106 | |
| 107 | unset eval_pids # Clean up array |
| 108 | fi |
| 109 | echo "-------- All eval tasks for seed ${seed} completed" |
| 110 | done |
| 111 | |
| 112 | echo "======== Completed ckptstep: ${ckptstep}" |
| 113 | echo |
| 114 | done |
| 115 | |
| 116 | echo "======== All tasks completed!" |