#!/bin/bash # render-batch.sh DIR: render every song in DIR/manifest.json ([{slug, title, style, seed}], lyrics in DIR/.txt), # then trim dead tails and encode MP3. Skips songs that already have an MP3. Saves the semantic tokens of every take # (DIR/-s/semantic.json) so a take can be extended later with semantic_prefix_file. # Env: AUDIOCPP_CLI, YUE2_MODEL, PYTHON (needs numpy + PyAV for finish_track.py; default python3). set -u : "${AUDIOCPP_CLI:?set AUDIOCPP_CLI to your audiocpp_cli}" : "${YUE2_MODEL:?set YUE2_MODEL to the Yue2-3B-GGUF directory}" PYTHON=${PYTHON:-python3}; HERE=$(cd "$(dirname "$0")" && pwd) export ONEAPI_DEVICE_SELECTOR=${ONEAPI_DEVICE_SELECTOR:-level_zero:gpu} cd "$1" python3 -c "import json; [print(m['slug'], m['seed'], m['style'], sep='\t') for m in json.load(open('manifest.json'))]" | while IFS=$'\t' read -r slug seed style; do [ -f "$slug-s$seed.mp3" ] && { echo "skip $slug (done)"; continue; } start=$(date +%s) "$AUDIOCPP_CLI" --task gen --family yue2 --model "$YUE2_MODEL" --backend sycl --threads 8 \ --lyrics "$(cat "$slug.txt")" --request-option style="$style" --request-option cot=off \ --request-option semantic_max_tokens=6500 --request-option export_semantic=true \ --seed "$seed" --out-dir "$slug-s$seed" --out "$slug-s$seed.wav" --log > "$slug-s$seed.log" 2>&1 < /dev/null rc=$? echo "$slug rc=$rc wall=$(( $(date +%s)-start ))s $(grep -a 'yue2.semantic.tokens ' "$slug-s$seed.log" | awk '{print "tokens="$NF}')" [ $rc -eq 0 ] && "$PYTHON" "$HERE/finish_track.py" "$slug-s$seed.wav" "$slug-s$seed.mp3" done