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TabItem(translations["utils"]):
|
| 8 |
+
with gr.Tabs():
|
| 9 |
+
with gr.TabItem(translations["audio_editing"], visible=configs.get("audioldm2", True)):
|
| 10 |
+
gr.Markdown(translations["audio_editing_info"])
|
| 11 |
+
with gr.Row():
|
| 12 |
+
gr.Markdown(translations["audio_editing_markdown"])
|
| 13 |
+
with gr.Row():
|
| 14 |
+
with gr.Column():
|
| 15 |
+
with gr.Group():
|
| 16 |
+
with gr.Row():
|
| 17 |
+
save_compute = gr.Checkbox(label=translations["save_compute"], value=True, interactive=True)
|
| 18 |
+
tar_prompt = gr.Textbox(label=translations["target_prompt"], info=translations["target_prompt_info"], placeholder="Piano and violin cover", lines=5, interactive=True)
|
| 19 |
+
with gr.Column():
|
| 20 |
+
cfg_scale_src = gr.Slider(value=3, minimum=0.5, maximum=25, label=translations["cfg_scale_src"], info=translations["cfg_scale_src_info"], interactive=True)
|
| 21 |
+
cfg_scale_tar = gr.Slider(value=12, minimum=0.5, maximum=25, label=translations["cfg_scale_tar"], info=translations["cfg_scale_tar_info"], interactive=True)
|
| 22 |
+
with gr.Row():
|
| 23 |
+
edit_button = gr.Button(translations["editing"], variant="primary")
|
| 24 |
+
with gr.Row():
|
| 25 |
+
with gr.Column():
|
| 26 |
+
drop_audio_file = gr.File(label=translations["drop_audio"], file_types=[".wav", ".mp3", ".flac", ".ogg", ".opus", ".m4a", ".mp4", ".aac", ".alac", ".wma", ".aiff", ".webm", ".ac3"])
|
| 27 |
+
display_audio = gr.Audio(show_download_button=True, interactive=False, label=translations["input_audio"])
|
| 28 |
+
with gr.Column():
|
| 29 |
+
with gr.Accordion(translations["input_output"], open=False):
|
| 30 |
+
with gr.Column():
|
| 31 |
+
export_audio_format = gr.Radio(label=translations["export_format"], info=translations["export_info"], choices=["wav", "mp3", "flac", "ogg", "opus", "m4a", "mp4", "aac", "alac", "wma", "aiff", "webm", "ac3"], value="wav", interactive=True)
|
| 32 |
+
input_audiopath = gr.Dropdown(label=translations["audio_path"], value="", choices=paths_for_files, info=translations["provide_audio"], allow_custom_value=True, interactive=True)
|
| 33 |
+
output_audiopath = gr.Textbox(label=translations["output_path"], value="audios/output.wav", placeholder="audios/output.wav", info=translations["output_path_info"], interactive=True)
|
| 34 |
+
with gr.Column():
|
| 35 |
+
refesh_audio = gr.Button(translations["refesh"])
|
| 36 |
+
with gr.Accordion(translations["setting"], open=False):
|
| 37 |
+
audioldm2_model = gr.Radio(label=translations["audioldm2_model"], info=translations["audioldm2_model_info"], choices=["audioldm2", "audioldm2-large", "audioldm2-music"], value="audioldm2-music", interactive=True)
|
| 38 |
+
with gr.Row():
|
| 39 |
+
src_prompt = gr.Textbox(label=translations["source_prompt"], lines=2, interactive=True, info=translations["source_prompt_info"], placeholder="A recording of a happy upbeat classical music piece")
|
| 40 |
+
with gr.Row():
|
| 41 |
+
with gr.Column():
|
| 42 |
+
audioldm2_sample_rate = gr.Slider(minimum=8000, maximum=96000, label=translations["sr"], info=translations["sr_info"], value=44100, step=1, interactive=True)
|
| 43 |
+
t_start = gr.Slider(minimum=15, maximum=85, value=45, step=1, label=translations["t_start"], interactive=True, info=translations["t_start_info"])
|
| 44 |
+
steps = gr.Slider(value=50, step=1, minimum=10, maximum=300, label=translations["steps_label"], info=translations["steps_info"], interactive=True)
|
| 45 |
+
with gr.Row():
|
| 46 |
+
gr.Markdown(translations["output_audio"])
|
| 47 |
+
with gr.Row():
|
| 48 |
+
output_audioldm2 = gr.Audio(show_download_button=True, interactive=False, label=translations["output_audio"])
|
| 49 |
+
with gr.Row():
|
| 50 |
+
refesh_audio.click(fn=change_audios_choices, inputs=[input_audiopath], outputs=[input_audiopath])
|
| 51 |
+
drop_audio_file.upload(fn=lambda audio_in: shutil.move(audio_in.name, os.path.join("audios")), inputs=[drop_audio_file], outputs=[input_audiopath])
|
| 52 |
+
input_audiopath.change(fn=lambda audio: audio if os.path.isfile(audio) else None, inputs=[input_audiopath], outputs=[display_audio])
|
| 53 |
+
with gr.Row():
|
| 54 |
+
edit_button.click(
|
| 55 |
+
fn=run_audioldm2,
|
| 56 |
+
inputs=[
|
| 57 |
+
input_audiopath,
|
| 58 |
+
output_audiopath,
|
| 59 |
+
export_audio_format,
|
| 60 |
+
audioldm2_sample_rate,
|
| 61 |
+
audioldm2_model,
|
| 62 |
+
src_prompt,
|
| 63 |
+
tar_prompt,
|
| 64 |
+
steps,
|
| 65 |
+
cfg_scale_src,
|
| 66 |
+
cfg_scale_tar,
|
| 67 |
+
t_start,
|
| 68 |
+
save_compute
|
| 69 |
+
],
|
| 70 |
+
outputs=[output_audioldm2],
|
| 71 |
+
api_name="audioldm2"
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
with gr.TabItem(translations["audio_effects"], visible=configs.get("effects_tab", True)):
|
| 75 |
+
gr.Markdown(translations["apply_audio_effects"])
|
| 76 |
+
with gr.Row():
|
| 77 |
+
gr.Markdown(translations["audio_effects_edit"])
|
| 78 |
+
with gr.Row():
|
| 79 |
+
with gr.Column():
|
| 80 |
+
with gr.Row():
|
| 81 |
+
reverb_check_box = gr.Checkbox(label=translations["reverb"], value=False, interactive=True)
|
| 82 |
+
chorus_check_box = gr.Checkbox(label=translations["chorus"], value=False, interactive=True)
|
| 83 |
+
delay_check_box = gr.Checkbox(label=translations["delay"], value=False, interactive=True)
|
| 84 |
+
phaser_check_box = gr.Checkbox(label=translations["phaser"], value=False, interactive=True)
|
| 85 |
+
compressor_check_box = gr.Checkbox(label=translations["compressor"], value=False, interactive=True)
|
| 86 |
+
more_options = gr.Checkbox(label=translations["more_option"], value=False, interactive=True)
|
| 87 |
+
with gr.Row():
|
| 88 |
+
with gr.Accordion(translations["input_output"], open=False):
|
| 89 |
+
with gr.Row():
|
| 90 |
+
upload_audio = gr.File(label=translations["drop_audio"], file_types=[".wav", ".mp3", ".flac", ".ogg", ".opus", ".m4a", ".mp4", ".aac", ".alac", ".wma", ".aiff", ".webm", ".ac3"])
|
| 91 |
+
with gr.Row():
|
| 92 |
+
audio_in_path = gr.Dropdown(label=translations["input_audio"], value="", choices=paths_for_files, info=translations["provide_audio"], interactive=True, allow_custom_value=True)
|
| 93 |
+
audio_out_path = gr.Textbox(label=translations["output_audio"], value="audios/audio_effects.wav", placeholder="audios/audio_effects.wav", info=translations["provide_output"], interactive=True)
|
| 94 |
+
with gr.Row():
|
| 95 |
+
with gr.Column():
|
| 96 |
+
audio_combination = gr.Checkbox(label=translations["merge_instruments"], value=False, interactive=True)
|
| 97 |
+
audio_combination_input = gr.Dropdown(label=translations["input_audio"], value="", choices=paths_for_files, info=translations["provide_audio"], interactive=True, allow_custom_value=True, visible=audio_combination.value)
|
| 98 |
+
with gr.Row():
|
| 99 |
+
audio_effects_refesh = gr.Button(translations["refesh"])
|
| 100 |
+
with gr.Row():
|
| 101 |
+
audio_output_format = gr.Radio(label=translations["export_format"], info=translations["export_info"], choices=["wav", "mp3", "flac", "ogg", "opus", "m4a", "mp4", "aac", "alac", "wma", "aiff", "webm", "ac3"], value="wav", interactive=True)
|
| 102 |
+
with gr.Row():
|
| 103 |
+
apply_effects_button = gr.Button(translations["apply"], variant="primary", scale=2)
|
| 104 |
+
with gr.Row():
|
| 105 |
+
with gr.Column():
|
| 106 |
+
with gr.Row():
|
| 107 |
+
with gr.Accordion(translations["reverb"], open=False, visible=reverb_check_box.value) as reverb_accordion:
|
| 108 |
+
reverb_freeze_mode = gr.Checkbox(label=translations["reverb_freeze"], info=translations["reverb_freeze_info"], value=False, interactive=True)
|
| 109 |
+
reverb_room_size = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.15, label=translations["room_size"], info=translations["room_size_info"], interactive=True)
|
| 110 |
+
reverb_damping = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.7, label=translations["damping"], info=translations["damping_info"], interactive=True)
|
| 111 |
+
reverb_wet_level = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.2, label=translations["wet_level"], info=translations["wet_level_info"], interactive=True)
|
| 112 |
+
reverb_dry_level = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.8, label=translations["dry_level"], info=translations["dry_level_info"], interactive=True)
|
| 113 |
+
reverb_width = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label=translations["width"], info=translations["width_info"], interactive=True)
|
| 114 |
+
with gr.Row():
|
| 115 |
+
with gr.Accordion(translations["chorus"], open=False, visible=chorus_check_box.value) as chorus_accordion:
|
| 116 |
+
chorus_depth = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["chorus_depth"], info=translations["chorus_depth_info"], interactive=True)
|
| 117 |
+
chorus_rate_hz = gr.Slider(minimum=0.1, maximum=10, step=0.1, value=1.5, label=translations["chorus_rate_hz"], info=translations["chorus_rate_hz_info"], interactive=True)
|
| 118 |
+
chorus_mix = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["chorus_mix"], info=translations["chorus_mix_info"], interactive=True)
|
| 119 |
+
chorus_centre_delay_ms = gr.Slider(minimum=0, maximum=50, step=1, value=10, label=translations["chorus_centre_delay_ms"], info=translations["chorus_centre_delay_ms_info"], interactive=True)
|
| 120 |
+
chorus_feedback = gr.Slider(minimum=-1, maximum=1, step=0.01, value=0, label=translations["chorus_feedback"], info=translations["chorus_feedback_info"], interactive=True)
|
| 121 |
+
with gr.Row():
|
| 122 |
+
with gr.Accordion(translations["delay"], open=False, visible=delay_check_box.value) as delay_accordion:
|
| 123 |
+
delay_second = gr.Slider(minimum=0, maximum=5, step=0.01, value=0.5, label=translations["delay_seconds"], info=translations["delay_seconds_info"], interactive=True)
|
| 124 |
+
delay_feedback = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["delay_feedback"], info=translations["delay_feedback_info"], interactive=True)
|
| 125 |
+
delay_mix = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["delay_mix"], info=translations["delay_mix_info"], interactive=True)
|
| 126 |
+
with gr.Column():
|
| 127 |
+
with gr.Row():
|
| 128 |
+
with gr.Accordion(translations["more_option"], open=False, visible=more_options.value) as more_accordion:
|
| 129 |
+
with gr.Row():
|
| 130 |
+
fade = gr.Checkbox(label=translations["fade"], value=False, interactive=True)
|
| 131 |
+
bass_or_treble = gr.Checkbox(label=translations["bass_or_treble"], value=False, interactive=True)
|
| 132 |
+
limiter = gr.Checkbox(label=translations["limiter"], value=False, interactive=True)
|
| 133 |
+
resample_checkbox = gr.Checkbox(label=translations["resample"], value=False, interactive=True)
|
| 134 |
+
with gr.Row():
|
| 135 |
+
distortion_checkbox = gr.Checkbox(label=translations["distortion"], value=False, interactive=True)
|
| 136 |
+
gain_checkbox = gr.Checkbox(label=translations["gain"], value=False, interactive=True)
|
| 137 |
+
bitcrush_checkbox = gr.Checkbox(label=translations["bitcrush"], value=False, interactive=True)
|
| 138 |
+
clipping_checkbox = gr.Checkbox(label=translations["clipping"], value=False, interactive=True)
|
| 139 |
+
with gr.Accordion(translations["fade"], open=True, visible=fade.value) as fade_accordion:
|
| 140 |
+
with gr.Row():
|
| 141 |
+
fade_in = gr.Slider(minimum=0, maximum=10000, step=100, value=0, label=translations["fade_in"], info=translations["fade_in_info"], interactive=True)
|
| 142 |
+
fade_out = gr.Slider(minimum=0, maximum=10000, step=100, value=0, label=translations["fade_out"], info=translations["fade_out_info"], interactive=True)
|
| 143 |
+
with gr.Accordion(translations["bass_or_treble"], open=True, visible=bass_or_treble.value) as bass_treble_accordion:
|
| 144 |
+
with gr.Row():
|
| 145 |
+
bass_boost = gr.Slider(minimum=0, maximum=20, step=1, value=0, label=translations["bass_boost"], info=translations["bass_boost_info"], interactive=True)
|
| 146 |
+
bass_frequency = gr.Slider(minimum=20, maximum=200, step=10, value=100, label=translations["bass_frequency"], info=translations["bass_frequency_info"], interactive=True)
|
| 147 |
+
with gr.Row():
|
| 148 |
+
treble_boost = gr.Slider(minimum=0, maximum=20, step=1, value=0, label=translations["treble_boost"], info=translations["treble_boost_info"], interactive=True)
|
| 149 |
+
treble_frequency = gr.Slider(minimum=1000, maximum=10000, step=500, value=3000, label=translations["treble_frequency"], info=translations["treble_frequency_info"], interactive=True)
|
| 150 |
+
with gr.Accordion(translations["limiter"], open=True, visible=limiter.value) as limiter_accordion:
|
| 151 |
+
with gr.Row():
|
| 152 |
+
limiter_threashold_db = gr.Slider(minimum=-60, maximum=0, step=1, value=-1, label=translations["limiter_threashold_db"], info=translations["limiter_threashold_db_info"], interactive=True)
|
| 153 |
+
limiter_release_ms = gr.Slider(minimum=10, maximum=1000, step=1, value=100, label=translations["limiter_release_ms"], info=translations["limiter_release_ms_info"], interactive=True)
|
| 154 |
+
with gr.Column():
|
| 155 |
+
pitch_shift_semitones = gr.Slider(minimum=-20, maximum=20, step=1, value=0, label=translations["pitch"], info=translations["pitch_info"], interactive=True)
|
| 156 |
+
audio_effect_resample_sr = gr.Slider(minimum=0, maximum=96000, step=1, value=0, label=translations["resample"], info=translations["resample_info"], interactive=True, visible=resample_checkbox.value)
|
| 157 |
+
distortion_drive_db = gr.Slider(minimum=0, maximum=50, step=1, value=20, label=translations["distortion"], info=translations["distortion_info"], interactive=True, visible=distortion_checkbox.value)
|
| 158 |
+
gain_db = gr.Slider(minimum=-60, maximum=60, step=1, value=0, label=translations["gain"], info=translations["gain_info"], interactive=True, visible=gain_checkbox.value)
|
| 159 |
+
clipping_threashold_db = gr.Slider(minimum=-60, maximum=0, step=1, value=-1, label=translations["clipping_threashold_db"], info=translations["clipping_threashold_db_info"], interactive=True, visible=clipping_checkbox.value)
|
| 160 |
+
bitcrush_bit_depth = gr.Slider(minimum=1, maximum=24, step=1, value=16, label=translations["bitcrush_bit_depth"], info=translations["bitcrush_bit_depth_info"], interactive=True, visible=bitcrush_checkbox.value)
|
| 161 |
+
with gr.Row():
|
| 162 |
+
with gr.Accordion(translations["phaser"], open=False, visible=phaser_check_box.value) as phaser_accordion:
|
| 163 |
+
phaser_depth = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["phaser_depth"], info=translations["phaser_depth_info"], interactive=True)
|
| 164 |
+
phaser_rate_hz = gr.Slider(minimum=0.1, maximum=10, step=0.1, value=1, label=translations["phaser_rate_hz"], info=translations["phaser_rate_hz_info"], interactive=True)
|
| 165 |
+
phaser_mix = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["phaser_mix"], info=translations["phaser_mix_info"], interactive=True)
|
| 166 |
+
phaser_centre_frequency_hz = gr.Slider(minimum=50, maximum=5000, step=10, value=1000, label=translations["phaser_centre_frequency_hz"], info=translations["phaser_centre_frequency_hz_info"], interactive=True)
|
| 167 |
+
phaser_feedback = gr.Slider(minimum=-1, maximum=1, step=0.01, value=0, label=translations["phaser_feedback"], info=translations["phaser_feedback_info"], interactive=True)
|
| 168 |
+
with gr.Row():
|
| 169 |
+
with gr.Accordion(translations["compressor"], open=False, visible=compressor_check_box.value) as compressor_accordion:
|
| 170 |
+
compressor_threashold_db = gr.Slider(minimum=-60, maximum=0, step=1, value=-20, label=translations["compressor_threashold_db"], info=translations["compressor_threashold_db_info"], interactive=True)
|
| 171 |
+
compressor_ratio = gr.Slider(minimum=1, maximum=20, step=0.1, value=1, label=translations["compressor_ratio"], info=translations["compressor_ratio_info"], interactive=True)
|
| 172 |
+
compressor_attack_ms = gr.Slider(minimum=0.1, maximum=100, step=0.1, value=10, label=translations["compressor_attack_ms"], info=translations["compressor_attack_ms_info"], interactive=True)
|
| 173 |
+
compressor_release_ms = gr.Slider(minimum=10, maximum=1000, step=1, value=100, label=translations["compressor_release_ms"], info=translations["compressor_release_ms_info"], interactive=True)
|
| 174 |
+
with gr.Row():
|
| 175 |
+
gr.Markdown(translations["output_audio"])
|
| 176 |
+
with gr.Row():
|
| 177 |
+
audio_play_input = gr.Audio(show_download_button=True, interactive=False, label=translations["input_audio"])
|
| 178 |
+
audio_play_output = gr.Audio(show_download_button=True, interactive=False, label=translations["output_audio"])
|
| 179 |
+
with gr.Row():
|
| 180 |
+
reverb_check_box.change(fn=visible, inputs=[reverb_check_box], outputs=[reverb_accordion])
|
| 181 |
+
chorus_check_box.change(fn=visible, inputs=[chorus_check_box], outputs=[chorus_accordion])
|
| 182 |
+
delay_check_box.change(fn=visible, inputs=[delay_check_box], outputs=[delay_accordion])
|
| 183 |
+
with gr.Row():
|
| 184 |
+
compressor_check_box.change(fn=visible, inputs=[compressor_check_box], outputs=[compressor_accordion])
|
| 185 |
+
phaser_check_box.change(fn=visible, inputs=[phaser_check_box], outputs=[phaser_accordion])
|
| 186 |
+
more_options.change(fn=visible, inputs=[more_options], outputs=[more_accordion])
|
| 187 |
+
with gr.Row():
|
| 188 |
+
fade.change(fn=visible, inputs=[fade], outputs=[fade_accordion])
|
| 189 |
+
bass_or_treble.change(fn=visible, inputs=[bass_or_treble], outputs=[bass_treble_accordion])
|
| 190 |
+
limiter.change(fn=visible, inputs=[limiter], outputs=[limiter_accordion])
|
| 191 |
+
resample_checkbox.change(fn=visible, inputs=[resample_checkbox], outputs=[audio_effect_resample_sr])
|
| 192 |
+
with gr.Row():
|
| 193 |
+
distortion_checkbox.change(fn=visible, inputs=[distortion_checkbox], outputs=[distortion_drive_db])
|
| 194 |
+
gain_checkbox.change(fn=visible, inputs=[gain_checkbox], outputs=[gain_db])
|
| 195 |
+
clipping_checkbox.change(fn=visible, inputs=[clipping_checkbox], outputs=[clipping_threashold_db])
|
| 196 |
+
bitcrush_checkbox.change(fn=visible, inputs=[bitcrush_checkbox], outputs=[bitcrush_bit_depth])
|
| 197 |
+
with gr.Row():
|
| 198 |
+
upload_audio.upload(fn=lambda audio_in: shutil.move(audio_in.name, os.path.join("audios")), inputs=[upload_audio], outputs=[audio_in_path])
|
| 199 |
+
audio_in_path.change(fn=lambda audio: audio if audio else None, inputs=[audio_in_path], outputs=[audio_play_input])
|
| 200 |
+
audio_effects_refesh.click(fn=lambda a, b: [change_audios_choices(a), change_audios_choices(b)], inputs=[audio_in_path, audio_combination_input], outputs=[audio_in_path, audio_combination_input])
|
| 201 |
+
with gr.Row():
|
| 202 |
+
more_options.change(fn=lambda: [False]*8, inputs=[], outputs=[fade, bass_or_treble, limiter, resample_checkbox, distortion_checkbox, gain_checkbox, clipping_checkbox, bitcrush_checkbox])
|
| 203 |
+
audio_combination.change(fn=visible, inputs=[audio_combination], outputs=[audio_combination_input])
|
| 204 |
+
with gr.Row():
|
| 205 |
+
apply_effects_button.click(
|
| 206 |
+
fn=audio_effects,
|
| 207 |
+
inputs=[
|
| 208 |
+
audio_in_path,
|
| 209 |
+
audio_out_path,
|
| 210 |
+
resample_checkbox,
|
| 211 |
+
audio_effect_resample_sr,
|
| 212 |
+
chorus_depth,
|
| 213 |
+
chorus_rate_hz,
|
| 214 |
+
chorus_mix,
|
| 215 |
+
chorus_centre_delay_ms,
|
| 216 |
+
chorus_feedback,
|
| 217 |
+
distortion_drive_db,
|
| 218 |
+
reverb_room_size,
|
| 219 |
+
reverb_damping,
|
| 220 |
+
reverb_wet_level,
|
| 221 |
+
reverb_dry_level,
|
| 222 |
+
reverb_width,
|
| 223 |
+
reverb_freeze_mode,
|
| 224 |
+
pitch_shift_semitones,
|
| 225 |
+
delay_second,
|
| 226 |
+
delay_feedback,
|
| 227 |
+
delay_mix,
|
| 228 |
+
compressor_threashold_db,
|
| 229 |
+
compressor_ratio,
|
| 230 |
+
compressor_attack_ms,
|
| 231 |
+
compressor_release_ms,
|
| 232 |
+
limiter_threashold_db,
|
| 233 |
+
limiter_release_ms,
|
| 234 |
+
gain_db,
|
| 235 |
+
bitcrush_bit_depth,
|
| 236 |
+
clipping_threashold_db,
|
| 237 |
+
phaser_rate_hz,
|
| 238 |
+
phaser_depth,
|
| 239 |
+
phaser_centre_frequency_hz,
|
| 240 |
+
phaser_feedback,
|
| 241 |
+
phaser_mix,
|
| 242 |
+
bass_boost,
|
| 243 |
+
bass_frequency,
|
| 244 |
+
treble_boost,
|
| 245 |
+
treble_frequency,
|
| 246 |
+
fade_in,
|
| 247 |
+
fade_out,
|
| 248 |
+
audio_output_format,
|
| 249 |
+
chorus_check_box,
|
| 250 |
+
distortion_checkbox,
|
| 251 |
+
reverb_check_box,
|
| 252 |
+
delay_check_box,
|
| 253 |
+
compressor_check_box,
|
| 254 |
+
limiter,
|
| 255 |
+
gain_checkbox,
|
| 256 |
+
bitcrush_checkbox,
|
| 257 |
+
clipping_checkbox,
|
| 258 |
+
phaser_check_box,
|
| 259 |
+
bass_or_treble,
|
| 260 |
+
fade,
|
| 261 |
+
audio_combination,
|
| 262 |
+
audio_combination_input
|
| 263 |
+
],
|
| 264 |
+
outputs=[audio_play_output],
|
| 265 |
+
api_name="audio_effects"
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
with gr.TabItem(translations["f0_extractor_tab"], visible=configs.get("f0_extractor_tab", True)):
|
| 269 |
+
gr.Markdown(translations["f0_extractor_markdown"])
|
| 270 |
+
with gr.Row():
|
| 271 |
+
gr.Markdown(translations["f0_extractor_markdown_2"])
|
| 272 |
+
with gr.Row():
|
| 273 |
+
extractor_button = gr.Button(translations["extract_button"].replace("2. ", ""), variant="primary")
|
| 274 |
+
with gr.Row():
|
| 275 |
+
with gr.Column():
|
| 276 |
+
upload_audio_file = gr.File(label=translations["drop_audio"], file_types=[".wav", ".mp3", ".flac", ".ogg", ".opus", ".m4a", ".mp4", ".aac", ".alac", ".wma", ".aiff", ".webm", ".ac3"])
|
| 277 |
+
audioplay = gr.Audio(show_download_button=True, interactive=False, label=translations["input_audio"])
|
| 278 |
+
with gr.Column():
|
| 279 |
+
with gr.Accordion(translations["f0_method"], open=False):
|
| 280 |
+
with gr.Group():
|
| 281 |
+
onnx_f0_mode3 = gr.Checkbox(label=translations["f0_onnx_mode"], info=translations["f0_onnx_mode_info"], value=False, interactive=True)
|
| 282 |
+
f0_method_extract = gr.Radio(label=translations["f0_method"], info=translations["f0_method_info"], choices=method_f0, value="rmvpe", interactive=True)
|
| 283 |
+
with gr.Accordion(translations["audio_path"], open=True):
|
| 284 |
+
input_audio_path = gr.Dropdown(label=translations["audio_path"], value="", choices=paths_for_files, allow_custom_value=True, interactive=True)
|
| 285 |
+
refesh_audio_button = gr.Button(translations["refesh"])
|
| 286 |
+
with gr.Row():
|
| 287 |
+
gr.Markdown("___")
|
| 288 |
+
with gr.Row():
|
| 289 |
+
file_output = gr.File(label="", file_types=[".txt"], interactive=False)
|
| 290 |
+
image_output = gr.Image(label="", interactive=False, show_download_button=True)
|
| 291 |
+
with gr.Row():
|
| 292 |
+
upload_audio_file.upload(fn=lambda audio_in: shutil.move(audio_in.name, os.path.join("audios")), inputs=[upload_audio_file], outputs=[input_audio_path])
|
| 293 |
+
input_audio_path.change(fn=lambda audio: audio if os.path.isfile(audio) else None, inputs=[input_audio_path], outputs=[audioplay])
|
| 294 |
+
refesh_audio_button.click(fn=change_audios_choices, inputs=[input_audio_path], outputs=[input_audio_path])
|
| 295 |
+
with gr.Row():
|
| 296 |
+
extractor_button.click(
|
| 297 |
+
fn=f0_extract,
|
| 298 |
+
inputs=[
|
| 299 |
+
input_audio_path,
|
| 300 |
+
f0_method_extract,
|
| 301 |
+
onnx_f0_mode3
|
| 302 |
+
],
|
| 303 |
+
outputs=[file_output, image_output],
|
| 304 |
+
api_name="f0_extract"
|
| 305 |
+
)
|