from huggingface_hub import hf_hub_download import gradio as gr, subprocess, os # Download checkpoint once at startup ckpt = "Wav2Lip/checkpoints/wav2lip.pth" def generate(script, mic_path, video_path): if not (script and mic_path and video_path): return None, "⚠️ Provide script, audio, and video." os.makedirs("Wav2Lip/results", exist_ok=True) output = "Wav2Lip/results/output.mp4" subprocess.call([ "python", "Wav2Lip/inference.py", "--checkpoint_path", ckpt, "--face", video_path, "--audio", mic_path, "--outfile", output ]) # Check the output file if not os.path.exists(output): return None, "❗ Error: Video not generated." return output, "✅ Done!"