Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,13 +10,10 @@ from diffusers import StableDiffusionImg2ImgPipeline
|
|
10 |
|
11 |
device = "cpu"
|
12 |
MODEL_ID = "Hyeon2/riffusion-musiccaps"
|
13 |
-
pipe = StableDiffusionPipeline.from_pretrained(MODEL_ID
|
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:
|
@@ -26,7 +23,7 @@ def classic(prompt, duration):
|
|
26 |
wav = wav_bytes_from_spectrogram_image(spec)
|
27 |
with open("output.wav", "wb") as f:
|
28 |
f.write(wav[0].getbuffer())
|
29 |
-
return spec,
|
30 |
|
31 |
title = """
|
32 |
<div style="text-align: center; max-width: 500px; margin: 0 auto;">
|
@@ -114,9 +111,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
114 |
|
115 |
gr.HTML(title)
|
116 |
|
117 |
-
|
118 |
-
|
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")
|
121 |
|
122 |
send_btn = gr.Button(value="Get a new spectrogram!", elem_id="submit-btn")
|
|
|
10 |
|
11 |
device = "cpu"
|
12 |
MODEL_ID = "Hyeon2/riffusion-musiccaps"
|
13 |
+
pipe = StableDiffusionPipeline.from_pretrained(MODEL_ID)
|
14 |
pipe = pipe.to(device)
|
15 |
|
16 |
def predict(prompt, duration):
|
|
|
|
|
|
|
17 |
if duration == 5:
|
18 |
width_duration=512
|
19 |
else:
|
|
|
23 |
wav = wav_bytes_from_spectrogram_image(spec)
|
24 |
with open("output.wav", "wb") as f:
|
25 |
f.write(wav[0].getbuffer())
|
26 |
+
return spec, "output.wav"
|
27 |
|
28 |
title = """
|
29 |
<div style="text-align: center; max-width: 500px; margin: 0 auto;">
|
|
|
111 |
|
112 |
gr.HTML(title)
|
113 |
|
114 |
+
with gr.column():
|
115 |
+
prompt_input = gr.Textbox(placeholder="A LoFi beat", label="Musical prompt", elem_id="prompt-in")
|
|
|
116 |
duration_input = gr.Slider(label="Duration in seconds", minimum=5, maximum=10, step=1, value=8, elem_id="duration-slider")
|
117 |
|
118 |
send_btn = gr.Button(value="Get a new spectrogram!", elem_id="submit-btn")
|