xcrop commited on
Commit
e2d19c3
·
verified ·
1 Parent(s): df902a7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+
4
+ def generate_talking_head(image, audio):
5
+ output_dir = "./results"
6
+ os.makedirs(output_dir, exist_ok=True)
7
+
8
+ # SadTalker ke inference command
9
+ os.system(
10
+ f"python inference.py "
11
+ f"--driven_audio {audio} "
12
+ f"--source_image {image} "
13
+ f"--result_dir {output_dir}"
14
+ )
15
+
16
+ output_path = os.path.join(output_dir, "output.mp4")
17
+ if os.path.exists(output_path):
18
+ return output_path
19
+ else:
20
+ return None
21
+
22
+ iface = gr.Interface(
23
+ fn=generate_talking_head,
24
+ inputs=[gr.Image(type="filepath", label="Upload Image"),
25
+ gr.Audio(type="filepath", label="Upload Audio")],
26
+ outputs=gr.Video(label="Generated Video")
27
+ )
28
+
29
+ iface.launch()