Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
import subprocess
|
| 4 |
+
|
| 5 |
+
# Function to run Wav2Lip model
|
| 6 |
+
def run_wav2lip(video_path, audio_path):
|
| 7 |
+
# Define the command to run the Wav2Lip model
|
| 8 |
+
command = f"python inference.py --face {video_path} --audio {audio_path} --outfile output_result.mp4"
|
| 9 |
+
|
| 10 |
+
# Execute the command
|
| 11 |
+
subprocess.run(command, shell=True, check=True)
|
| 12 |
+
|
| 13 |
+
# Return the output video file path
|
| 14 |
+
return "output_result.mp4"
|
| 15 |
+
|
| 16 |
+
# Gradio Interface
|
| 17 |
+
interface = gr.Interface(
|
| 18 |
+
fn=run_wav2lip,
|
| 19 |
+
inputs=[
|
| 20 |
+
gr.inputs.Video(label="Input Video"),
|
| 21 |
+
gr.inputs.Audio(label="Input Audio")
|
| 22 |
+
],
|
| 23 |
+
outputs=gr.outputs.Video(label="Output Video"),
|
| 24 |
+
title="Wav2Lip Model",
|
| 25 |
+
description="Upload a video and an audio file to run the Wav2Lip model."
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Launch the Gradio app
|
| 29 |
+
if __name__ == "__main__":
|
| 30 |
+
interface.launch()
|