Update app.py
Browse files
app.py
CHANGED
@@ -92,9 +92,11 @@ def download_audio(url):
|
|
92 |
|
93 |
|
94 |
|
95 |
-
|
|
|
96 |
def separate_audio(input_audio, model_voc_inst, model_deecho, model_back_voc):
|
97 |
-
output_dir = audio_separat_dir
|
|
|
98 |
separator = Separator(output_dir=output_dir)
|
99 |
|
100 |
# Define output files
|
@@ -123,7 +125,18 @@ def separate_audio(input_audio, model_voc_inst, model_deecho, model_back_voc):
|
|
123 |
os.rename(os.path.join(output_dir, backing_voc[0]), backing_vocals) # Rename to “Backing Vocals.wav”
|
124 |
os.rename(os.path.join(output_dir, backing_voc[1]), lead_vocals) # Rename to “Lead Vocals.wav”
|
125 |
|
126 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
# Main function to process audio (Inference)
|
129 |
def process_audio(MODEL_NAME, SOUND_PATH, F0_CHANGE, F0_METHOD, MIN_PITCH, MAX_PITCH, CREPE_HOP_LENGTH, INDEX_RATE,
|
@@ -282,6 +295,7 @@ with gr.Blocks(title="Hex RVC", theme=gr.themes.Base(primary_hue="red", secondar
|
|
282 |
with gr.Row():
|
283 |
input_audio = gr.Audio(type="filepath", label="Upload Audio File")
|
284 |
|
|
|
285 |
with gr.Row():
|
286 |
with gr.Accordion("Separation by Link", open = False):
|
287 |
with gr.Row():
|
@@ -305,16 +319,16 @@ with gr.Blocks(title="Hex RVC", theme=gr.themes.Base(primary_hue="red", secondar
|
|
305 |
model_deecho = gr.Textbox(value='UVR-DeEcho-DeReverb.pth', label="DeEcho-DeReverb Model", visible=False)
|
306 |
model_back_voc = gr.Textbox(value='mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt', label="Backing Vocals Model", visible=False)
|
307 |
|
308 |
-
|
309 |
-
|
310 |
with gr.Row():
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
|
319 |
|
320 |
# Launch the Gradio app
|
|
|
92 |
|
93 |
|
94 |
|
95 |
+
|
96 |
+
# Define the audio separation function
|
97 |
def separate_audio(input_audio, model_voc_inst, model_deecho, model_back_voc):
|
98 |
+
output_dir = audio_separat_dir
|
99 |
+
os.makedirs(output_dir, exist_ok=True)
|
100 |
separator = Separator(output_dir=output_dir)
|
101 |
|
102 |
# Define output files
|
|
|
125 |
os.rename(os.path.join(output_dir, backing_voc[0]), backing_vocals) # Rename to “Backing Vocals.wav”
|
126 |
os.rename(os.path.join(output_dir, backing_voc[1]), lead_vocals) # Rename to “Lead Vocals.wav”
|
127 |
|
128 |
+
return [
|
129 |
+
instrumental, vocals, vocals_no_reverb, vocals_reverb, lead_vocals, backing_vocals
|
130 |
+
]
|
131 |
+
|
132 |
+
# Gradio Interface
|
133 |
+
def gradio_interface(input_audio, model_voc_inst, model_deecho, model_back_voc):
|
134 |
+
# Separate audio and get paths to output files
|
135 |
+
results = separate_audio(input_audio, model_voc_inst, model_deecho, model_back_voc)
|
136 |
+
|
137 |
+
# Convert file paths to Gradio downloadable links
|
138 |
+
return [gr.File(file) for file in results]
|
139 |
+
|
140 |
|
141 |
# Main function to process audio (Inference)
|
142 |
def process_audio(MODEL_NAME, SOUND_PATH, F0_CHANGE, F0_METHOD, MIN_PITCH, MAX_PITCH, CREPE_HOP_LENGTH, INDEX_RATE,
|
|
|
295 |
with gr.Row():
|
296 |
input_audio = gr.Audio(type="filepath", label="Upload Audio File")
|
297 |
|
298 |
+
|
299 |
with gr.Row():
|
300 |
with gr.Accordion("Separation by Link", open = False):
|
301 |
with gr.Row():
|
|
|
319 |
model_deecho = gr.Textbox(value='UVR-DeEcho-DeReverb.pth', label="DeEcho-DeReverb Model", visible=False)
|
320 |
model_back_voc = gr.Textbox(value='mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt', label="Backing Vocals Model", visible=False)
|
321 |
|
322 |
+
submit_button = gr.Button("Separate Audio")
|
323 |
+
|
324 |
with gr.Row():
|
325 |
+
output_files = gr.File(label="Download Separated Files", multiple=True)
|
326 |
+
|
327 |
+
submit_button.click(
|
328 |
+
fn=gradio_interface,
|
329 |
+
inputs=[input_audio, model_voc_inst, model_deecho, model_back_voc],
|
330 |
+
outputs=output_files
|
331 |
+
)
|
332 |
|
333 |
|
334 |
# Launch the Gradio app
|