goldpulpy's picture
Fix bugs
f025aa6
raw history blame
No virus
1.34 kB
import random
import subprocess
import os
import gradio
import gradio as gr
current_dir = os.path.dirname(os.path.abspath(__file__))
def predict(video, audio):
print(f"Processing video {video} and audio {audio}")
output_file = f"{current_dir}/results/{random.randint(10,100000)}.mp4"
command = ["python", "inference.py", "--face", video,
"--audio", audio, "--outfile", output_file]
subprocess.run(command, check=True)
return output_file
with gradio.Blocks(
title="Video Retalking SpaceAI",
theme=gr.themes.Base(
primary_hue=gr.themes.colors.green,
font=["Source Sans Pro", "Arial", "sans-serif"],
font_mono=['JetBrains mono', "Consolas", 'Courier New']
),
) as demo:
with gradio.Row():
gradio.Markdown("# Video Retalking SpaceAI")
with gradio.Row():
with gradio.Column():
v = gradio.Video(label='Source image/video')
with gradio.Column():
a = gradio.Audio(
type='filepath', label='Target Audio')
with gradio.Row():
btn = gradio.Button(value="Synthesize",variant="primary")
with gradio.Column():
o = gradio.Video(label="Output Video")
btn.click(fn=predict, inputs=[v, a], outputs=[o])
demo.queue().launch()