Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
import os
|
3 |
|
4 |
import subprocess, os
|
5 |
assets_folder = "assets"
|
@@ -21,11 +21,27 @@ for file, link in files.items():
|
|
21 |
except subprocess.CalledProcessError as e:
|
22 |
print(f"Error downloading {file}: {e}")
|
23 |
|
24 |
-
def
|
25 |
return os.listdir(filepath)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
with gr.Blocks(
|
28 |
with gr.Row():
|
29 |
-
|
|
|
|
|
30 |
|
31 |
-
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import os, shutil
|
3 |
|
4 |
import subprocess, os
|
5 |
assets_folder = "assets"
|
|
|
21 |
except subprocess.CalledProcessError as e:
|
22 |
print(f"Error downloading {file}: {e}")
|
23 |
|
24 |
+
def show_available(filepath):
|
25 |
return os.listdir(filepath)
|
26 |
+
|
27 |
+
def upload_file(file):
|
28 |
+
audio_formats = ['.wav', '.mp3', '.ogg', '.flac', '.aac']
|
29 |
+
file_name, file_extension = os.path.splitext(file.name)
|
30 |
+
if file_extension.lower() in audio_formats:
|
31 |
+
shutil.move(file.name,'audios')
|
32 |
+
return show_available('audios')
|
33 |
+
elif file_extension.lower().endswith('.pth'):
|
34 |
+
shutil.move(file.name,'assets/weights')
|
35 |
+
elif file_extension.lower().endswith('.index'):
|
36 |
+
shutil.move(file.name,'logs')
|
37 |
+
else:
|
38 |
+
print("Filetype not compatible")
|
39 |
+
return {"choices":show_available('audios'),"__type__": "update"}
|
40 |
|
41 |
+
with gr.Blocks() as app:
|
42 |
with gr.Row():
|
43 |
+
dropbox = gr.Dropbox(label="Upload files")
|
44 |
+
audio_picker= gr.Dropdown(label="",choices=show_available('audios'))
|
45 |
+
dropbox.upload(fn=upload_file, inputs=['dropbox'],outputs=['audio_picker'])
|
46 |
|
47 |
+
app.launch()
|