File size: 757 Bytes
7f90cea
 
a4c3f93
c249cf4
7f90cea
34441ec
 
7e0e287
7f90cea
 
 
7602259
7e0e287
7f90cea
7602259
6f7450f
b3bf8b2
7602259
a4c3f93
6f7450f
7f90cea
6f7450f
a4c3f93
7602259
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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!"