Spaces:
Sleeping
Sleeping
File size: 1,451 Bytes
1b8d40c 9e6f4e1 26b8f0d d6fcce5 1b8d40c d6fcce5 1b8d40c d6fcce5 26b8f0d d6fcce5 9e6f4e1 d6fcce5 1b8d40c d6fcce5 1b8d40c d6fcce5 1b8d40c d6fcce5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
import gradio as gr
import subprocess
import os
# Define the command template
COMMAND_TEMPLATE = "python scripts/demo.py --config_file ./config/LS3DCG.json --infer --audio_file {audio_path} --body_model_name s2g_LS3DCG --body_model_path experiments/2022-10-19-smplx_S2G-LS3DCG/ckpt-99.pth --id 0"
# Define the function to process the audio and generate the video
def process_audio(audio):
# Save uploaded audio to a specific file path
audio_path = "demo_audio/style.wav"
with open(audio_path, "wb") as f:
f.write(audio.read())
# Run the script command with the specified audio file
command = COMMAND_TEMPLATE.format(audio_path=audio_path)
subprocess.run(command, shell=True)
# Specify the path to the output video
output_video_path = "./output_video.mp4" # Update if output location is different
# Check if the video file exists and return it for display
if os.path.exists(output_video_path):
return output_video_path
else:
return "Error: Video file not generated."
# Set up Gradio interface
audio_input = gr.Audio(label="Upload a .wav audio file", type="file")
video_output = gr.Video(label="Generated Video Output")
interface = gr.Interface(
fn=process_audio,
inputs=audio_input,
outputs=video_output,
title="Audio-to-Video Generator",
description="Upload a .wav file to generate an animated video output."
)
# Launch the Gradio app
interface.launch()
|