Spaces:
Sleeping
Sleeping
import gradio as gr | |
import subprocess | |
import os | |
def run_inference(audio_file): | |
# Define the output video filename | |
output_video = "output_video.mp4" # Change this to your desired output filename | |
# Define the command to run your script | |
command = [ | |
"python", "scripts/demo.py", | |
"--config_file", "./config/LS3DCG.json", | |
"--infer", | |
"--audio_file", audio_file, | |
"--body_model_name", "s2g_LS3DCG", | |
"--body_model_path", "experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth", | |
"--id", "0", | |
] | |
# Run the command and capture the output | |
result = subprocess.run(command, capture_output=True, text=True) | |
# Check for errors | |
if result.returncode != 0: | |
return f"Error: {result.stderr}" | |
# Return the generated video file path | |
return output_video | |
# Create Gradio interface | |
interface = gr.Interface( | |
fn=run_inference, | |
inputs=gr.Audio(source="upload", type="filepath"), | |
outputs=gr.Video(type="file"), | |
title="Audio to Video Inference", | |
description="Upload an audio file to generate a video." | |
) | |
# Launch the app | |
if __name__ == "__main__": | |
interface.launch() | |