Spaces:
Sleeping
Sleeping
insanecoder69
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -12,8 +12,11 @@ def run_talkshow_model(audio_file):
|
|
12 |
body_model_path = 'experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth'
|
13 |
|
14 |
# Path of the uploaded audio file
|
15 |
-
audio_file_path = audio_file
|
16 |
-
|
|
|
|
|
|
|
17 |
# Run the demo.py script with the necessary arguments
|
18 |
command = [
|
19 |
'python', demo_script,
|
@@ -22,24 +25,31 @@ def run_talkshow_model(audio_file):
|
|
22 |
'--audio_file', audio_file_path,
|
23 |
'--body_model_name', body_model_name,
|
24 |
'--body_model_path', body_model_path,
|
25 |
-
'--id', '0'
|
|
|
26 |
]
|
27 |
|
28 |
-
# Run the subprocess and capture any output
|
29 |
try:
|
30 |
-
subprocess
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
except subprocess.CalledProcessError as e:
|
33 |
-
return f"Error running the model: {
|
34 |
|
35 |
# Set up the Gradio interface
|
36 |
interface = gr.Interface(
|
37 |
fn=run_talkshow_model,
|
38 |
inputs=gr.Audio(source="upload", type="filepath"),
|
39 |
-
outputs=
|
40 |
title="TalkSHOW: Audio to Mesh"
|
41 |
)
|
42 |
|
43 |
# Launch the interface
|
44 |
if __name__ == "__main__":
|
45 |
-
interface.launch()
|
|
|
12 |
body_model_path = 'experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth'
|
13 |
|
14 |
# Path of the uploaded audio file
|
15 |
+
audio_file_path = audio_file
|
16 |
+
|
17 |
+
# Path where the output .mp4 video will be saved
|
18 |
+
output_video_path = './output_video/result.mp4'
|
19 |
+
|
20 |
# Run the demo.py script with the necessary arguments
|
21 |
command = [
|
22 |
'python', demo_script,
|
|
|
25 |
'--audio_file', audio_file_path,
|
26 |
'--body_model_name', body_model_name,
|
27 |
'--body_model_path', body_model_path,
|
28 |
+
'--id', '0',
|
29 |
+
'--output', output_video_path # Assuming demo.py has an argument to specify output
|
30 |
]
|
31 |
|
|
|
32 |
try:
|
33 |
+
# Run the subprocess and capture output
|
34 |
+
subprocess.run(command, check=True, capture_output=True, text=True)
|
35 |
+
|
36 |
+
# Check if the .mp4 file is generated
|
37 |
+
if os.path.exists(output_video_path):
|
38 |
+
return output_video_path # Return the path of the generated video
|
39 |
+
else:
|
40 |
+
return "Error: Output video not generated."
|
41 |
+
|
42 |
except subprocess.CalledProcessError as e:
|
43 |
+
return f"Error running the model: {e.stderr}" # Return the error message
|
44 |
|
45 |
# Set up the Gradio interface
|
46 |
interface = gr.Interface(
|
47 |
fn=run_talkshow_model,
|
48 |
inputs=gr.Audio(source="upload", type="filepath"),
|
49 |
+
outputs=gr.Video(), # Use gr.Video to output the generated .mp4 video
|
50 |
title="TalkSHOW: Audio to Mesh"
|
51 |
)
|
52 |
|
53 |
# Launch the interface
|
54 |
if __name__ == "__main__":
|
55 |
+
interface.launch()
|