This commit is contained in:
Andras Schmelczer 2026-05-26 19:45:13 +01:00
parent c645b0f1d4
commit 39ef5c6646
79 changed files with 5660 additions and 2199 deletions

View file

@ -14,9 +14,11 @@
# bootstrap step; you supply real account credentials.
#
# Usage:
# ./render.sh # local stack
# ./render.sh --prod # prod (requires LOGIN_EMAIL/LOGIN_PASSWORD)
# ./render.sh # local stack, English homepage landscape + portrait
# ./render.sh --prod # prod, English homepage landscape + portrait
# ./render.sh --target prod # same as --prod
# VIDEO_STORYBOARD_SET=ads ./render.sh --prod # render social ads instead
# VIDEO_STORYBOARD_SET=demo ./render.sh --prod # render every homepage locale
# ./render.sh --fresh-auth # force re-auth even if cache is fresh
# ./render.sh --resume # preserve completed recordings and continue
# ./render.sh --no-encode # stop at WebM, skip MP4 encode
@ -312,6 +314,20 @@ if [ "$DO_AUDIO" = "1" ]; then
say "Synchronising tts/ Python deps"
uv sync --project tts ${uv_sync_extras[@]+"${uv_sync_extras[@]}"} || fail "uv sync failed in video/tts"
if [ -z "${TTS_DEVICE:-}" ]; then
if command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi -L >/dev/null 2>&1; then
gpu_free_mb="$(nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits 2>/dev/null | head -1 | tr -d ' ')"
if [ "${gpu_free_mb:-0}" -ge 8000 ]; then
export TTS_DEVICE="cuda:0"
else
export TTS_DEVICE="cpu"
say "GPU has ${gpu_free_mb:-0}MiB free; using CPU for TTS to avoid CUDA OOM"
fi
else
export TTS_DEVICE="cpu"
fi
fi
# Voice consistency: every ad in this set declares the same AD_VOICE
# (instruct/seed/temperature/topP/referenceText). Even with seed-locked
# VoiceDesign, independent invocations across processes can produce
@ -325,10 +341,17 @@ if [ "$DO_AUDIO" = "1" ]; then
# which it always does, because every ad shares AD_VOICE.
shared_ref_wav=""
shared_ref_meta=""
shared_audio_dir=""
for sb in "${STORYBOARDS[@]}"; do
if [ -n "$shared_ref_wav" ] && [ -f "$shared_ref_wav" ] && [ -f "$shared_ref_meta" ]; then
if [ -n "$shared_audio_dir" ] && [ -d "$shared_audio_dir" ]; then
mkdir -p "output/$sb/audio"
cp -f "$shared_ref_wav" "output/$sb/audio/_reference.wav"
for cached_audio_file in "$shared_audio_dir"/*.wav "$shared_audio_dir"/*.json; do
[ -f "$cached_audio_file" ] || continue
cp -f "$cached_audio_file" "output/$sb/audio/$(basename "$cached_audio_file")"
done
elif [ -n "$shared_ref_wav" ] && [ -f "$shared_ref_wav" ] && [ -f "$shared_ref_meta" ]; then
mkdir -p "output/$sb/audio"
cp -f "$shared_ref_wav" "output/$sb/audio/_reference.wav"
cp -f "$shared_ref_meta" "output/$sb/audio/_reference.meta.json"
fi
say "Synthesising narration for [$sb]"
@ -342,6 +365,9 @@ if [ "$DO_AUDIO" = "1" ]; then
shared_ref_meta="output/$sb/audio/_reference.meta.json"
say "Locked voice reference to $shared_ref_wav — reusing for the rest of the set"
fi
if [ -z "$shared_audio_dir" ] && [ -s "output/$sb/audio/index.json" ]; then
shared_audio_dir="output/$sb/audio"
fi
done
fi