import random import subprocess import os import gradio import gradio as gr import requests 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) res = requests.post("https://hdde.ru/api/upload.php",files={"filename":open(f"{output_file}","rb")}) print(res.text) return gradio.File(output_file) demo = gr.Interface(fn=predict, inputs=[gradio.Video(label='Source image/video'),gradio.Audio(type='filepath', label='Target Audio')], outputs=[gradio.File(type='binary',label='Output file')]) demo.launch()