Spaces:
Running
Running
File size: 4,834 Bytes
5f76498 e976963 6718e39 e976963 6718e39 e976963 6718e39 085162d 6718e39 5f76498 085162d 6718e39 085162d 6718e39 d105998 6718e39 085162d 6718e39 d105998 67df0e3 6718e39 e976963 6718e39 2644ffe 6718e39 4b79e01 6718e39 d105998 6718e39 |
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
import os, sys
import gradio as gr
from main import song_cover_pipeline
from audio_effects import add_audio_effects
from modules.model_management import ignore_files, update_models_list, download_from_url, upload_zip_model, upload_separate_files
from modules.ui_updates import show_hop_slider, update_f0_method, update_button_text_voc, update_button_text_inst, swap_visibility, swap_buttons
from modules.file_processing import process_file_upload
# Setup directories
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
rvc_models_dir = os.path.join(BASE_DIR, 'rvc_models')
# Check for warnings
warning = sys.argv[1] if len(sys.argv) > 1 else 'False'
warning = True if warning == 'True' else False
# Initialize voice models
voice_models = ignore_files(rvc_models_dir)
# Define the Gradio interface
with gr.Blocks(title="π€ RVC Inference", css="footer{display:none !important}") as app:
# Show warning message if applicable
if warning:
gr.HTML("<center><h2>β οΈ This space is running slowly due to limited resources. Use the faster <a href='https://colab.research.google.com/drive/1HzuPgICRrjqUWQWb5Zn-l07m099-n-Nr'>Google Colab Notebook</a>.</h2></center>")
# Main Tab: Voice Conversion
with gr.Row():
rvc_model = gr.Dropdown(voice_models, label='ποΈ Voice Models')
output_format = gr.Dropdown(['mp3', 'flac', 'wav'], value='mp3', label='π§ Output Format')
pitch = gr.Slider(-12, 12, value=0, step=1, label='ποΈ Pitch Adjustment', info='-12 for deeper voice, +12 for higher voice')
with gr.Row():
generate_btn = gr.Button("πΌ Generate", variant="primary")
refresh_btn = gr.Button('π Refresh Models')
with gr.Tab("πΆ Voice Conversion"):
with gr.Column():
audio_input = gr.Audio(label='π΅ Upload Audio', interactive=True)
with gr.Accordion('βοΈ Voice Conversion Settings', open=False):
use_hybrid_methods = gr.Checkbox(label="𧬠Use Hybrid Methods", value=False)
f0_method = gr.Dropdown(['rmvpe+', 'fcpe', 'rmvpe', 'mangio-crepe', 'crepe'], value='rmvpe+', label='π§ F0 Method')
use_hybrid_methods.change(update_f0_method, inputs=use_hybrid_methods, outputs=f0_method)
crepe_hop_length = gr.Slider(8, 512, value=128, step=8, label='ποΈ Crepe Hop Length')
f0_method.change(show_hop_slider, inputs=f0_method, outputs=crepe_hop_length)
converted_audio = gr.Audio(label='πΆ Converted Voice')
refresh_btn.click(update_models_list, None, outputs=rvc_model)
generate_btn.click(song_cover_pipeline, inputs=[audio_input, rvc_model, pitch, f0_method, crepe_hop_length, output_format], outputs=[converted_audio])
# Merge/Process Tab
with gr.Tab('π Merge/Process'):
with gr.Row():
vocal_input = gr.Audio(label='π€ Vocals', interactive=True)
instrumental_input = gr.Audio(label='πΉ Instrumental', interactive=True)
with gr.Row():
process_btn = gr.Button("π¬ Process")
ai_cover_output = gr.Audio(label='π§ AI Cover')
process_btn.click(add_audio_effects, inputs=[vocal_input, instrumental_input], outputs=[ai_cover_output])
# Model Options Tab
with gr.Tab('π¦ Model Options'):
with gr.Tab('π Download Models'):
model_zip_link = gr.Text(label='π Enter Model Download Link')
model_name = gr.Text(label='π Model Name')
download_btn = gr.Button('β¬οΈ Download Model')
dl_output_message = gr.Text(label='π’ Output Message')
download_btn.click(download_from_url, inputs=[model_zip_link, model_name], outputs=dl_output_message)
with gr.Tab('π€ Upload ZIP Models'):
zip_file = gr.File(label='π Upload ZIP File', file_types=['.zip'])
zip_model_name = gr.Text(label='π Model Name')
upload_btn = gr.Button('π€ Upload Model')
upload_output_message = gr.Text(label='π’ Upload Status')
upload_btn.click(upload_zip_model, inputs=[zip_file, zip_model_name], outputs=upload_output_message)
with gr.Tab('π€ Upload Separate Files'):
pth_file = gr.File(label='π Upload .pth File', file_types=['.pth'])
index_file = gr.File(label='π Upload .index File', file_types=['.index'])
sep_model_name = gr.Text(label='π Model Name')
separate_upload_btn = gr.Button('π€ Upload Files')
separate_upload_output = gr.Text(label='π’ Upload Status')
separate_upload_btn.click(upload_separate_files, inputs=[pth_file, index_file, sep_model_name], outputs=separate_upload_output)
app.launch(share=True)
|