Spaces:
Running
Running
Update src/covergen.py
Browse files- src/covergen.py +51 -1
src/covergen.py
CHANGED
@@ -6,7 +6,15 @@ from audio_effects import add_audio_effects
|
|
6 |
from modules.model_management import ignore_files, update_models_list, download_from_url, upload_zip_model, upload_separate_files
|
7 |
from modules.ui_updates import show_hop_slider, update_f0_method, update_button_text_voc, update_button_text_inst, swap_visibility, swap_buttons
|
8 |
from modules.file_processing import process_file_upload
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
separator = Separator()
|
12 |
|
@@ -32,6 +40,30 @@ UVR_5_MODELS = [
|
|
32 |
{"model_name": "UVR-DeEcho-DeReverb by FoxJoy", "checkpoint": "UVR-DeEcho-DeReverb.pth"},
|
33 |
]
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
def inf_handler(audio, model_name):
|
36 |
model_found = False
|
37 |
for model_info in UVR_5_MODELS:
|
@@ -107,6 +139,19 @@ with gr.Blocks(title="π€ RVC Inference", css="footer{display:none !important}"
|
|
107 |
|
108 |
with gr.Tab(" π§ Vocal Separator (UVR)"):
|
109 |
gr.Markdown("β Separate vocals and instruments from an audio file using UVR models.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
uvr5_audio_file = gr.Audio(label=" π² Audio File",type="filepath")
|
111 |
|
112 |
with gr.Row():
|
@@ -116,6 +161,11 @@ with gr.Blocks(title="π€ RVC Inference", css="footer{display:none !important}"
|
|
116 |
uvr5_output_voc = gr.Audio(type="filepath", label="Output 1",)
|
117 |
uvr5_output_inst = gr.Audio(type="filepath", label="Output 2",)
|
118 |
|
|
|
|
|
|
|
|
|
|
|
119 |
uvr5_button.click(inference, [uvr5_audio_file, uvr5_model], [uvr5_output_voc, uvr5_output_inst])
|
120 |
|
121 |
|
|
|
6 |
from modules.model_management import ignore_files, update_models_list, download_from_url, upload_zip_model, upload_separate_files
|
7 |
from modules.ui_updates import show_hop_slider, update_f0_method, update_button_text_voc, update_button_text_inst, swap_visibility, swap_buttons
|
8 |
from modules.file_processing import process_file_upload
|
9 |
+
import os
|
10 |
+
import re
|
11 |
+
import random
|
12 |
+
from scipy.io.wavfile import write
|
13 |
+
from scipy.io.wavfile import read
|
14 |
+
import numpy as np
|
15 |
+
import gradio as gr
|
16 |
+
import yt_dlp
|
17 |
+
import subprocess
|
18 |
|
19 |
separator = Separator()
|
20 |
|
|
|
40 |
{"model_name": "UVR-DeEcho-DeReverb by FoxJoy", "checkpoint": "UVR-DeEcho-DeReverb.pth"},
|
41 |
]
|
42 |
|
43 |
+
|
44 |
+
|
45 |
+
def download_audio(url):
|
46 |
+
ydl_opts = {
|
47 |
+
'format': 'bestaudio/best',
|
48 |
+
'outtmpl': 'ytdl/%(title)s.%(ext)s',
|
49 |
+
'postprocessors': [{
|
50 |
+
'key': 'FFmpegExtractAudio',
|
51 |
+
'preferredcodec': 'wav',
|
52 |
+
'preferredquality': '192',
|
53 |
+
}],
|
54 |
+
}
|
55 |
+
|
56 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
57 |
+
info_dict = ydl.extract_info(url, download=True)
|
58 |
+
file_path = ydl.prepare_filename(info_dict).rsplit('.', 1)[0] + '.wav'
|
59 |
+
sample_rate, audio_data = read(file_path)
|
60 |
+
audio_array = np.asarray(audio_data, dtype=np.int16)
|
61 |
+
|
62 |
+
return sample_rate, audio_array
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
def inf_handler(audio, model_name):
|
68 |
model_found = False
|
69 |
for model_info in UVR_5_MODELS:
|
|
|
139 |
|
140 |
with gr.Tab(" π§ Vocal Separator (UVR)"):
|
141 |
gr.Markdown("β Separate vocals and instruments from an audio file using UVR models.")
|
142 |
+
|
143 |
+
|
144 |
+
with gr.Accordion("π Separation by Link", open=False):
|
145 |
+
with gr.Row():
|
146 |
+
mdx23c_link = gr.Textbox(label="π Link",placeholder="π Paste the link here",interactive=True)
|
147 |
+
with gr.Row():
|
148 |
+
gr.Markdown("π‘ You can paste the link to the video/audio from many sites, check the complete list [here](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md)")
|
149 |
+
with gr.Row():
|
150 |
+
mdx23c_download_button = gr.Button("β¬οΈ Download!",variant="primary")
|
151 |
+
|
152 |
+
|
153 |
+
|
154 |
+
|
155 |
uvr5_audio_file = gr.Audio(label=" π² Audio File",type="filepath")
|
156 |
|
157 |
with gr.Row():
|
|
|
161 |
uvr5_output_voc = gr.Audio(type="filepath", label="Output 1",)
|
162 |
uvr5_output_inst = gr.Audio(type="filepath", label="Output 2",)
|
163 |
|
164 |
+
|
165 |
+
|
166 |
+
|
167 |
+
mdx23c_download_button.click(download_audio, [mdx23c_link], [uvr5_audio_file])
|
168 |
+
|
169 |
uvr5_button.click(inference, [uvr5_audio_file, uvr5_model], [uvr5_output_voc, uvr5_output_inst])
|
170 |
|
171 |
|