add edit
This commit is contained in:
+137
-5
@@ -98,8 +98,8 @@ def create_text2music_ui(
|
||||
with gr.Column():
|
||||
outputs, input_params_json = create_output_ui()
|
||||
with gr.Tab("retake"):
|
||||
retake_variance = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=0.2, label="variance", info="Variance for the retake. 0.0 means no variance. 1.0 means full variance.")
|
||||
retake_seeds = gr.Textbox(label="retake seeds (default None)", placeholder="", value=None, info="Seed for the retake.")
|
||||
retake_variance = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=0.2, label="variance")
|
||||
retake_seeds = gr.Textbox(label="retake seeds (default None)", placeholder="", value=None)
|
||||
retake_bnt = gr.Button("Retake", variant="primary")
|
||||
retake_outputs, retake_input_params_json = create_output_ui("Retake")
|
||||
|
||||
@@ -138,8 +138,8 @@ def create_text2music_ui(
|
||||
outputs=retake_outputs + [retake_input_params_json],
|
||||
)
|
||||
with gr.Tab("repainting"):
|
||||
retake_variance = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=0.2, label="variance", info="Variance for the retake. 0.0 means no variance. 1.0 means full variance.")
|
||||
retake_seeds = gr.Textbox(label="retake seeds (default None)", placeholder="", value=None, info="Seed for the retake.")
|
||||
retake_variance = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=0.2, label="variance")
|
||||
retake_seeds = gr.Textbox(label="retake seeds (default None)", placeholder="", value=None)
|
||||
repaint_start = gr.Slider(minimum=0.0, maximum=240.0, step=0.01, value=0.0, label="Repaint Start Time", interactive=True)
|
||||
repaint_end = gr.Slider(minimum=0.0, maximum=240.0, step=0.01, value=30.0, label="Repaint End Time", interactive=True)
|
||||
repaint_source = gr.Radio(["text2music", "last_repaint", "upload"], value="text2music", label="Repaint Source", elem_id="repaint_source")
|
||||
@@ -250,7 +250,139 @@ def create_text2music_ui(
|
||||
outputs=repaint_outputs + [repaint_input_params_json],
|
||||
)
|
||||
with gr.Tab("edit"):
|
||||
pass
|
||||
edit_prompt = gr.Textbox(lines=2, label="Edit Tags", max_lines=4)
|
||||
edit_lyrics = gr.Textbox(lines=9, label="Edit Lyrics", max_lines=13)
|
||||
|
||||
edit_type = gr.Radio(["only_lyrics", "remix"], value="only_lyrics", label="Edit Type", elem_id="edit_type", info="`only_lyrics` will keep the whole song the same except lyrics difference. Make your diffrence smaller, e.g. one lyrc line change.\nremix can change the song melody and genre")
|
||||
edit_n_min = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=0.8, label="edit_n_min", interactive=True)
|
||||
edit_n_max = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=1.0, label="edit_n_max", interactive=True)
|
||||
|
||||
def edit_type_change_func(edit_type):
|
||||
if edit_type == "only_lyrics":
|
||||
n_min = 0.8
|
||||
n_max = 1.0
|
||||
elif edit_type == "remix":
|
||||
n_min = 0.2
|
||||
n_max = 0.4
|
||||
return n_min, n_max
|
||||
|
||||
edit_type.change(
|
||||
edit_type_change_func,
|
||||
inputs=[edit_type],
|
||||
outputs=[edit_n_min, edit_n_max]
|
||||
)
|
||||
|
||||
edit_source = gr.Radio(["text2music", "last_edit", "upload"], value="text2music", label="Edit Source", elem_id="edit_source")
|
||||
edit_source_audio_upload = gr.Audio(label="Upload Audio", type="filepath", visible=False, elem_id="edit_source_audio_upload")
|
||||
edit_source.change(
|
||||
fn=lambda x: gr.update(visible=x == "upload", elem_id="edit_source_audio_upload"),
|
||||
inputs=[edit_source],
|
||||
outputs=[edit_source_audio_upload],
|
||||
)
|
||||
|
||||
edit_bnt = gr.Button("Edit", variant="primary")
|
||||
edit_outputs, edit_input_params_json = create_output_ui("Edit")
|
||||
|
||||
def edit_process_func(
|
||||
text2music_json_data,
|
||||
edit_input_params_json,
|
||||
edit_source,
|
||||
edit_source_audio_upload,
|
||||
prompt,
|
||||
lyrics,
|
||||
edit_prompt,
|
||||
edit_lyrics,
|
||||
edit_n_min,
|
||||
edit_n_max,
|
||||
infer_step,
|
||||
guidance_scale,
|
||||
scheduler_type,
|
||||
cfg_type,
|
||||
omega_scale,
|
||||
manual_seeds,
|
||||
guidance_interval,
|
||||
guidance_interval_decay,
|
||||
min_guidance_scale,
|
||||
use_erg_tag,
|
||||
use_erg_lyric,
|
||||
use_erg_diffusion,
|
||||
oss_steps,
|
||||
guidance_scale_text,
|
||||
guidance_scale_lyric,
|
||||
):
|
||||
if edit_source == "upload":
|
||||
src_audio_path = edit_source_audio_upload
|
||||
json_data = text2music_json_data
|
||||
elif edit_source == "text2music":
|
||||
json_data = text2music_json_data
|
||||
src_audio_path = json_data["audio_path"]
|
||||
elif edit_source == "last_edit":
|
||||
json_data = edit_input_params_json
|
||||
src_audio_path = json_data["audio_path"]
|
||||
|
||||
if not edit_prompt:
|
||||
edit_prompt = prompt
|
||||
if not edit_lyrics:
|
||||
edit_lyrics = lyrics
|
||||
|
||||
return text2music_process_func(
|
||||
json_data["audio_duration"],
|
||||
prompt,
|
||||
lyrics,
|
||||
infer_step,
|
||||
guidance_scale,
|
||||
scheduler_type,
|
||||
cfg_type,
|
||||
omega_scale,
|
||||
manual_seeds,
|
||||
guidance_interval,
|
||||
guidance_interval_decay,
|
||||
min_guidance_scale,
|
||||
use_erg_tag,
|
||||
use_erg_lyric,
|
||||
use_erg_diffusion,
|
||||
oss_steps,
|
||||
guidance_scale_text,
|
||||
guidance_scale_lyric,
|
||||
task="edit",
|
||||
src_audio_path=src_audio_path,
|
||||
edit_target_prompt=edit_prompt,
|
||||
edit_target_lyrics=edit_lyrics,
|
||||
edit_n_min=edit_n_min,
|
||||
edit_n_max=edit_n_max
|
||||
)
|
||||
|
||||
edit_bnt.click(
|
||||
fn=edit_process_func,
|
||||
inputs=[
|
||||
input_params_json,
|
||||
edit_input_params_json,
|
||||
edit_source,
|
||||
edit_source_audio_upload,
|
||||
prompt,
|
||||
lyrics,
|
||||
edit_prompt,
|
||||
edit_lyrics,
|
||||
edit_n_min,
|
||||
edit_n_max,
|
||||
infer_step,
|
||||
guidance_scale,
|
||||
scheduler_type,
|
||||
cfg_type,
|
||||
omega_scale,
|
||||
manual_seeds,
|
||||
guidance_interval,
|
||||
guidance_interval_decay,
|
||||
min_guidance_scale,
|
||||
use_erg_tag,
|
||||
use_erg_lyric,
|
||||
use_erg_diffusion,
|
||||
oss_steps,
|
||||
guidance_scale_text,
|
||||
guidance_scale_lyric,
|
||||
],
|
||||
outputs=edit_outputs + [edit_input_params_json],
|
||||
)
|
||||
|
||||
def sample_data():
|
||||
json_data = sample_data_func()
|
||||
|
||||
Reference in New Issue
Block a user