import subprocess import os def run_wav2lip(face, audio, out): # Ensure temp directory exists os.makedirs("temp", exist_ok=True) result = subprocess.run([ "python", "Wav2Lip/inference.py", "--checkpoint_path", "models/wav2lip.pth", "--face", face, "--audio", audio, "--outfile", out ], check=True, capture_output=True, text=True) # Check if the output file was created if not os.path.exists(out): raise RuntimeError(f"Wav2Lip failed to create output video. stderr: {result.stderr}")