Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import subprocess
|
|
3 |
import os
|
4 |
from pydub import AudioSegment
|
5 |
import tempfile
|
|
|
|
|
6 |
os.environ["PYOPENGL_PLATFORM"] = "osmesa"
|
7 |
|
8 |
# Paths to TalkShow demo script and configuration
|
@@ -11,6 +13,9 @@ CONFIG_FILE = "./config/LS3DCG.json"
|
|
11 |
BODY_MODEL_PATH = "experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth"
|
12 |
OUTPUT_MP4_PATH = "./output/demo_output.mp4"
|
13 |
|
|
|
|
|
|
|
14 |
def convert_audio_to_wav(input_audio):
|
15 |
# Use a temporary file to save the .wav output
|
16 |
temp_wav = tempfile.NamedTemporaryFile(delete=False, suffix=".wav")
|
@@ -43,6 +48,8 @@ def run_demo_and_get_video(input_audio):
|
|
43 |
return OUTPUT_MP4_PATH
|
44 |
else:
|
45 |
return "Error: Output video not generated."
|
|
|
|
|
46 |
finally:
|
47 |
# Clean up the temporary .wav file after processing
|
48 |
os.remove(wav_path)
|
@@ -51,7 +58,9 @@ def run_demo_and_get_video(input_audio):
|
|
51 |
interface = gr.Interface(
|
52 |
fn=run_demo_and_get_video,
|
53 |
inputs=gr.Audio(source="upload", type="filepath"),
|
54 |
-
outputs=gr.Video()
|
|
|
|
|
55 |
)
|
56 |
|
57 |
# Launch the app
|
|
|
3 |
import os
|
4 |
from pydub import AudioSegment
|
5 |
import tempfile
|
6 |
+
|
7 |
+
# Set OpenGL platform
|
8 |
os.environ["PYOPENGL_PLATFORM"] = "osmesa"
|
9 |
|
10 |
# Paths to TalkShow demo script and configuration
|
|
|
13 |
BODY_MODEL_PATH = "experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth"
|
14 |
OUTPUT_MP4_PATH = "./output/demo_output.mp4"
|
15 |
|
16 |
+
# Ensure the output directory exists
|
17 |
+
os.makedirs(os.path.dirname(OUTPUT_MP4_PATH), exist_ok=True)
|
18 |
+
|
19 |
def convert_audio_to_wav(input_audio):
|
20 |
# Use a temporary file to save the .wav output
|
21 |
temp_wav = tempfile.NamedTemporaryFile(delete=False, suffix=".wav")
|
|
|
48 |
return OUTPUT_MP4_PATH
|
49 |
else:
|
50 |
return "Error: Output video not generated."
|
51 |
+
except subprocess.CalledProcessError as e:
|
52 |
+
return f"Error: {str(e)}"
|
53 |
finally:
|
54 |
# Clean up the temporary .wav file after processing
|
55 |
os.remove(wav_path)
|
|
|
58 |
interface = gr.Interface(
|
59 |
fn=run_demo_and_get_video,
|
60 |
inputs=gr.Audio(source="upload", type="filepath"),
|
61 |
+
outputs=gr.Video(type="file"),
|
62 |
+
title="TalkSHOW Demo",
|
63 |
+
description="Generate a video from audio input using TalkSHOW model."
|
64 |
)
|
65 |
|
66 |
# Launch the app
|