Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1269,31 +1269,31 @@ def translate(txt,to_lang="en",from_lang="auto"):
|
|
1269 |
log(f'RET translate with translation as {translation}')
|
1270 |
return translation.lower()
|
1271 |
|
1272 |
-
@spaces.GPU(duration=
|
1273 |
def handle_generation(artist,song,genre,lyrics):
|
1274 |
|
1275 |
log(f'CALL handle_generate')
|
1276 |
|
1277 |
pos_artist = re.sub(r"([ \t]){1,}", " ", artist).upper().strip()
|
|
|
1278 |
pos_song = re.sub(r"([ \t]){1,}", " ", song).lower().strip()
|
1279 |
pos_song = ' '.join(word[0].upper() + word[1:] for word in pos_song.split())
|
1280 |
|
1281 |
-
lyrics = re.sub(r"
|
1282 |
lyrics_lines = re.split(r"([\n]){1,}", lyrics)
|
1283 |
|
1284 |
for line_index in range(len(lyrics_lines)):
|
1285 |
-
|
|
|
1286 |
lyrics_lines[line_index] = lyrics_lines[line_index].strip() + "."
|
1287 |
-
else:
|
1288 |
-
lyrics_lines[line_index] = lyrics_lines[line_index].strip()
|
1289 |
lyrics = " ".join(lyrics_lines)
|
1290 |
|
1291 |
-
pos_genre = re.sub(
|
1292 |
pos_genre = ' '.join(word[0].upper() + word[1:] for word in pos_genre.split())
|
1293 |
|
1294 |
pos_lyrics = re.sub(r"([ \t]){1,}", " ", lyrics).lower().strip()
|
1295 |
pos_lyrics = pos_lyrics if pos_lyrics == "" else summarize(translate(pos_lyrics))
|
1296 |
-
pos_lyrics = re.sub(r"([ \t]){1,}", " ",
|
1297 |
|
1298 |
neg = f"Sexuality, Human body, Human, Textual, Labeled, Distorted, Discontinuous, Blurry, Doll-Like, Overly Plastic, Low-Quality, Painted, Smooth, Artificial, Phony, Gaudy, Digital Effects."
|
1299 |
q = "\""
|
|
|
1269 |
log(f'RET translate with translation as {translation}')
|
1270 |
return translation.lower()
|
1271 |
|
1272 |
+
@spaces.GPU(duration=240)
|
1273 |
def handle_generation(artist,song,genre,lyrics):
|
1274 |
|
1275 |
log(f'CALL handle_generate')
|
1276 |
|
1277 |
pos_artist = re.sub(r"([ \t]){1,}", " ", artist).upper().strip()
|
1278 |
+
|
1279 |
pos_song = re.sub(r"([ \t]){1,}", " ", song).lower().strip()
|
1280 |
pos_song = ' '.join(word[0].upper() + word[1:] for word in pos_song.split())
|
1281 |
|
1282 |
+
lyrics = re.sub(r",( ){1,}",". ",lyrics)
|
1283 |
lyrics_lines = re.split(r"([\n]){1,}", lyrics)
|
1284 |
|
1285 |
for line_index in range(len(lyrics_lines)):
|
1286 |
+
lyrics_lines[line_index] = lyrics_lines[line_index].strip()
|
1287 |
+
if re.sub(r'[\.]$', '', lyrics_lines[line_index]) == lyrics_lines[line_index]:
|
1288 |
lyrics_lines[line_index] = lyrics_lines[line_index].strip() + "."
|
|
|
|
|
1289 |
lyrics = " ".join(lyrics_lines)
|
1290 |
|
1291 |
+
pos_genre = re.sub(r"([ \t]){1,}", " ", genre).lower().strip()
|
1292 |
pos_genre = ' '.join(word[0].upper() + word[1:] for word in pos_genre.split())
|
1293 |
|
1294 |
pos_lyrics = re.sub(r"([ \t]){1,}", " ", lyrics).lower().strip()
|
1295 |
pos_lyrics = pos_lyrics if pos_lyrics == "" else summarize(translate(pos_lyrics))
|
1296 |
+
pos_lyrics = re.sub(r"([ \t]){1,}", " ", pos_lyrics).lower().strip()
|
1297 |
|
1298 |
neg = f"Sexuality, Human body, Human, Textual, Labeled, Distorted, Discontinuous, Blurry, Doll-Like, Overly Plastic, Low-Quality, Painted, Smooth, Artificial, Phony, Gaudy, Digital Effects."
|
1299 |
q = "\""
|