Update app.py
Browse files
app.py
CHANGED
@@ -38,12 +38,12 @@ def load_model(version):
|
|
38 |
return MusicGen.get_pretrained(version)
|
39 |
|
40 |
|
41 |
-
def predict(music_prompt, melody, duration):
|
42 |
text = music_prompt
|
43 |
global MODEL
|
44 |
topk = int(250)
|
45 |
-
if MODEL is None or MODEL.name !=
|
46 |
-
MODEL = load_model(
|
47 |
|
48 |
if duration > MODEL.lm.cfg.dataset.segment_duration:
|
49 |
raise gr.Error("MusicGen currently supports durations of up to 30 seconds!")
|
@@ -104,10 +104,10 @@ with gr.Blocks(css=css) as demo:
|
|
104 |
#split_drums = gr.Audio(type="filepath", label="Drums")
|
105 |
#split_others = gr.Audio(type="filepath", label="Other")
|
106 |
with gr.Row():
|
107 |
-
music_prompt = gr.Textbox(label="Musical Prompt", info="Describe what kind music you wish for", interactive=True)
|
108 |
-
melody = gr.Audio(source="upload", type="numpy", label="
|
109 |
-
|
110 |
-
|
111 |
with gr.Row():
|
112 |
duration = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="Duration", interactive=True)
|
113 |
with gr.Row():
|
@@ -119,7 +119,7 @@ with gr.Blocks(css=css) as demo:
|
|
119 |
# cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
|
120 |
|
121 |
output = gr.Audio(label="Generated Music")
|
122 |
-
load_sound_btn.click(split_process, inputs=[uploaded_sound, chosen_track], outputs=[melody])
|
123 |
submit.click(predict, inputs=[music_prompt, melody, duration], outputs=[output])
|
124 |
|
125 |
|
|
|
38 |
return MusicGen.get_pretrained(version)
|
39 |
|
40 |
|
41 |
+
def predict(music_prompt, melody, duration, model):
|
42 |
text = music_prompt
|
43 |
global MODEL
|
44 |
topk = int(250)
|
45 |
+
if MODEL is None or MODEL.name != model:
|
46 |
+
MODEL = load_model(model)
|
47 |
|
48 |
if duration > MODEL.lm.cfg.dataset.segment_duration:
|
49 |
raise gr.Error("MusicGen currently supports durations of up to 30 seconds!")
|
|
|
104 |
#split_drums = gr.Audio(type="filepath", label="Drums")
|
105 |
#split_others = gr.Audio(type="filepath", label="Other")
|
106 |
with gr.Row():
|
107 |
+
music_prompt = gr.Textbox(label="Musical Prompt", info="Describe what kind of music you wish for", interactive=True)
|
108 |
+
melody = gr.Audio(source="upload", type="numpy", label="Track Condition (from previous step)", interactive=False)
|
109 |
+
with gr.Row():
|
110 |
+
model = gr.Radio(["melody", "medium", "small", "large"], label="Model", value="melody", interactive=True)
|
111 |
with gr.Row():
|
112 |
duration = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="Duration", interactive=True)
|
113 |
with gr.Row():
|
|
|
119 |
# cfg_coef = gr.Number(label="Classifier Free Guidance", value=3.0, interactive=True)
|
120 |
|
121 |
output = gr.Audio(label="Generated Music")
|
122 |
+
load_sound_btn.click(split_process, inputs=[uploaded_sound, chosen_track, model], outputs=[melody])
|
123 |
submit.click(predict, inputs=[music_prompt, melody, duration], outputs=[output])
|
124 |
|
125 |
|