Spaces:
Running
Running
lazarusking
commited on
Commit
•
c0b6376
0
Parent(s):
v1
Browse files- .gitignore +1 -0
- app.py +46 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
flagged
|
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import logging
|
2 |
+
import os
|
3 |
+
import subprocess
|
4 |
+
from tempfile import _TemporaryFileWrapper
|
5 |
+
|
6 |
+
from ffmpy import FFmpeg
|
7 |
+
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
logging.basicConfig(level=logging.INFO)
|
11 |
+
|
12 |
+
def convert(file:_TemporaryFileWrapper,options:list,):
|
13 |
+
logging.info(f"Current working path :{os.getcwd()}")
|
14 |
+
logging.info(f"File name: {file.name}")
|
15 |
+
# options.append(["Boy","Girl"])
|
16 |
+
new_name,_=file.name.split(".")
|
17 |
+
logging.info(f"New filename:{new_name}")
|
18 |
+
cm=["ffmpeg","-y","-i",file.name,f"{new_name}.{options}"]
|
19 |
+
output_file=f"{new_name}.{options}"
|
20 |
+
ffmpeg=FFmpeg(inputs={file.name:None},outputs={output_file:None},global_options=["-y","-hide_banner"])
|
21 |
+
print(ffmpeg)
|
22 |
+
ffmpeg.run()
|
23 |
+
# subprocess.run(cm,text=True)
|
24 |
+
# gr.CheckboxGroup(choices=["Fast","HD"])
|
25 |
+
return [output_file,ffmpeg]
|
26 |
+
|
27 |
+
app=gr.Interface(fn=convert,inputs=[gr.File(),gr.Radio(choices=["mp3","ogg","flac","wav"])],outputs=[gr.Audio(),"text"],flagging_dir="flagged")
|
28 |
+
app.launch(server_port=3000)
|
29 |
+
# cm=["ffmpeg","-i","/home/accel/Documents/Denouement.ogg","/home/accel/Documents/Denouement.mp3"]
|
30 |
+
|
31 |
+
# subprocess.run(cm,text=True)
|
32 |
+
# dm=gr.Blocks()
|
33 |
+
# with dm:
|
34 |
+
# gr.Markdown("Something")
|
35 |
+
# with gr.Tabs():
|
36 |
+
# with gr.TabItem("A tab"):
|
37 |
+
# text_input=gr.Textbox()
|
38 |
+
# text_output=gr.Textbox()
|
39 |
+
# text_button=gr.Button("Action")
|
40 |
+
# with gr.TabItem("Second tab"):
|
41 |
+
# with gr.Row():
|
42 |
+
# txt_input=gr.Textbox()
|
43 |
+
# txt_output=gr.Textbox()
|
44 |
+
# txt_button=gr.Button("Play")
|
45 |
+
# text_button.click(hello,inputs=text_input,outputs=text_output)
|
46 |
+
# dm.launch()
|