Download app.py from XPMaster/converter: direct link, hf CLI and curl.
- Browser
- Download file 640 Bytes
-
https://huggingface.co/spaces/XPMaster/converter/resolve/main/app.py
- Command line
-
hf download hf://spaces/XPMaster/converter/app.py
-
curl -L -o app.py https://huggingface.co/spaces/XPMaster/converter/resolve/main/app.py
640 Bytes
| import gradio as gr | |
| import ffmpeg | |
| def convert_to_mp3(file): | |
| input_file = file.name | |
| output_file = "output.mp3" | |
| # Use ffmpeg to extract audio and convert it to 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() | |