Spaces:
Sleeping
Sleeping
import gradio as gr | |
import subprocess | |
import os | |
def run_talkshow_model(audio_file): | |
# Path to the TalkSHOW demo script | |
demo_script = 'scripts/demo.py' | |
# Configuration and model parameters | |
config_file = './config/LS3DCG.json' | |
body_model_name = 's2g_LS3DCG' | |
body_model_path = 'experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth' | |
# Temporary path to store the uploaded audio file | |
audio_file_path = './demo_audio/uploaded_audio.wav' | |
# Save the uploaded audio file to the expected location | |
audio_file.save(audio_file_path) | |
# Run the demo.py script with the necessary arguments | |
command = [ | |
'python', demo_script, | |
'--config_file', config_file, | |
'--infer', | |
'--audio_file', audio_file_path, | |
'--body_model_name', body_model_name, | |
'--body_model_path', body_model_path, | |
'--id', '0' | |
] | |
# Run the subprocess and capture any output | |
try: | |
subprocess.run(command, check=True) | |
return "Mesh generated successfully!" | |
except subprocess.CalledProcessError as e: | |
return f"Error running the model: {str(e)}" | |
# Set up the Gradio interface | |
interface = gr.Interface( | |
fn=run_ttalkshow_model, | |
inputs=gr.Audio(source="upload", type="filepath"), | |
outputs="text", | |
title="TalkSHOW: Audio to Mesh" | |
) | |
# Launch the interface | |
interface.launch() | |