Spaces:
Sleeping
Sleeping
Add Stable Audio Open option
Browse files
app.py
CHANGED
@@ -39,6 +39,13 @@ def check_api(model_name):
|
|
39 |
return "api ready"
|
40 |
except :
|
41 |
return "api not ready yet"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
from moviepy.editor import VideoFileClip
|
44 |
from moviepy.audio.AudioClip import AudioClip
|
@@ -179,7 +186,19 @@ def get_musicgen(prompt):
|
|
179 |
)
|
180 |
print(result)
|
181 |
return result[1]
|
182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
import re
|
184 |
import torch
|
185 |
from transformers import pipeline
|
@@ -263,6 +282,9 @@ def infer(image_in, chosen_model, api_status):
|
|
263 |
elif chosen_model == "MusicGen" :
|
264 |
gr.Info("Now calling MusicGen for music...")
|
265 |
music_o = get_musicgen(musical_prompt)
|
|
|
|
|
|
|
266 |
|
267 |
return gr.update(value=musical_prompt, interactive=True), gr.update(visible=True), music_o
|
268 |
|
@@ -284,6 +306,9 @@ def retry(chosen_model, caption):
|
|
284 |
elif chosen_model == "MusicGen" :
|
285 |
gr.Info("Now calling MusicGen for music...")
|
286 |
music_o = get_musicgen(musical_prompt)
|
|
|
|
|
|
|
287 |
|
288 |
return music_o
|
289 |
|
@@ -334,7 +359,8 @@ with gr.Blocks(css=css) as demo:
|
|
334 |
"AudioLDM-2",
|
335 |
"Riffusion",
|
336 |
"Mustango",
|
337 |
-
"MusicGen"
|
|
|
338 |
],
|
339 |
value = None,
|
340 |
filterable = False
|
|
|
39 |
return "api ready"
|
40 |
except :
|
41 |
return "api not ready yet"
|
42 |
+
elif model_name == "Stable Audio Open":
|
43 |
+
try:
|
44 |
+
client = Client("artificialguybr/Stable-Audio-Open-Zero")
|
45 |
+
return "api ready"
|
46 |
+
except:
|
47 |
+
return "api not ready yet"
|
48 |
+
|
49 |
|
50 |
from moviepy.editor import VideoFileClip
|
51 |
from moviepy.audio.AudioClip import AudioClip
|
|
|
186 |
)
|
187 |
print(result)
|
188 |
return result[1]
|
189 |
+
|
190 |
+
def get_stable_audio_open(prompt):
|
191 |
+
client = Client("artificialguybr/Stable-Audio-Open-Zero")
|
192 |
+
result = client.predict(
|
193 |
+
prompt=prompt,
|
194 |
+
seconds_total=30,
|
195 |
+
steps=100,
|
196 |
+
cfg_scale=7,
|
197 |
+
api_name="/predict"
|
198 |
+
)
|
199 |
+
print(result)
|
200 |
+
return result
|
201 |
+
|
202 |
import re
|
203 |
import torch
|
204 |
from transformers import pipeline
|
|
|
282 |
elif chosen_model == "MusicGen" :
|
283 |
gr.Info("Now calling MusicGen for music...")
|
284 |
music_o = get_musicgen(musical_prompt)
|
285 |
+
elif chosen_model == "Stable Audio Open" :
|
286 |
+
gr.Info("Now calling Stable Audio Open for music...")
|
287 |
+
music_o = get_sable_audio_open(musocal_prompt)
|
288 |
|
289 |
return gr.update(value=musical_prompt, interactive=True), gr.update(visible=True), music_o
|
290 |
|
|
|
306 |
elif chosen_model == "MusicGen" :
|
307 |
gr.Info("Now calling MusicGen for music...")
|
308 |
music_o = get_musicgen(musical_prompt)
|
309 |
+
elif chosen_model == "Stable Audio Open" :
|
310 |
+
gr.Info("Now calling Stable Audio Open for music...")
|
311 |
+
music_o = get_sable_audio_open(musocal_prompt)
|
312 |
|
313 |
return music_o
|
314 |
|
|
|
359 |
"AudioLDM-2",
|
360 |
"Riffusion",
|
361 |
"Mustango",
|
362 |
+
"MusicGen",
|
363 |
+
"Stable Audio Open"
|
364 |
],
|
365 |
value = None,
|
366 |
filterable = False
|