Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,8 @@ os.environ['weight_root']="assets/weights"
|
|
9 |
from infer.modules.vc.modules import VC
|
10 |
from configs.config import Config
|
11 |
import torch
|
|
|
|
|
12 |
os.makedirs(os.path.join(".", "audios"), exist_ok=True)
|
13 |
config = Config()
|
14 |
vc = VC(config)
|
@@ -17,6 +19,21 @@ def warn(text):
|
|
17 |
try: gr.Warning(text)
|
18 |
except: pass
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
def load_model(model_picker,index_picker):
|
21 |
logs = show_available("logs")
|
22 |
if model_picker.replace(".pth","") in logs:
|
@@ -252,6 +269,13 @@ with gr.Blocks() as app:
|
|
252 |
model_picker = gr.Dropdown(label="Model: ",choices=show_available('assets/weights','.pth'),value=show_available('assets/weights','.pth')[0],interactive=True,allow_custom_value=True)
|
253 |
index_picker = gr.Dropdown(label="Index:",interactive=True,choices=show_available('logs'),value=show_available('logs')[0],allow_custom_value=True)
|
254 |
model_picker.change(fn=load_model,inputs=[model_picker,index_picker],outputs=[index_picker])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
with gr.TabItem("(Or download a model here)"):
|
256 |
with gr.Row():
|
257 |
url = gr.Textbox(label="Paste the URL here:",value="",placeholder="(i.e. https://huggingface.co/repo/model/resolve/main/model.zip)")
|
@@ -268,7 +292,7 @@ with gr.Blocks() as app:
|
|
268 |
with gr.TabItem("Advanced"):
|
269 |
index_rate = gr.Slider(label='Index Rate: ',minimum=0,maximum=1,value=0.66,step=0.01)
|
270 |
pitch = gr.Slider(label='Pitch (-12 lowers it an octave, 0 keeps the original pitch, 12 lifts it an octave): ',minimum =-12, maximum=12, step=1, value=0, interactive=True)
|
271 |
-
method = gr.Dropdown(label="Method:",choices=["rmvpe","pm"],value="rmvpe")
|
272 |
|
273 |
with gr.Row():
|
274 |
with gr.Tabs():
|
|
|
9 |
from infer.modules.vc.modules import VC
|
10 |
from configs.config import Config
|
11 |
import torch
|
12 |
+
import yt_dlp
|
13 |
+
import ffmpeg
|
14 |
os.makedirs(os.path.join(".", "audios"), exist_ok=True)
|
15 |
config = Config()
|
16 |
vc = VC(config)
|
|
|
19 |
try: gr.Warning(text)
|
20 |
except: pass
|
21 |
|
22 |
+
|
23 |
+
def download_audio(url, audio_name):
|
24 |
+
ydl_opts = {
|
25 |
+
'format': 'bestaudio/best',
|
26 |
+
'postprocessors': [{
|
27 |
+
'key': 'FFmpegExtractAudio',
|
28 |
+
'preferredcodec': 'wav',
|
29 |
+
'preferredquality': '192',
|
30 |
+
}],
|
31 |
+
'outtmpl': 'audios/{audio_name}.%(ext)s',
|
32 |
+
}
|
33 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
34 |
+
ydl.download([url])
|
35 |
+
return "audio downloaded as '{audio_name}.wav'"
|
36 |
+
|
37 |
def load_model(model_picker,index_picker):
|
38 |
logs = show_available("logs")
|
39 |
if model_picker.replace(".pth","") in logs:
|
|
|
269 |
model_picker = gr.Dropdown(label="Model: ",choices=show_available('assets/weights','.pth'),value=show_available('assets/weights','.pth')[0],interactive=True,allow_custom_value=True)
|
270 |
index_picker = gr.Dropdown(label="Index:",interactive=True,choices=show_available('logs'),value=show_available('logs')[0],allow_custom_value=True)
|
271 |
model_picker.change(fn=load_model,inputs=[model_picker,index_picker],outputs=[index_picker])
|
272 |
+
with gr.Tabs():
|
273 |
+
with gr.TabItem("2.download youtube wav:"):
|
274 |
+
url = gr.Textbox(label="url youtube")
|
275 |
+
audio_name = gr.Textbox(label="name audio")
|
276 |
+
output_audio = gr.Audio(label="output audio")
|
277 |
+
dwnl_button = gr.Button("Download")
|
278 |
+
dwnl_button.click(fn=download_audio,inputs=[url,audio_name],outputs=[output_audio])
|
279 |
with gr.TabItem("(Or download a model here)"):
|
280 |
with gr.Row():
|
281 |
url = gr.Textbox(label="Paste the URL here:",value="",placeholder="(i.e. https://huggingface.co/repo/model/resolve/main/model.zip)")
|
|
|
292 |
with gr.TabItem("Advanced"):
|
293 |
index_rate = gr.Slider(label='Index Rate: ',minimum=0,maximum=1,value=0.66,step=0.01)
|
294 |
pitch = gr.Slider(label='Pitch (-12 lowers it an octave, 0 keeps the original pitch, 12 lifts it an octave): ',minimum =-12, maximum=12, step=1, value=0, interactive=True)
|
295 |
+
method = gr.Dropdown(label="Method:",choices=["rmvpe","crepe", "pm"],value="rmvpe")
|
296 |
|
297 |
with gr.Row():
|
298 |
with gr.Tabs():
|