|
|
|
|
@ -98,32 +98,34 @@ def generate_audio(
|
|
|
|
|
# ============================================================
|
|
|
|
|
|
|
|
|
|
container_path = chapter_text
|
|
|
|
|
# log(f"[AUDIO] CH{chapter_number}: container_path={container_path}")
|
|
|
|
|
|
|
|
|
|
# 1) Strip container prefix to get relative path: BOOK/VOLUME/FILE
|
|
|
|
|
if container_path.startswith(CONTAINER_PREFIX):
|
|
|
|
|
# Fix 1 — container_path kan None zijn → abort zonder crash
|
|
|
|
|
if not container_path:
|
|
|
|
|
log(f"[AUDIO] CH{chapter_number}: FATAL — no input path provided")
|
|
|
|
|
redis_client.delete(slot_key)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Fix 2 — veilige startswith
|
|
|
|
|
if CONTAINER_PREFIX and container_path.startswith(CONTAINER_PREFIX):
|
|
|
|
|
relative_path = container_path[len(CONTAINER_PREFIX) :].lstrip("/")
|
|
|
|
|
else:
|
|
|
|
|
relative_path = container_path # fallback
|
|
|
|
|
relative_path = container_path
|
|
|
|
|
|
|
|
|
|
parts = relative_path.split("/")
|
|
|
|
|
if len(parts) < 3:
|
|
|
|
|
log(
|
|
|
|
|
f"[AUDIO] CH{chapter_number}: FATAL — cannot parse book/volume from {relative_path}"
|
|
|
|
|
)
|
|
|
|
|
if slot_key:
|
|
|
|
|
redis_client.delete(slot_key)
|
|
|
|
|
redis_client.delete(slot_key)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
book_from_path = parts[0]
|
|
|
|
|
volume_from_path = parts[1]
|
|
|
|
|
|
|
|
|
|
# 2) Construct real host path
|
|
|
|
|
host_path = os.path.join(HOST_PATH, relative_path)
|
|
|
|
|
# log(f"[AUDIO] CH{chapter_number}: resolved_host_path={host_path}")
|
|
|
|
|
|
|
|
|
|
# ============================================================
|
|
|
|
|
# PREPARE OUTPUT DIR (always correct)
|
|
|
|
|
# OUTPUT PREP
|
|
|
|
|
# ============================================================
|
|
|
|
|
|
|
|
|
|
base_dir = os.path.join(HOST_PATH, book_from_path, volume_from_path, "Audio")
|
|
|
|
|
@ -132,8 +134,6 @@ def generate_audio(
|
|
|
|
|
safe_num = f"{chapter_number:04d}"
|
|
|
|
|
audio_file = os.path.join(base_dir, f"{safe_num}.m4a")
|
|
|
|
|
|
|
|
|
|
# log(f"[AUDIO] CH{chapter_number}: output_file={audio_file}")
|
|
|
|
|
|
|
|
|
|
if os.path.exists(audio_file):
|
|
|
|
|
log(f"[AUDIO] Skip CH{chapter_number} → already exists")
|
|
|
|
|
redis_client.delete(slot_key)
|
|
|
|
|
@ -158,7 +158,6 @@ def generate_audio(
|
|
|
|
|
# ============================================================
|
|
|
|
|
# RUN TTS
|
|
|
|
|
# ============================================================
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
subprocess.run(cmd, shell=True, check=True, timeout=AUDIO_TIMEOUT)
|
|
|
|
|
log(f"[AUDIO] CH{chapter_number}: Completed")
|
|
|
|
|
|