Fix voice clone preview URL not matching saved file

The save_file_safely function may add a UUID suffix to the filename if there's
a collision, but the preview URL was being constructed using the original
filename instead of the actual saved filename. Now uses saved_preview_path.name.
This commit is contained in:
ajaysi
2026-04-20 14:08:43 +05:30
parent 625dd550d3
commit 4a4b8c5a24

View File

@@ -547,7 +547,12 @@ async def create_voice_clone(
saved_preview_path, error = save_file_safely(preview_audio_bytes, user_voice_dir, preview_filename)
if not error and saved_preview_path:
preview_url = f"/api/assets/{user_id}/voice_samples/{preview_filename}"
# Use actual saved filename (may have UUID suffix added by save_file_safely)
actual_filename = saved_preview_path.name
preview_url = f"/api/assets/{user_id}/voice_samples/{actual_filename}"
logger.info(f"[VoiceClone] Saved preview audio to: {saved_preview_path}")
else:
logger.error(f"[VoiceClone] Failed to save preview audio: {error}")
# 4. Save to Asset Library
asset_id = save_asset_to_library(