fffiloni commited on
Commit
19d9994
1 Parent(s): b0e0fc9

add Stable Audio option

Browse files
Files changed (1) hide show
  1. app.py +29 -2
app.py CHANGED
@@ -1,11 +1,13 @@
1
  import gradio as gr
2
  import spaces
 
3
  import json
4
  import re
5
  import random
6
  import numpy as np
7
  from gradio_client import Client
8
 
 
9
  MAX_SEED = np.iinfo(np.int32).max
10
 
11
  def check_api(model_name):
@@ -39,6 +41,13 @@ def check_api(model_name):
39
  return "api ready"
40
  except :
41
  return "api not ready yet"
 
 
 
 
 
 
 
42
 
43
  from moviepy.editor import *
44
  import cv2
@@ -194,6 +203,18 @@ def get_musicgen(prompt):
194
  )
195
  print(result)
196
  return result[1]
 
 
 
 
 
 
 
 
 
 
 
 
197
 
198
  import re
199
  import torch
@@ -297,6 +318,9 @@ def infer(video_in, chosen_model, api_status):
297
  elif chosen_model == "MusicGen" :
298
  gr.Info("Now calling MusicGen for music...")
299
  music_o = get_musicgen(musical_prompt)
 
 
 
300
 
301
  final_res = blend_vmsc(video_in, music_o)
302
  return gr.update(value=musical_prompt, interactive=True), gr.update(visible=True), music_o, final_res
@@ -319,6 +343,9 @@ def retry(video_in, chosen_model, caption):
319
  elif chosen_model == "MusicGen" :
320
  gr.Info("Now calling MusicGen for music...")
321
  music_o = get_musicgen(musical_prompt)
 
 
 
322
  final_res = blend_vmsc(video_in, music_o)
323
  return music_o, final_res
324
 
@@ -365,7 +392,8 @@ with gr.Blocks(css=css) as demo:
365
  "AudioLDM-2",
366
  "Riffusion",
367
  "Mustango",
368
- "MusicGen"
 
369
  ],
370
  value = None,
371
  filterable = False
@@ -431,7 +459,6 @@ with gr.Blocks(css=css) as demo:
431
  result,
432
  video_o
433
  ],
434
- concurrency_limit = 4
435
  )
436
 
437
  demo.queue(max_size=16).launch(show_api=False)
 
1
  import gradio as gr
2
  import spaces
3
+ import os
4
  import json
5
  import re
6
  import random
7
  import numpy as np
8
  from gradio_client import Client
9
 
10
+ hf_token = os.environ.get("HF_TOKEN")
11
  MAX_SEED = np.iinfo(np.int32).max
12
 
13
  def check_api(model_name):
 
41
  return "api ready"
42
  except :
43
  return "api not ready yet"
44
+ elif model_name == "Stable Audio Open":
45
+ try:
46
+ client = Client("fffiloni/Stable-Audio-Open-A10", hf_token=hf_token)
47
+ return "api ready"
48
+ except:
49
+ return "api not ready yet"
50
+
51
 
52
  from moviepy.editor import *
53
  import cv2
 
203
  )
204
  print(result)
205
  return result[1]
206
+
207
+ def get_stable_audio_open(prompt):
208
+ client = Client("fffiloni/Stable-Audio-Open-A10", hf_token=hf_token)
209
+ result = client.predict(
210
+ prompt=prompt,
211
+ seconds_total=10,
212
+ steps=100,
213
+ cfg_scale=7,
214
+ api_name="/predict"
215
+ )
216
+ print(result)
217
+ return result
218
 
219
  import re
220
  import torch
 
318
  elif chosen_model == "MusicGen" :
319
  gr.Info("Now calling MusicGen for music...")
320
  music_o = get_musicgen(musical_prompt)
321
+ elif chosen_model == "Stable Audio Open" :
322
+ gr.Info("Now calling Stable Audio Open for music...")
323
+ music_o = get_stable_audio_open(musical_prompt)
324
 
325
  final_res = blend_vmsc(video_in, music_o)
326
  return gr.update(value=musical_prompt, interactive=True), gr.update(visible=True), music_o, final_res
 
343
  elif chosen_model == "MusicGen" :
344
  gr.Info("Now calling MusicGen for music...")
345
  music_o = get_musicgen(musical_prompt)
346
+ elif chosen_model == "Stable Audio Open" :
347
+ gr.Info("Now calling Stable Audio Open for music...")
348
+ music_o = get_stable_audio_open(musical_prompt)
349
  final_res = blend_vmsc(video_in, music_o)
350
  return music_o, final_res
351
 
 
392
  "AudioLDM-2",
393
  "Riffusion",
394
  "Mustango",
395
+ "MusicGen",
396
+ "Stable Audio Open"
397
  ],
398
  value = None,
399
  filterable = False
 
459
  result,
460
  video_o
461
  ],
 
462
  )
463
 
464
  demo.queue(max_size=16).launch(show_api=False)