Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,15 +13,15 @@ MODEL_ID = "Hyeon2/riffusion-musiccaps"
|
|
13 |
pipe = StableDiffusionPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.float16)
|
14 |
pipe = pipe.to(device)
|
15 |
|
16 |
-
def predict(prompt,
|
17 |
-
return classic(prompt,
|
18 |
|
19 |
-
def classic(prompt,
|
20 |
if duration == 5:
|
21 |
width_duration=512
|
22 |
else:
|
23 |
width_duration = 512 + ((int(duration) - 5) * 128)
|
24 |
-
spec = pipe(prompt,
|
25 |
print(spec)
|
26 |
wav = wav_bytes_from_spectrogram_image(spec)
|
27 |
with open("output.wav", "wb") as f:
|
@@ -114,8 +114,7 @@ with gr.Blocks(css="style.css") as demo:
|
|
114 |
|
115 |
gr.HTML(title)
|
116 |
|
117 |
-
prompt_input = gr.Textbox(placeholder="
|
118 |
-
audio_input = gr.Audio(sources=["upload"], type="filepath", visible=False)
|
119 |
with gr.Row():
|
120 |
negative_prompt = gr.Textbox(label="Negative prompt")
|
121 |
duration_input = gr.Slider(label="Duration in seconds", minimum=5, maximum=10, step=1, value=8, elem_id="duration-slider")
|
@@ -124,9 +123,9 @@ with gr.Blocks(css="style.css") as demo:
|
|
124 |
|
125 |
with gr.Column(elem_id="col-container-2"):
|
126 |
|
127 |
-
spectrogram_output = gr.Image(label="
|
128 |
-
sound_output = gr.Audio(type='filepath', label="
|
129 |
|
130 |
-
send_btn.click(predict, inputs=[prompt_input,
|
131 |
|
132 |
demo.queue(max_size=250).launch(debug=True, ssr_mode=False)
|
|
|
13 |
pipe = StableDiffusionPipeline.from_pretrained(MODEL_ID, torch_dtype=torch.float16)
|
14 |
pipe = pipe.to(device)
|
15 |
|
16 |
+
def predict(prompt, duration):
|
17 |
+
return classic(prompt, duration)
|
18 |
|
19 |
+
def classic(prompt, duration):
|
20 |
if duration == 5:
|
21 |
width_duration=512
|
22 |
else:
|
23 |
width_duration = 512 + ((int(duration) - 5) * 128)
|
24 |
+
spec = pipe(prompt, height=512, width=width_duration).images[0]
|
25 |
print(spec)
|
26 |
wav = wav_bytes_from_spectrogram_image(spec)
|
27 |
with open("output.wav", "wb") as f:
|
|
|
114 |
|
115 |
gr.HTML(title)
|
116 |
|
117 |
+
prompt_input = gr.Textbox(placeholder="A LoFi beat", label="Musical prompt", elem_id="prompt-in")
|
|
|
118 |
with gr.Row():
|
119 |
negative_prompt = gr.Textbox(label="Negative prompt")
|
120 |
duration_input = gr.Slider(label="Duration in seconds", minimum=5, maximum=10, step=1, value=8, elem_id="duration-slider")
|
|
|
123 |
|
124 |
with gr.Column(elem_id="col-container-2"):
|
125 |
|
126 |
+
spectrogram_output = gr.Image(label="Spectrogram Image Result", elem_id="img-out")
|
127 |
+
sound_output = gr.Audio(type='filepath', label="Generated Audio", elem_id="music-out")
|
128 |
|
129 |
+
send_btn.click(predict, inputs=[prompt_input, duration_input], outputs=[spectrogram_output, sound_output])
|
130 |
|
131 |
demo.queue(max_size=250).launch(debug=True, ssr_mode=False)
|