Spaces:
Runtime error
Runtime error
File size: 987 Bytes
e39102f b2da359 e39102f b2da359 7abead3 e39102f b2da359 7abead3 b2da359 7abead3 b2da359 9f6393f b2da359 |
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 |
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()
|