Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import os | |
| import subprocess | |
| import gdown | |
| # Auto-download the Wav2Lip pretrained model if it doesn't exist | |
| def download_model(): | |
| model_url = "https://drive.google.com/uc?id=1rwXzZ1R5RkAqpKfx-9k3dxC5Pp1fSzJv" # hosted model | |
| model_path = "wav2lip.pth" | |
| if not os.path.exists(model_path): | |
| gdown.download(model_url, model_path, quiet=False) | |
| return model_path | |
| # Main lipsync function | |
| def sync_lips(video, audio): | |
| model_path = download_model() | |
| output_path = "results/result_voice.mp4" | |
| os.makedirs("results", exist_ok=True) | |
| command = f"python3 inference.py --checkpoint_path {model_path} --face {video} --audio {audio} --outfile {output_path}" | |
| subprocess.call(command, shell=True) | |
| return output_path | |
| # Gradio Interface | |
| demo = gr.Interface( | |
| fn=sync_lips, | |
| inputs=["video", "audio"], | |
| outputs="video", | |
| title="Lip Sync Generator", | |
| description="Upload a face video (.mp4) and an audio file (.wav) to get a lip-synced output using Wav2Lip model." | |
| ) | |
| demo.launch() | |