Rejekts commited on
Commit
ed6a17b
1 Parent(s): c5e2020

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
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 sorted(filepath):
25
  return os.listdir(filepath)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- with gr.Blocks(title="🔊",theme=gr.themes.Base(primary_hue="rose",neutral_hue="zinc")) as app:
28
  with gr.Row():
29
- weight = gr.Dropdown(choices=sorted('assets/weights'))
 
 
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()