| import gradio as gr |
| import ffmpeg |
|
|
| def convert_to_mp3(file): |
| input_file = file.name |
| output_file = "output.mp3" |
| |
| |
| try: |
| ffmpeg.input(input_file).output(output_file).run(overwrite_output=True) |
| except FileNotFoundError as e: |
| return str(e) |
| |
| return output_file |
|
|
| app = gr.Interface( |
| fn=convert_to_mp3, |
| inputs=gr.File(label="Upload Audio/Video File"), |
| outputs=gr.File(label="Download MP3 File"), |
| title="Convert Audio/Video to MP3", |
| description="Upload an audio or video file and convert its audio to MP3 format." |
| ) |
|
|
| app.launch() |
|
|