Spaces:
Runtime error
Runtime error
File size: 1,929 Bytes
643df07 ed6a17b 20765d0 fc254f0 c5e2020 fc254f0 c5e2020 ed6a17b d414b06 ed6a17b 643df07 ed6a17b 6a6e875 fc254f0 ae1ca35 09b1fb5 643df07 ed6a17b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import gradio as gr
import os, shutil
'''import subprocess, os
assets_folder = "assets"
if not os.path.exists(assets_folder):
os.makedirs(assets_folder)
files = {
"rmvpe/rmvpe.pt":"https://huggingface.co/Rejekts/project/resolve/main/rmvpe.pt",
"hubert/hubert_base.pt":"https://huggingface.co/Rejekts/project/resolve/main/hubert_base.pt",
"pretrained_v2/D40k.pth":"https://huggingface.co/Rejekts/project/resolve/main/D40k.pth",
"pretrained_v2/G40k.pth":"https://huggingface.co/Rejekts/project/resolve/main/G40k.pth",
"pretrained_v2/f0D40k.pth":"https://huggingface.co/Rejekts/project/resolve/main/f0D40k.pth",
"pretrained_v2/f0G40k.pth":"https://huggingface.co/Rejekts/project/resolve/main/f0G40k.pth"
}
for file, link in files.items():
file_path = os.path.join(assets_folder, file)
if not os.path.exists(file_path):
try:
subprocess.run(['wget', link, '-O', file_path], check=True)
except subprocess.CalledProcessError as e:
print(f"Error downloading {file}: {e}")'''
def show_available(filepath):
return os.listdir(filepath)
def upload_file(file):
audio_formats = ['.wav', '.mp3', '.ogg', '.flac', '.aac']
file_name, file_extension = os.path.splitext(file.name)
if file_extension.lower() in audio_formats:
shutil.move(file.name,'audios')
elif file_extension.lower().endswith('.pth'):
shutil.move(file.name,'assets/weights')
elif file_extension.lower().endswith('.index'):
shutil.move(file.name,'logs')
else:
print("Filetype not compatible")
return {"choices":show_available('audios'),"__type__": "update"}
with gr.Blocks() as app:
with gr.Row():
dropbox = gr.File(label="Upload files")
audio_picker = gr.Dropdown(label="",choices=show_available('audios'))
dropbox.upload(fn=upload_file, inputs=[dropbox],outputs=[audio_picker])
app.launch() |