switin06's picture
Update app.py
7a1ef03 verified
raw
history blame contribute delete
862 Bytes
import gradio as gr
from inference import main
import tempfile
from moviepy.editor import VideoFileClip
def remove_audio_then_infer(video_path):
# Load video and remove audio
clip = VideoFileClip(video_path)
clip_no_audio = clip.without_audio()
# Save to a temporary file
temp_video = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False)
clip_no_audio.write_videofile(temp_video.name, codec="libx264", audio=False, logger=None)
# Run your main inference
return main(temp_video.name)
iface = gr.Interface(
fn=remove_audio_then_infer,
inputs=gr.Video(label="Upload Cricket Video"),
outputs=gr.Video(label="Generated Commentary Video"),
title="Cricket Commentary Generator",
description="Upload a cricket video to generate AI-powered commentary with ambient sound."
)
iface.launch(debug=True, share=True)