Yaron Koresh commited on
Commit
5c0528c
·
verified ·
1 Parent(s): 311351e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -585,7 +585,7 @@ def _summarize(text):
585
  log(f'RET _summarize with ret as {ret}')
586
  return ret
587
 
588
- def summarize(text, max_words=20):
589
  log(f'CALL summarize')
590
 
591
  words = text.split()
@@ -616,7 +616,7 @@ def generate_random_string(length):
616
  characters = str(ascii_letters + digits)
617
  return ''.join(random.choice(characters) for _ in range(length))
618
 
619
- def add_song_cover_text(img,top_title=None,bottom_title=None):
620
 
621
  w, h = img.size
622
 
@@ -1279,7 +1279,7 @@ def handle_generation(h,w,d):
1279
  d = " ".join(d_lines)
1280
 
1281
  d = re.sub(r"([ \t]){1,}", " ", d).lower().strip()
1282
- d = d if d == "" else summarize(translate(d))
1283
  d = re.sub(r"([ \t]){1,}", " ", d)
1284
  d = re.sub(r"(\. \.)", ".", d)
1285
 
@@ -1377,7 +1377,7 @@ if __name__ == "__main__":
1377
  outputs=[cover]
1378
  )
1379
  add_titles.click(
1380
- fn=add_song_cover_text,
1381
  inputs=[cover,top,bottom],
1382
  outputs=[cover]
1383
  )
 
585
  log(f'RET _summarize with ret as {ret}')
586
  return ret
587
 
588
+ def summarize(text, max_words=100):
589
  log(f'CALL summarize')
590
 
591
  words = text.split()
 
616
  characters = str(ascii_letters + digits)
617
  return ''.join(random.choice(characters) for _ in range(length))
618
 
619
+ def add_text_above_image(img,top_title=None,bottom_title=None):
620
 
621
  w, h = img.size
622
 
 
1279
  d = " ".join(d_lines)
1280
 
1281
  d = re.sub(r"([ \t]){1,}", " ", d).lower().strip()
1282
+ d = d if d == "" else summarize(translate(d),max_words=30)
1283
  d = re.sub(r"([ \t]){1,}", " ", d)
1284
  d = re.sub(r"(\. \.)", ".", d)
1285
 
 
1377
  outputs=[cover]
1378
  )
1379
  add_titles.click(
1380
+ fn=add_text_above_image,
1381
  inputs=[cover,top,bottom],
1382
  outputs=[cover]
1383
  )