Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,16 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess, os
|
| 3 |
|
| 4 |
-
assert os.path.exists("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
def generate(mic_path: str, video_path: str):
|
| 7 |
-
output_dir = "results"
|
| 8 |
-
os.makedirs(output_dir, exist_ok=True)
|
| 9 |
-
output_path = os.path.join(output_dir, "output.mp4")
|
| 10 |
subprocess.call([
|
| 11 |
"python", "inference.py",
|
| 12 |
"--checkpoint_path", "checkpoints/wav2lip.pth",
|
|
@@ -19,12 +23,27 @@ def generate(mic_path: str, video_path: str):
|
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
gr.Markdown("## 🎬 AI Lip‑Sync Video Generator")
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
output_video = gr.Video(label="Generated Video")
|
| 27 |
|
| 28 |
-
btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
demo.launch(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess, os
|
| 3 |
|
| 4 |
+
assert os.path.exists("checkpoints/wav2lip.pth")
|
| 5 |
+
|
| 6 |
+
def generate(script: str, mic_path: str, video_path: str):
|
| 7 |
+
# Save script if you want to use it for TTS later
|
| 8 |
+
with open("script.txt", "w") as f:
|
| 9 |
+
f.write(script)
|
| 10 |
+
|
| 11 |
+
os.makedirs("results", exist_ok=True)
|
| 12 |
+
output_path = os.path.join("results", "output.mp4")
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
subprocess.call([
|
| 15 |
"python", "inference.py",
|
| 16 |
"--checkpoint_path", "checkpoints/wav2lip.pth",
|
|
|
|
| 23 |
with gr.Blocks() as demo:
|
| 24 |
gr.Markdown("## 🎬 AI Lip‑Sync Video Generator")
|
| 25 |
|
| 26 |
+
script_input = gr.Textbox(
|
| 27 |
+
lines=3,
|
| 28 |
+
placeholder="Paste your script here...",
|
| 29 |
+
label="1) Script Input"
|
| 30 |
+
)
|
| 31 |
+
mic = gr.Audio(
|
| 32 |
+
sources=["microphone"],
|
| 33 |
+
type="filepath",
|
| 34 |
+
label="2) Record Audio"
|
| 35 |
+
)
|
| 36 |
+
webcam = gr.Video(
|
| 37 |
+
sources=["webcam"],
|
| 38 |
+
label="3) Record Video"
|
| 39 |
+
)
|
| 40 |
+
btn = gr.Button("4) Generate Video")
|
| 41 |
output_video = gr.Video(label="Generated Video")
|
| 42 |
|
| 43 |
+
btn.click(
|
| 44 |
+
fn=generate,
|
| 45 |
+
inputs=[script_input, mic, webcam],
|
| 46 |
+
outputs=output_video
|
| 47 |
+
)
|
| 48 |
|
| 49 |
+
demo.launch()
|