make_waveform / app.py
1littlecoder's picture
Update app.py
b2da359 verified
raw
history blame
1.01 kB
import gradio as gr
from moviepy.editor import AudioFileClip, ImageClip
def create_video(image, audio):
# Load the audio file
audio_clip = AudioFileClip(audio.name)
# Load the image file and set it to the duration of the audio
image_clip = ImageClip(image.name).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.inputs.Image(type="file", label="Upload Image"),
gr.inputs.Audio(type="file", label="Upload Audio")
],
outputs=gr.outputs.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()