Spaces:
Running
on
T4
Running
on
T4
Segment Length Update
Browse files
app.py
CHANGED
@@ -133,9 +133,9 @@ def git_tag():
|
|
133 |
except Exception:
|
134 |
return "<none>"
|
135 |
|
136 |
-
def load_melody_filepath(melody_filepath, title, assigned_model,topp, temperature, cfg_coef,
|
137 |
# get melody filename
|
138 |
-
#$Union[str, os.PathLike]
|
139 |
symbols = ['_', '.', '-']
|
140 |
if (melody_filepath is None) or (melody_filepath == ""):
|
141 |
return title, gr.update(maximum=0, value=0) , gr.update(value="medium", interactive=True), gr.update(value=topp), gr.update(value=temperature), gr.update(value=cfg_coef)
|
@@ -146,9 +146,9 @@ def load_melody_filepath(melody_filepath, title, assigned_model,topp, temperatur
|
|
146 |
for symbol in symbols:
|
147 |
melody_name = melody_name.replace(symbol, ' ').title()
|
148 |
#additonal melody setting updates
|
149 |
-
topp =
|
150 |
temperature = 0.5
|
151 |
-
cfg_coef = 3.
|
152 |
else:
|
153 |
melody_name = title
|
154 |
|
@@ -160,7 +160,7 @@ def load_melody_filepath(melody_filepath, title, assigned_model,topp, temperatur
|
|
160 |
# get melody length in number of segments and modify the UI
|
161 |
melody = get_melody(melody_filepath)
|
162 |
sr, melody_data = melody[0], melody[1]
|
163 |
-
segment_samples = sr *
|
164 |
total_melodys = max(min((len(melody_data) // segment_samples), 25), 0)
|
165 |
print(f"Melody length: {len(melody_data)}, Melody segments: {total_melodys}\n")
|
166 |
MAX_PROMPT_INDEX = total_melodys
|
@@ -479,7 +479,7 @@ def ui(**kwargs):
|
|
479 |
settings_font_color = gr.ColorPicker(label="Settings Font Color", value="#c87f05", interactive=True, key="settings_font_color")
|
480 |
with gr.Accordion("Expert", open=False):
|
481 |
with gr.Row():
|
482 |
-
|
483 |
overlap = gr.Slider(minimum=0, maximum=15, value=1, step=1, label="Segment Overlap", interactive=True)
|
484 |
dimension = gr.Slider(minimum=-2, maximum=2, value=2, step=1, label="Dimension", info="determines which direction to add new segements of audio. (1 = stack tracks, 2 = lengthen, -2..0 = ?)", interactive=True)
|
485 |
with gr.Row():
|
@@ -497,9 +497,10 @@ def ui(**kwargs):
|
|
497 |
seed_used = gr.Number(label='Seed used', value=-1, interactive=False)
|
498 |
|
499 |
radio.change(toggle_audio_src, radio, [melody_filepath], queue=False, show_progress=False)
|
500 |
-
melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title, model,topp, temperature, cfg_coef,
|
501 |
reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed_click")
|
502 |
autoplay_cb.change(fn=lambda x: gr.update(autoplay=x), inputs=[autoplay_cb], outputs=[output], queue=False, api_name="autoplay_cb_change")
|
|
|
503 |
|
504 |
gr.Examples(
|
505 |
examples=[
|
@@ -568,7 +569,7 @@ def ui(**kwargs):
|
|
568 |
api_name="submit"
|
569 |
).then(
|
570 |
predict,
|
571 |
-
inputs=[model, text,melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap, prompt_index, include_title, include_settings, harmony_only, user_profile,
|
572 |
outputs=[output, wave_file, seed_used], scroll_to_output=True)
|
573 |
|
574 |
# Show the interface
|
|
|
133 |
except Exception:
|
134 |
return "<none>"
|
135 |
|
136 |
+
def load_melody_filepath(melody_filepath, title, assigned_model,topp, temperature, cfg_coef, segment_length = 30):
|
137 |
# get melody filename
|
138 |
+
#$Union[str, os.PathLike]
|
139 |
symbols = ['_', '.', '-']
|
140 |
if (melody_filepath is None) or (melody_filepath == ""):
|
141 |
return title, gr.update(maximum=0, value=0) , gr.update(value="medium", interactive=True), gr.update(value=topp), gr.update(value=temperature), gr.update(value=cfg_coef)
|
|
|
146 |
for symbol in symbols:
|
147 |
melody_name = melody_name.replace(symbol, ' ').title()
|
148 |
#additonal melody setting updates
|
149 |
+
topp = 800
|
150 |
temperature = 0.5
|
151 |
+
cfg_coef = 3.25
|
152 |
else:
|
153 |
melody_name = title
|
154 |
|
|
|
160 |
# get melody length in number of segments and modify the UI
|
161 |
melody = get_melody(melody_filepath)
|
162 |
sr, melody_data = melody[0], melody[1]
|
163 |
+
segment_samples = sr * segment_length
|
164 |
total_melodys = max(min((len(melody_data) // segment_samples), 25), 0)
|
165 |
print(f"Melody length: {len(melody_data)}, Melody segments: {total_melodys}\n")
|
166 |
MAX_PROMPT_INDEX = total_melodys
|
|
|
479 |
settings_font_color = gr.ColorPicker(label="Settings Font Color", value="#c87f05", interactive=True, key="settings_font_color")
|
480 |
with gr.Accordion("Expert", open=False):
|
481 |
with gr.Row():
|
482 |
+
segment_length = gr.Slider(minimum=10, maximum=30, value=30, step =1,label="Music Generation Segment Length (s)", interactive=True,key="segment_length")
|
483 |
overlap = gr.Slider(minimum=0, maximum=15, value=1, step=1, label="Segment Overlap", interactive=True)
|
484 |
dimension = gr.Slider(minimum=-2, maximum=2, value=2, step=1, label="Dimension", info="determines which direction to add new segements of audio. (1 = stack tracks, 2 = lengthen, -2..0 = ?)", interactive=True)
|
485 |
with gr.Row():
|
|
|
497 |
seed_used = gr.Number(label='Seed used', value=-1, interactive=False)
|
498 |
|
499 |
radio.change(toggle_audio_src, radio, [melody_filepath], queue=False, show_progress=False)
|
500 |
+
melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title, model,topp, temperature, cfg_coef, segment_length], outputs=[title, prompt_index , model, topp, temperature, cfg_coef], api_name="melody_filepath_change", queue=False)
|
501 |
reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed_click")
|
502 |
autoplay_cb.change(fn=lambda x: gr.update(autoplay=x), inputs=[autoplay_cb], outputs=[output], queue=False, api_name="autoplay_cb_change")
|
503 |
+
segment_length.change(fn=load_melody_filepath, queue=False, api_name="segment_length_change", trigger_mode="once", inputs=[melody_filepath, title, model,topp, temperature, cfg_coef, segment_length], outputs=[title, prompt_index , model, topp, temperature, cfg_coef], show_progress="minimal")
|
504 |
|
505 |
gr.Examples(
|
506 |
examples=[
|
|
|
569 |
api_name="submit"
|
570 |
).then(
|
571 |
predict,
|
572 |
+
inputs=[model, text,melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap, prompt_index, include_title, include_settings, harmony_only, user_profile, segment_length],
|
573 |
outputs=[output, wave_file, seed_used], scroll_to_output=True)
|
574 |
|
575 |
# Show the interface
|