Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import ffmpeg
|
| 3 |
-
import tempfile
|
| 4 |
-
import os
|
| 5 |
|
| 6 |
def convert_to_mp3(file):
|
| 7 |
input_file = file.name
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
# Return the path to the output file
|
| 19 |
-
return output_file
|
| 20 |
|
| 21 |
app = gr.Interface(
|
| 22 |
fn=convert_to_mp3,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import ffmpeg
|
|
|
|
|
|
|
| 3 |
|
| 4 |
def convert_to_mp3(file):
|
| 5 |
input_file = file.name
|
| 6 |
+
output_file = "output.mp3"
|
| 7 |
+
|
| 8 |
+
# Use ffmpeg to extract audio and convert it to mp3
|
| 9 |
+
try:
|
| 10 |
+
ffmpeg.input(input_file).output(output_file).run(overwrite_output=True)
|
| 11 |
+
except FileNotFoundError as e:
|
| 12 |
+
return str(e)
|
| 13 |
+
|
| 14 |
+
return output_file
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
app = gr.Interface(
|
| 17 |
fn=convert_to_mp3,
|