Spaces:
Runtime error
Runtime error
Test Interface without change queues
Browse files
app.py
CHANGED
|
@@ -97,7 +97,7 @@ def load_melody_filepath(melody_filepath, title):
|
|
| 97 |
#$Union[str, os.PathLike]
|
| 98 |
symbols = ['_', '.', '-']
|
| 99 |
if (melody_filepath is None) or (melody_filepath == ""):
|
| 100 |
-
return title, gr.
|
| 101 |
|
| 102 |
if (title is None) or ("MusicGen" in title) or (title == ""):
|
| 103 |
melody_name, melody_extension = get_filename_from_filepath(melody_filepath)
|
|
@@ -117,7 +117,7 @@ def load_melody_filepath(melody_filepath, title):
|
|
| 117 |
print(f"Melody length: {len(melody_data)}, Melody segments: {total_melodys}\n")
|
| 118 |
MAX_PROMPT_INDEX = total_melodys
|
| 119 |
|
| 120 |
-
return gr.Textbox.update(value=melody_name), gr.
|
| 121 |
|
| 122 |
def predict(model, text, melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap=1, prompt_index = 0, include_title = True, include_settings = True, harmony_only = False):
|
| 123 |
global MODEL, INTERRUPTED, INTERRUPTING, MOVE_TO_CPU
|
|
@@ -305,11 +305,11 @@ def ui(**kwargs):
|
|
| 305 |
# Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
|
| 306 |
_ = gr.Button("Interrupt", elem_id="btn-interrupt").click(fn=interrupt, queue=False)
|
| 307 |
with gr.Row():
|
| 308 |
-
with gr.Column():
|
| 309 |
-
melody_filepath = gr.Audio(source="upload", type="filepath", label="Melody Condition (optional)", interactive=True, elem_id="melody-input")
|
| 310 |
-
harmony_only = gr.Radio(label="Use Harmony Only",choices=["No", "Yes"], value="No", interactive=True, info="Remove Drums?")
|
| 311 |
with gr.Column():
|
| 312 |
radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")
|
|
|
|
|
|
|
|
|
|
| 313 |
prompt_index = gr.Slider(label="Melody Condition Sample Segment", minimum=-1, maximum=MAX_PROMPT_INDEX, step=1, value=0, interactive=True, info="Which 30 second segment to condition with, - 1 condition each segment independantly")
|
| 314 |
with gr.Accordion("Video", open=False):
|
| 315 |
with gr.Row():
|
|
@@ -340,7 +340,7 @@ def ui(**kwargs):
|
|
| 340 |
seed_used = gr.Number(label='Seed used', value=-1, interactive=False)
|
| 341 |
|
| 342 |
radio.change(toggle_audio_src, radio, [melody_filepath], queue=False, show_progress=False)
|
| 343 |
-
melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title], outputs=[title, prompt_index , model], api_name="melody_filepath_change")
|
| 344 |
reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed")
|
| 345 |
submit.click(predict, 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], outputs=[output, wave_file, seed_used], api_name="submit")
|
| 346 |
gr.Examples(
|
|
|
|
| 97 |
#$Union[str, os.PathLike]
|
| 98 |
symbols = ['_', '.', '-']
|
| 99 |
if (melody_filepath is None) or (melody_filepath == ""):
|
| 100 |
+
return title, gr.update(maximum=0, value=0) , gr.update(value="melody", interactive=True)
|
| 101 |
|
| 102 |
if (title is None) or ("MusicGen" in title) or (title == ""):
|
| 103 |
melody_name, melody_extension = get_filename_from_filepath(melody_filepath)
|
|
|
|
| 117 |
print(f"Melody length: {len(melody_data)}, Melody segments: {total_melodys}\n")
|
| 118 |
MAX_PROMPT_INDEX = total_melodys
|
| 119 |
|
| 120 |
+
return gr.Textbox.update(value=melody_name), gr.update(maximum=MAX_PROMPT_INDEX, value=0), gr.update(value="melody", interactive=False)
|
| 121 |
|
| 122 |
def predict(model, text, melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap=1, prompt_index = 0, include_title = True, include_settings = True, harmony_only = False):
|
| 123 |
global MODEL, INTERRUPTED, INTERRUPTING, MOVE_TO_CPU
|
|
|
|
| 305 |
# Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
|
| 306 |
_ = gr.Button("Interrupt", elem_id="btn-interrupt").click(fn=interrupt, queue=False)
|
| 307 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
| 308 |
with gr.Column():
|
| 309 |
radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")
|
| 310 |
+
melody_filepath = gr.Audio(source="upload", type="filepath", label="Melody Condition (optional)", interactive=True, elem_id="melody-input")
|
| 311 |
+
with gr.Column():
|
| 312 |
+
harmony_only = gr.Radio(label="Use Harmony Only",choices=["No", "Yes"], value="No", interactive=True, info="Remove Drums?")
|
| 313 |
prompt_index = gr.Slider(label="Melody Condition Sample Segment", minimum=-1, maximum=MAX_PROMPT_INDEX, step=1, value=0, interactive=True, info="Which 30 second segment to condition with, - 1 condition each segment independantly")
|
| 314 |
with gr.Accordion("Video", open=False):
|
| 315 |
with gr.Row():
|
|
|
|
| 340 |
seed_used = gr.Number(label='Seed used', value=-1, interactive=False)
|
| 341 |
|
| 342 |
radio.change(toggle_audio_src, radio, [melody_filepath], queue=False, show_progress=False)
|
| 343 |
+
melody_filepath.change(load_melody_filepath, inputs=[melody_filepath, title], outputs=[title, prompt_index , model], api_name="melody_filepath_change", queue=False)
|
| 344 |
reuse_seed.click(fn=lambda x: x, inputs=[seed_used], outputs=[seed], queue=False, api_name="reuse_seed")
|
| 345 |
submit.click(predict, 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], outputs=[output, wave_file, seed_used], api_name="submit")
|
| 346 |
gr.Examples(
|