Surn commited on
Commit
b147eea
·
1 Parent(s): 4d23518

MCP server updates

Browse files
Files changed (1) hide show
  1. app.py +25 -13
app.py CHANGED
@@ -79,6 +79,15 @@ class FileCleaner:
79
 
80
  #file_cleaner = FileCleaner()
81
 
 
 
 
 
 
 
 
 
 
82
  def toggle_audio_src(choice):
83
  """
84
  Toggle the audio input source between microphone and file upload.
@@ -239,30 +248,30 @@ def load_melody_filepath(melody_filepath, title, assigned_model, topp, temperatu
239
 
240
  return gr.update(value=melody_name), gr.update(maximum=MAX_PROMPT_INDEX, value=-1), gr.update(value=assigned_model, interactive=True), gr.update(value=topp), gr.update(value=temperature), gr.update(value=cfg_coef), gr.update(maximum=MAX_OVERLAP)
241
 
242
- def predict(model, text, melody_filepath, duration, dimension, topk, topp, temperature, cfg_coef, background, title, settings_font, settings_font_color, seed, overlap=1, prompt_index = 0, include_title = True, include_settings = True, harmony_only = False, profile = gr.OAuthProfile, segment_length = 30, settings_font_size=28, settings_animate_waveform=False, video_orientation="Landscape", excerpt_duration=3.5, progress=gr.Progress(track_tqdm=True)):
243
  """
244
  Generate music and video based on the provided parameters and model.
245
 
246
  Args:
247
  model (str): Model name to use for generation.
248
  text (str): Prompt describing the music.
249
- melody_filepath (str): Path to melody conditioning file. default to None.
250
  duration (int): Total duration in seconds.
251
  dimension (int): Audio stacking/concatenation dimension.
252
  topk (int): Top-k sampling value.
253
  topp (float): Top-p sampling value.
254
  temperature (float): Sampling temperature.
255
  cfg_coef (float): Classifier-free guidance coefficient.
256
- background (str): Path to background image. default to "./assets/background.png".
257
- title (str): Song title.
258
- settings_font (str): Path to font file.
259
- settings_font_color (str): Font color for settings text.
260
- seed (int): Random seed.
261
- overlap (int, optional): Segment overlap in seconds.
262
- prompt_index (int, optional): Melody segment index.
263
- include_title (bool, optional): Whether to add title to video.
264
- include_settings (bool, optional): Whether to add settings to video.
265
- harmony_only (bool, optional): Whether to use harmony only.
266
  profile (gr.OAuthProfile): User profile.
267
  segment_length (int, optional): Segment length in seconds.
268
  settings_font_size (int, optional): Font size for settings text.
@@ -618,7 +627,7 @@ def ui(**kwargs):
618
  with gr.Row():
619
  with gr.Column():
620
  radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")
621
- melody_filepath = gr.Audio(sources=["upload"], type="filepath", label="Melody Condition (optional)", interactive=True, elem_id="melody-input", key="melody_input")
622
  with gr.Column():
623
  harmony_only = gr.Radio(label="Use Harmony Only",choices=["No", "Yes"], value="No", interactive=True, info="Remove Drums?", key="use_harmony")
624
  prompt_index = gr.Slider(label="Melody Condition Sample Segment", minimum=-1, maximum=MAX_PROMPT_INDEX, step=1, value=-1, interactive=True, info="Which 10-30 second segment to condition with, - 1 = align with conditioning melody", key="melody_index")
@@ -749,6 +758,9 @@ def ui(**kwargs):
749
  launch_kwargs['favicon_path'] = "./assets/favicon.ico"
750
  launch_kwargs['mcp_server'] = True
751
 
 
 
 
752
 
753
  demo.queue(max_size=10, api_open=True).launch(**launch_kwargs)
754
 
 
79
 
80
  #file_cleaner = FileCleaner()
81
 
82
+ def ping():
83
+ """
84
+ return the value true
85
+
86
+ Returns:
87
+ boolean: true
88
+ """
89
+ return True
90
+
91
  def toggle_audio_src(choice):
92
  """
93
  Toggle the audio input source between microphone and file upload.
 
248
 
249
  return gr.update(value=melody_name), gr.update(maximum=MAX_PROMPT_INDEX, value=-1), gr.update(value=assigned_model, interactive=True), gr.update(value=topp), gr.update(value=temperature), gr.update(value=cfg_coef), gr.update(maximum=MAX_OVERLAP)
250
 
251
+ def predict(model, text, melody_filepath = None, duration=10, dimension=2, topk=200, topp=0, temperature=1.0, cfg_coef=4.0, background = None, title="UnlimitedMusicGen", settings_font="./assets/arial.ttf", settings_font_color = "#c87f05", seed=-1, overlap=1, prompt_index = 0, include_title = True, include_settings = True, harmony_only = False, profile = gr.OAuthProfile, segment_length = 30, settings_font_size=28, settings_animate_waveform=False, video_orientation="Landscape", excerpt_duration=3.5, progress=gr.Progress(track_tqdm=True)):
252
  """
253
  Generate music and video based on the provided parameters and model.
254
 
255
  Args:
256
  model (str): Model name to use for generation.
257
  text (str): Prompt describing the music.
258
+ melody_filepath (str, optional): Path to melody conditioning file. default to None.
259
  duration (int): Total duration in seconds.
260
  dimension (int): Audio stacking/concatenation dimension.
261
  topk (int): Top-k sampling value.
262
  topp (float): Top-p sampling value.
263
  temperature (float): Sampling temperature.
264
  cfg_coef (float): Classifier-free guidance coefficient.
265
+ background (str, optional): Path to background image. Default to "./assets/background.png".
266
+ title (str, optional): Song title. Default to "UnlimitedMusicGen".
267
+ settings_font (str, optional): Path to font file. Default to "./assets/arial.ttf".
268
+ settings_font_color (str, optional): Font color for settings text. Default to "
269
+ seed (int, optional): Random seed. Default to -1.
270
+ overlap (int, optional): Segment overlap in seconds. Default to 1.
271
+ prompt_index (int, optional): Melody segment index. Default to 0.
272
+ include_title (bool, optional): Whether to add title to video. Default to True.
273
+ include_settings (bool, optional): Whether to add settings to video. Default to True.
274
+ harmony_only (bool, optional): Whether to use harmony only. Default to False.
275
  profile (gr.OAuthProfile): User profile.
276
  segment_length (int, optional): Segment length in seconds.
277
  settings_font_size (int, optional): Font size for settings text.
 
627
  with gr.Row():
628
  with gr.Column():
629
  radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")
630
+ melody_filepath = gr.Audio(value=None,sources=["upload"], type="filepath", label="Melody Condition (optional)", interactive=True, elem_id="melody-input", key="melody_input")
631
  with gr.Column():
632
  harmony_only = gr.Radio(label="Use Harmony Only",choices=["No", "Yes"], value="No", interactive=True, info="Remove Drums?", key="use_harmony")
633
  prompt_index = gr.Slider(label="Melody Condition Sample Segment", minimum=-1, maximum=MAX_PROMPT_INDEX, step=1, value=-1, interactive=True, info="Which 10-30 second segment to condition with, - 1 = align with conditioning melody", key="melody_index")
 
758
  launch_kwargs['favicon_path'] = "./assets/favicon.ico"
759
  launch_kwargs['mcp_server'] = True
760
 
761
+ gr.api (
762
+ ping, api_name="ping"
763
+ )
764
 
765
  demo.queue(max_size=10, api_open=True).launch(**launch_kwargs)
766