Spaces:
Running
Running
Update src/covergen.py
Browse files- src/covergen.py +60 -2
src/covergen.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
import os, sys
|
2 |
import gradio as gr
|
3 |
-
|
4 |
from main import song_cover_pipeline
|
5 |
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 |
# Setup directories
|
11 |
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
12 |
rvc_models_dir = os.path.join(BASE_DIR, 'rvc_models')
|
@@ -18,6 +21,42 @@ warning = True if warning == 'True' else False
|
|
18 |
# Initialize voice models
|
19 |
voice_models = ignore_files(rvc_models_dir)
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
# Define the Gradio interface
|
22 |
with gr.Blocks(title="π€ RVC Inference", css="footer{display:none !important}") as app:
|
23 |
|
@@ -40,7 +79,7 @@ with gr.Blocks(title="π€ RVC Inference", css="footer{display:none !important}"
|
|
40 |
with gr.Tab("πΆ Voice Conversion"):
|
41 |
|
42 |
with gr.Column():
|
43 |
-
audio_input = gr.Audio(label='π΅ Upload Audio', interactive=True)
|
44 |
|
45 |
with gr.Accordion('βοΈ Voice Conversion Settings', open=False):
|
46 |
use_hybrid_methods = gr.Checkbox(label="𧬠Use Hybrid Methods", value=False)
|
@@ -62,6 +101,25 @@ with gr.Blocks(title="π€ RVC Inference", css="footer{display:none !important}"
|
|
62 |
refresh_btn.click(update_models_list, None, outputs=rvc_model)
|
63 |
generate_btn.click(song_cover_pipeline, inputs=[audio_input, rvc_model, pitch, f0_method, crepe_hop_length, index_rate, filter_radius, rms_mix_rate, protect, output_format], outputs=[converted_audio])
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
# Merge/Process Tab
|
66 |
with gr.Tab('π Merge/Process'):
|
67 |
with gr.Row():
|
|
|
1 |
import os, sys
|
2 |
import gradio as gr
|
3 |
+
from audio_separator.separator import Separator
|
4 |
from main import song_cover_pipeline
|
5 |
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 |
+
|
13 |
# Setup directories
|
14 |
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
15 |
rvc_models_dir = os.path.join(BASE_DIR, 'rvc_models')
|
|
|
21 |
# Initialize voice models
|
22 |
voice_models = ignore_files(rvc_models_dir)
|
23 |
|
24 |
+
|
25 |
+
|
26 |
+
UVR_5_MODELS = [
|
27 |
+
{"model_name": "BS-Roformer-Viperx-1297", "checkpoint": "model_bs_roformer_ep_317_sdr_12.9755.ckpt"},
|
28 |
+
{"model_name": "MDX23C-InstVoc HQ 2", "checkpoint": "MDX23C-8KFFT-InstVoc_HQ_2.ckpt"},
|
29 |
+
{"model_name": "Kim Vocal 2", "checkpoint": "Kim_Vocal_2.onnx"},
|
30 |
+
{"model_name": "5_HP-Karaoke", "checkpoint": "5_HP-Karaoke-UVR.pth"},
|
31 |
+
{"model_name": "UVR-DeNoise by FoxJoy", "checkpoint": "UVR-DeNoise.pth"},
|
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:
|
38 |
+
if model_info["model_name"] == model_name:
|
39 |
+
separator.load_model(model_info["checkpoint"])
|
40 |
+
model_found = True
|
41 |
+
break
|
42 |
+
if not model_found:
|
43 |
+
separator.load_model()
|
44 |
+
output_files = separator.separate(audio)
|
45 |
+
vocals = output_files[0]
|
46 |
+
inst = output_files[1]
|
47 |
+
return vocals, inst
|
48 |
+
|
49 |
+
|
50 |
+
def inference(audio, model_name):
|
51 |
+
output_data = inf_handler(audio, model_name)
|
52 |
+
vocals = output_data[0]
|
53 |
+
inst = output_data[1]
|
54 |
+
|
55 |
+
return vocals, inst
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
# Define the Gradio interface
|
61 |
with gr.Blocks(title="π€ RVC Inference", css="footer{display:none !important}") as app:
|
62 |
|
|
|
79 |
with gr.Tab("πΆ Voice Conversion"):
|
80 |
|
81 |
with gr.Column():
|
82 |
+
audio_input = gr.Audio(label='π΅ Upload Audio', interactive=True, type="filepath")
|
83 |
|
84 |
with gr.Accordion('βοΈ Voice Conversion Settings', open=False):
|
85 |
use_hybrid_methods = gr.Checkbox(label="𧬠Use Hybrid Methods", value=False)
|
|
|
101 |
refresh_btn.click(update_models_list, None, outputs=rvc_model)
|
102 |
generate_btn.click(song_cover_pipeline, inputs=[audio_input, rvc_model, pitch, f0_method, crepe_hop_length, index_rate, filter_radius, rms_mix_rate, protect, output_format], outputs=[converted_audio])
|
103 |
|
104 |
+
|
105 |
+
# UVR tab
|
106 |
+
|
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():
|
113 |
+
uvr5_model = gr.Dropdown(label="γ½οΈ Model", choices=[model["model_name"] for model in UVR_5_MODELS])
|
114 |
+
uvr5_button = gr.Button("π§ Separate Vocals", variant="primary",)
|
115 |
+
|
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 |
+
|
122 |
+
|
123 |
# Merge/Process Tab
|
124 |
with gr.Tab('π Merge/Process'):
|
125 |
with gr.Row():
|