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)