Update app.py
Browse files
app.py
CHANGED
|
@@ -95,48 +95,94 @@ if __name__ == '__main__':
|
|
| 95 |
|
| 96 |
# Gradio Interface
|
| 97 |
with gr.Blocks(title="Hex RVC", theme=gr.themes.Base(primary_hue="red", secondary_hue="pink")) as app:
|
| 98 |
-
gr.Markdown("# Hex RVC")
|
| 99 |
gr.Markdown("Join [AIHub](https://discord.gg/aihub) to get the RVC model!")
|
| 100 |
-
|
|
|
|
| 101 |
with gr.Tab("Inference"):
|
|
|
|
| 102 |
with gr.Row():
|
| 103 |
MODEL_NAME = gr.Dropdown(
|
| 104 |
-
label="Select
|
| 105 |
choices=get_folders(),
|
| 106 |
-
interactive=True
|
|
|
|
| 107 |
)
|
| 108 |
SOUND_PATH = gr.Dropdown(
|
| 109 |
choices=load_audio_files(),
|
| 110 |
-
label="Select
|
| 111 |
-
interactive=True
|
|
|
|
| 112 |
)
|
| 113 |
-
upload_audio = gr.Audio(
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
language = gr.Dropdown(choices=list(language_dict.keys()), label="Choose the Voice Model")
|
| 118 |
-
tts_convert = gr.Button("Convert")
|
| 119 |
-
tts_output = gr.Audio(label="Generated TTS Audio", type='filepath')
|
| 120 |
-
|
| 121 |
-
tts_convert.click(
|
| 122 |
-
fn=text_to_speech_edge,
|
| 123 |
-
inputs=[input_text, language],
|
| 124 |
-
outputs=tts_output
|
| 125 |
)
|
| 126 |
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
with gr.Row():
|
| 129 |
-
refresh_btn = gr.Button("Refresh")
|
| 130 |
-
run_button = gr.Button("
|
| 131 |
|
|
|
|
| 132 |
refresh_btn.click(
|
| 133 |
lambda: (refresh_audio_list(), refresh_folders()),
|
| 134 |
outputs=[SOUND_PATH, MODEL_NAME]
|
| 135 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
|
|
|
| 137 |
with gr.Tab("Download RVC Model"):
|
| 138 |
-
|
| 139 |
-
|
|
|
|
| 140 |
download_button = gr.Button("Download Model")
|
| 141 |
download_output = gr.Textbox(label="Download Status")
|
| 142 |
|
|
@@ -147,17 +193,36 @@ with gr.Blocks(title="Hex RVC", theme=gr.themes.Base(primary_hue="red", secondar
|
|
| 147 |
)
|
| 148 |
|
| 149 |
with gr.Tab("Audio Separation"):
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
app.launch(
|
| 160 |
share=args.share_enabled,
|
| 161 |
server_name=None if not args.listen else (args.listen_host or '0.0.0.0'),
|
| 162 |
-
server_port=args.listen_port
|
| 163 |
)
|
|
|
|
| 95 |
|
| 96 |
# Gradio Interface
|
| 97 |
with gr.Blocks(title="Hex RVC", theme=gr.themes.Base(primary_hue="red", secondary_hue="pink")) as app:
|
| 98 |
+
gr.Markdown("# Hex RVC - AI Audio Inference")
|
| 99 |
gr.Markdown("Join [AIHub](https://discord.gg/aihub) to get the RVC model!")
|
| 100 |
+
|
| 101 |
+
# Inference Tab with Priority on Settings
|
| 102 |
with gr.Tab("Inference"):
|
| 103 |
+
gr.Markdown("## Inference Settings")
|
| 104 |
with gr.Row():
|
| 105 |
MODEL_NAME = gr.Dropdown(
|
| 106 |
+
label="Select AI Model",
|
| 107 |
choices=get_folders(),
|
| 108 |
+
interactive=True,
|
| 109 |
+
info="Choose a pre-trained model for audio processing"
|
| 110 |
)
|
| 111 |
SOUND_PATH = gr.Dropdown(
|
| 112 |
choices=load_audio_files(),
|
| 113 |
+
label="Select Existing Audio File",
|
| 114 |
+
interactive=True,
|
| 115 |
+
info="Pick an audio file from the predefined directory"
|
| 116 |
)
|
| 117 |
+
upload_audio = gr.Audio(
|
| 118 |
+
label="Upload Your Own Audio",
|
| 119 |
+
type='filepath',
|
| 120 |
+
info="Upload an audio file if not using existing ones"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
)
|
| 122 |
|
| 123 |
+
gr.Markdown("### Conversion Parameters")
|
| 124 |
+
with gr.Accordion("Conversion Settings", open=True):
|
| 125 |
+
with gr.Row():
|
| 126 |
+
F0_CHANGE = gr.Number(
|
| 127 |
+
label="Pitch Change (semitones)",
|
| 128 |
+
value=0,
|
| 129 |
+
info="Adjust the pitch of the output audio"
|
| 130 |
+
)
|
| 131 |
+
F0_METHOD = gr.Dropdown(
|
| 132 |
+
choices=["crepe", "harvest", "mangio-crepe", "rmvpe", "rmvpe_legacy", "fcpe", "fcpe_legacy", "hybrid[rmvpe+fcpe]"],
|
| 133 |
+
label="F0 Method",
|
| 134 |
+
value="fcpe",
|
| 135 |
+
info="Select the fundamental frequency extraction method"
|
| 136 |
+
)
|
| 137 |
+
with gr.Row():
|
| 138 |
+
MIN_PITCH = gr.Number(label="Min Pitch", value=50, info="Minimum pitch detection threshold")
|
| 139 |
+
MAX_PITCH = gr.Number(label="Max Pitch", value=1100, info="Maximum pitch detection threshold")
|
| 140 |
+
CREPE_HOP_LENGTH = gr.Number(label="Crepe Hop Length", value=120, info="Hop length for Crepe method")
|
| 141 |
+
INDEX_RATE = gr.Slider(label="Index Rate", minimum=0, maximum=1, value=0.75)
|
| 142 |
+
FILTER_RADIUS = gr.Number(label="Filter Radius", value=3, info="Filter intensity for smoothing")
|
| 143 |
+
RMS_MIX_RATE = gr.Slider(label="RMS Mix Rate", minimum=0, maximum=1, value=0.25)
|
| 144 |
+
PROTECT = gr.Slider(label="Protect Factor", minimum=0, maximum=1, value=0.33)
|
| 145 |
+
|
| 146 |
+
gr.Markdown("### Advanced Settings")
|
| 147 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 148 |
+
SPLIT_INFER = gr.Checkbox(label="Enable Split Inference", value=False)
|
| 149 |
+
MIN_SILENCE = gr.Number(label="Min Silence (ms)", value=500)
|
| 150 |
+
SILENCE_THRESHOLD = gr.Number(label="Silence Threshold (dBFS)", value=-50)
|
| 151 |
+
SEEK_STEP = gr.Slider(label="Seek Step (ms)", minimum=1, maximum=10, value=1)
|
| 152 |
+
KEEP_SILENCE = gr.Number(label="Keep Silence (ms)", value=200)
|
| 153 |
+
FORMANT_SHIFT = gr.Checkbox(label="Enable Formant Shift", value=False)
|
| 154 |
+
QUEFRENCY = gr.Number(label="Quefrency", value=0)
|
| 155 |
+
TIMBRE = gr.Number(label="Timbre", value=1)
|
| 156 |
+
F0_AUTOTUNE = gr.Checkbox(label="Enable F0 Autotune", value=False)
|
| 157 |
+
OUTPUT_FORMAT = gr.Dropdown(choices=["wav", "flac", "mp3"], label="Output Format", value="wav")
|
| 158 |
+
|
| 159 |
+
gr.Markdown("## Generate Audio")
|
| 160 |
+
output_audio = gr.Audio(label="Generated Audio Output", type='filepath')
|
| 161 |
+
|
| 162 |
with gr.Row():
|
| 163 |
+
refresh_btn = gr.Button("Refresh Lists")
|
| 164 |
+
run_button = gr.Button("Run Inference")
|
| 165 |
|
| 166 |
+
# Refresh Button for Updating Model and Audio Choices
|
| 167 |
refresh_btn.click(
|
| 168 |
lambda: (refresh_audio_list(), refresh_folders()),
|
| 169 |
outputs=[SOUND_PATH, MODEL_NAME]
|
| 170 |
)
|
| 171 |
+
|
| 172 |
+
# Run Inference and Display Result
|
| 173 |
+
run_button.click(
|
| 174 |
+
fn=process_audio,
|
| 175 |
+
inputs=[MODEL_NAME, SOUND_PATH, F0_CHANGE, F0_METHOD, MIN_PITCH, MAX_PITCH, CREPE_HOP_LENGTH, INDEX_RATE,
|
| 176 |
+
FILTER_RADIUS, RMS_MIX_RATE, PROTECT, SPLIT_INFER, MIN_SILENCE, SILENCE_THRESHOLD, SEEK_STEP,
|
| 177 |
+
KEEP_SILENCE, FORMANT_SHIFT, QUEFRENCY, TIMBRE, F0_AUTOTUNE, OUTPUT_FORMAT, upload_audio],
|
| 178 |
+
outputs=output_audio
|
| 179 |
+
)
|
| 180 |
|
| 181 |
+
# Other Tabs (Download Model, Audio Separation)
|
| 182 |
with gr.Tab("Download RVC Model"):
|
| 183 |
+
gr.Markdown("## Download RVC Model")
|
| 184 |
+
url = gr.Textbox(label="Model URL")
|
| 185 |
+
dirname = gr.Textbox(label="Model Directory Name")
|
| 186 |
download_button = gr.Button("Download Model")
|
| 187 |
download_output = gr.Textbox(label="Download Status")
|
| 188 |
|
|
|
|
| 193 |
)
|
| 194 |
|
| 195 |
with gr.Tab("Audio Separation"):
|
| 196 |
+
gr.Markdown("## Audio Separation")
|
| 197 |
+
input_audio = gr.Audio(type="filepath", label="Upload Audio for Separation")
|
| 198 |
+
with gr.Accordion("Separation by Link", open = False):
|
| 199 |
+
with gr.Row():
|
| 200 |
+
roformer_link = gr.Textbox(
|
| 201 |
+
label = "Link",
|
| 202 |
+
placeholder = "Paste the link here",
|
| 203 |
+
interactive = True
|
| 204 |
+
)
|
| 205 |
+
with gr.Row():
|
| 206 |
+
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)")
|
| 207 |
+
with gr.Row():
|
| 208 |
+
roformer_download_button = gr.Button(
|
| 209 |
+
"Download!",
|
| 210 |
+
variant = "primary"
|
| 211 |
+
)
|
| 212 |
+
separate_button = gr.Button("Separate Audio")
|
| 213 |
+
separation_output = gr.Textbox(label="Separation Output Path")
|
| 214 |
+
|
| 215 |
+
roformer_download_button.click(download_audio, [roformer_link], [input_audio])
|
| 216 |
+
separate_button.click(
|
| 217 |
+
fn=separate_audio,
|
| 218 |
+
inputs=[input_audio, "model_bs_roformer_ep_317_sdr_12.9755.ckpt",
|
| 219 |
+
"UVR-DeEcho-DeReverb.pth",
|
| 220 |
+
"mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt"],
|
| 221 |
+
outputs=[separation_output]
|
| 222 |
+
)
|
| 223 |
|
| 224 |
app.launch(
|
| 225 |
share=args.share_enabled,
|
| 226 |
server_name=None if not args.listen else (args.listen_host or '0.0.0.0'),
|
| 227 |
+
server_port=args.listen_port
|
| 228 |
)
|