Surn commited on
Commit
50d48cc
1 Parent(s): 1dda6b6
Files changed (2) hide show
  1. app.py +2 -2
  2. audiocraft/utils/extend.py +15 -11
app.py CHANGED
@@ -130,7 +130,7 @@ def predict(model, text, melody, duration, dimension, topk, topp, temperature, c
130
  duration -= segment_duration
131
  else:
132
  last_chunk = output_segments[-1][:, :, -overlap*MODEL.sample_rate:]
133
- next_segment = MODEL.generate_continuation(last_chunk, MODEL.sample_rate, descriptions=[text], progress=True)
134
  duration -= segment_duration - overlap
135
  output_segments.append(next_segment)
136
 
@@ -204,7 +204,7 @@ def ui(**kwargs):
204
  with gr.Row():
205
  title = gr.Textbox(label="Title", value="UnlimitedMusicGen", interactive=True)
206
  settings_font = gr.Text(label="Settings Font", value="./assets/arial.ttf", interactive=True)
207
- settings_font_color = gr.ColorPicker(label="Settings Font Color", value="#ffffff", interactive=True)
208
  with gr.Row():
209
  model = gr.Radio(["melody", "medium", "small", "large"], label="Model", value="melody", interactive=True)
210
  with gr.Row():
 
130
  duration -= segment_duration
131
  else:
132
  last_chunk = output_segments[-1][:, :, -overlap*MODEL.sample_rate:]
133
+ next_segment = MODEL.generate_continuation(last_chunk, MODEL.sample_rate, descriptions=[text], progress=False)
134
  duration -= segment_duration - overlap
135
  output_segments.append(next_segment)
136
 
 
204
  with gr.Row():
205
  title = gr.Textbox(label="Title", value="UnlimitedMusicGen", interactive=True)
206
  settings_font = gr.Text(label="Settings Font", value="./assets/arial.ttf", interactive=True)
207
+ settings_font_color = gr.ColorPicker(label="Settings Font Color", value="#c87f05", interactive=True)
208
  with gr.Row():
209
  model = gr.Radio(["melody", "medium", "small", "large"], label="Model", value="melody", interactive=True)
210
  with gr.Row():
audiocraft/utils/extend.py CHANGED
@@ -85,7 +85,7 @@ def generate_music_segments(text, melody, MODEL, seed, duration:int=10, overlap:
85
  descriptions=[text],
86
  melody_wavs=verse,
87
  sample_rate=sr,
88
- progress=True,
89
  prompt=last_chunk if len(last_chunk) > 0 else None,
90
  )
91
 
@@ -162,7 +162,14 @@ def load_font(font_name, font_size=16):
162
  try:
163
  font = ImageFont.truetype(font_name, font_size)
164
  except (FileNotFoundError, OSError):
165
- print("Font not found. Trying to download from local assets folder...\n")
 
 
 
 
 
 
 
166
  if font is None:
167
  try:
168
  font = ImageFont.truetype("assets/" + font_name, font_size)
@@ -172,16 +179,13 @@ def load_font(font_name, font_size=16):
172
  if font is None:
173
  try:
174
  req = requests.get(font_name)
175
- font = ImageFont.truetype(BytesIO(req.content), font_size)
176
- except (FileNotFoundError, OSError):
177
- print(f"Font found: {font_name} Using Hugging Face download font\n")
178
-
179
- if font is None:
180
- try:
181
- font = ImageFont.truetype(hf_hub_download("assets", font_name), encoding="UTF-8")
182
- except (FileNotFoundError, OSError):
183
- font = ImageFont.load_default()
184
  print(f"Font not found: {font_name} Using default font\n")
 
 
 
 
185
  return font
186
 
187
 
 
85
  descriptions=[text],
86
  melody_wavs=verse,
87
  sample_rate=sr,
88
+ progress=False,
89
  prompt=last_chunk if len(last_chunk) > 0 else None,
90
  )
91
 
 
162
  try:
163
  font = ImageFont.truetype(font_name, font_size)
164
  except (FileNotFoundError, OSError):
165
+ print("Font not found. Using Hugging Face download..\n")
166
+
167
+ if font is None:
168
+ try:
169
+ font_path = ImageFont.truetype(hf_hub_download(repo_id="Surn/UnlimitedMusicGen", filename="assets/" + font_name, repo_type="space"), encoding="UTF-8")
170
+ font = ImageFont.truetype(font_path, font_size)
171
+ except (FileNotFoundError, OSError):
172
+ print("Font not found. Trying to download from local assets folder...\n")
173
  if font is None:
174
  try:
175
  font = ImageFont.truetype("assets/" + font_name, font_size)
 
179
  if font is None:
180
  try:
181
  req = requests.get(font_name)
182
+ font = ImageFont.truetype(BytesIO(req.content), font_size)
183
+ except (FileNotFoundError, OSError):
 
 
 
 
 
 
 
184
  print(f"Font not found: {font_name} Using default font\n")
185
+ if font:
186
+ print(f"Font loaded {font.getname()}")
187
+ else:
188
+ font = ImageFont.load_default()
189
  return font
190
 
191