Spaces:
Runtime error
Runtime error
import gradio as gr | |
from moviepy.editor import AudioFileClip, ImageClip | |
def create_video(image, audio): | |
# Load the audio file | |
audio_clip = AudioFileClip(audio) | |
# Load the image file and set it to the duration of the audio | |
image_clip = ImageClip(image).set_duration(audio_clip.duration) | |
# Set the audio to the image clip | |
video_clip = image_clip.set_audio(audio_clip) | |
# Save the video to a temporary file | |
output_path = "/tmp/output_video.mp4" | |
video_clip.write_videofile(output_path, fps=30) | |
return output_path | |
# Create Gradio interface | |
iface = gr.Interface( | |
fn=create_video, | |
inputs=[ | |
gr.Image(type="filepath", label="Upload Image"), | |
gr.Audio(type="filepath", label="Upload Audio") | |
], | |
outputs=gr.Video(label="Output Video"), | |
title="Image + Audio to Video Converter", | |
description="Upload an image and an audio file to generate a video with the image and audio combined." | |
) | |
iface.launch() | |