import gradio as gr import ffmpeg import os def extract_audio_from_video(video, start_time, end_time, use_time_cutting): if not video: raise gr.Error("No video file selected") input_file = video output_file = "media/extracted_audio.mp3" os.makedirs(os.path.dirname(output_file), exist_ok=True) if os.path.exists(output_file): os.remove(output_file) if use_time_cutting: ffmpeg.input(input_file, ss=start_time, to=end_time).output( output_file, format="mp3" ).run(overwrite_output=True) else: ffmpeg.input(input_file).output(output_file, format="mp3").run( overwrite_output=True ) return output_file with gr.Blocks() as demo: gr.Markdown("