Spaces:
Sleeping
Sleeping
insanecoder69
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1 +1,47 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import subprocess
|
3 |
+
import os
|
4 |
+
|
5 |
+
def run_talkshow_model(audio_file):
|
6 |
+
# Path to the TalkSHOW demo script
|
7 |
+
demo_script = 'scripts/demo.py'
|
8 |
+
|
9 |
+
# Configuration and model parameters
|
10 |
+
config_file = './config/LS3DCG.json'
|
11 |
+
body_model_name = 's2g_LS3DCG'
|
12 |
+
body_model_path = 'experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth'
|
13 |
+
|
14 |
+
# Temporary path to store the uploaded audio file
|
15 |
+
audio_file_path = './demo_audio/uploaded_audio.wav'
|
16 |
+
|
17 |
+
# Save the uploaded audio file to the expected location
|
18 |
+
audio_file.save(audio_file_path)
|
19 |
+
|
20 |
+
# Run the demo.py script with the necessary arguments
|
21 |
+
command = [
|
22 |
+
'python', demo_script,
|
23 |
+
'--config_file', config_file,
|
24 |
+
'--infer',
|
25 |
+
'--audio_file', audio_file_path,
|
26 |
+
'--body_model_name', body_model_name,
|
27 |
+
'--body_model_path', body_model_path,
|
28 |
+
'--id', '0'
|
29 |
+
]
|
30 |
+
|
31 |
+
# Run the subprocess and capture any output
|
32 |
+
try:
|
33 |
+
subprocess.run(command, check=True)
|
34 |
+
return "Mesh generated successfully!"
|
35 |
+
except subprocess.CalledProcessError as e:
|
36 |
+
return f"Error running the model: {str(e)}"
|
37 |
+
|
38 |
+
# Set up the Gradio interface
|
39 |
+
interface = gr.Interface(
|
40 |
+
fn=run_ttalkshow_model,
|
41 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
42 |
+
outputs="text",
|
43 |
+
title="TalkSHOW: Audio to Mesh"
|
44 |
+
)
|
45 |
+
|
46 |
+
# Launch the interface
|
47 |
+
interface.launch()
|