mich123geb commited on
Commit
952337e
·
verified ·
1 Parent(s): 6d6331e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import subprocess
4
+ import uuid
5
+
6
+ # Auto-download model if missing
7
+ if not os.path.exists("wav2lip_gan.pth"):
8
+ os.system("wget https://huggingface.co/akhaliq/Wav2Lip/resolve/main/wav2lip_gan.pth")
9
+
10
+ def generate(image, audio):
11
+ uid = str(uuid.uuid4())
12
+ image_path = f"{uid}.jpg"
13
+ audio_path = f"{uid}.wav"
14
+ output_path = f"{uid}_result.mp4"
15
+
16
+ image.save(image_path)
17
+ audio.save(audio_path)
18
+
19
+ command = f"python inference.py --checkpoint_path wav2lip_gan.pth --face {image_path} --audio {audio_path} --outfile {output_path}"
20
+ subprocess.run(command.split())
21
+
22
+ return output_path
23
+
24
+ gr.Interface(
25
+ fn=generate,
26
+ inputs=[
27
+ gr.Image(type="pil", label="Image"),
28
+ gr.Audio(type="filepath", label="Audio (WAV only)")
29
+ ],
30
+ outputs=gr.Video(label="Talking Video"),
31
+ live=True,
32
+ enable_queue=True
33
+ ).launch()