Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,40 +1,27 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import subprocess
|
| 3 |
-
import os
|
| 4 |
|
| 5 |
-
|
| 6 |
-
assert os.path.exists("Wav2Lip/checkpoints/wav2lip.pth"), "checkpoint not found"
|
| 7 |
|
| 8 |
-
def generate(
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
# Assume mic_audio & webcam_video are files
|
| 14 |
-
audio_path = mic_audio.name
|
| 15 |
-
video_path = webcam_video.name
|
| 16 |
-
|
| 17 |
-
# Run Wav2Lip with your existing command
|
| 18 |
-
cmd = [
|
| 19 |
"python", "inference.py",
|
| 20 |
"--checkpoint_path", "checkpoints/wav2lip.pth",
|
| 21 |
"--face", video_path,
|
| 22 |
-
"--audio",
|
| 23 |
-
"--outfile",
|
| 24 |
-
]
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
return "results/output.mp4"
|
| 28 |
|
| 29 |
-
# Build Gradio interface
|
| 30 |
with gr.Blocks() as demo:
|
| 31 |
-
gr.Markdown("##
|
| 32 |
-
script_input = gr.Textbox(lines=4, placeholder="Paste your script here")
|
| 33 |
mic = gr.Audio(sources=["microphone"], type="filepath", label="Record Audio")
|
| 34 |
-
webcam = gr.Video(sources=["webcam"], label="Record Video")
|
| 35 |
-
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
| 39 |
|
| 40 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import subprocess, os
|
|
|
|
| 3 |
|
| 4 |
+
assert os.path.exists("checkpoints/wav2lip.pth")
|
|
|
|
| 5 |
|
| 6 |
+
def generate(mic_path: str, video_path: str):
|
| 7 |
+
output_path = "results/output.mp4"
|
| 8 |
+
os.makedirs("results", exist_ok=True)
|
| 9 |
+
subprocess.call([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
"python", "inference.py",
|
| 11 |
"--checkpoint_path", "checkpoints/wav2lip.pth",
|
| 12 |
"--face", video_path,
|
| 13 |
+
"--audio", mic_path,
|
| 14 |
+
"--outfile", output_path
|
| 15 |
+
])
|
| 16 |
+
return output_path
|
|
|
|
|
|
|
| 17 |
|
|
|
|
| 18 |
with gr.Blocks() as demo:
|
| 19 |
+
gr.Markdown("## 🎬 AI Lip‑Sync Video Recorder")
|
|
|
|
| 20 |
mic = gr.Audio(sources=["microphone"], type="filepath", label="Record Audio")
|
| 21 |
+
webcam = gr.Video(sources=["webcam"], type="filepath", label="Record Video")
|
| 22 |
+
btn = gr.Button("Generate Video")
|
| 23 |
+
out = gr.Video(label="Generated Video")
|
| 24 |
|
| 25 |
+
btn.click(generate, inputs=[mic, webcam], outputs=out)
|
| 26 |
|
| 27 |
+
demo.launch(share=True)
|