File size: 732 Bytes
e2d19c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
import gradio as gr
import os

def generate_talking_head(image, audio):
    output_dir = "./results"
    os.makedirs(output_dir, exist_ok=True)

    # SadTalker ke inference command
    os.system(
        f"python inference.py "
        f"--driven_audio {audio} "
        f"--source_image {image} "
        f"--result_dir {output_dir}"
    )

    output_path = os.path.join(output_dir, "output.mp4")
    if os.path.exists(output_path):
        return output_path
    else:
        return None

iface = gr.Interface(
    fn=generate_talking_head,
    inputs=[gr.Image(type="filepath", label="Upload Image"),
            gr.Audio(type="filepath", label="Upload Audio")],
    outputs=gr.Video(label="Generated Video")
)

iface.launch()