Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import requests
|
2 |
from bs4 import BeautifulSoup
|
3 |
from abc import ABC, abstractmethod
|
@@ -1192,7 +1193,7 @@ class GoogleTranslator(BaseTranslator):
|
|
1192 |
self._url_params["sl"] = self._source
|
1193 |
|
1194 |
if self.payload_key:
|
1195 |
-
self._url_params[self.payload_key] = text
|
1196 |
|
1197 |
response = requests.get(
|
1198 |
self._base_url, params=self._url_params, proxies=self.proxies
|
@@ -1278,14 +1279,21 @@ def handle_generation(artist,song,genre,lyrics):
|
|
1278 |
|
1279 |
log(f'CALL handle_generate')
|
1280 |
|
1281 |
-
pos_artist = re.sub("([ \t
|
1282 |
-
pos_song = re.sub("([ \t
|
1283 |
pos_song = ' '.join(word[0].upper() + word[1:] for word in pos_song.split())
|
1284 |
|
1285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1286 |
pos_genre = ' '.join(word[0].upper() + word[1:] for word in pos_genre.split())
|
1287 |
|
1288 |
-
pos_lyrics = re.sub(f'[{punctuation}]', '', re.sub("([ \t
|
1289 |
pos_lyrics_sum = pos_lyrics if pos_lyrics == "" else summarize(translate(pos_lyrics))
|
1290 |
|
1291 |
neg = f"Sexuality, Humanity, Textual, Labeled, Distorted, Discontinuous, Blurry, Doll-Like, Overly Plastic, Low-Quality, Painted, Smoothed, Artificial, Phony, Gaudy, Digital Effects."
|
@@ -1344,7 +1352,7 @@ if __name__ == "__main__":
|
|
1344 |
placeholder="Lyrics",
|
1345 |
value="",
|
1346 |
container=False,
|
1347 |
-
max_lines=
|
1348 |
)
|
1349 |
|
1350 |
with gr.Column():
|
|
|
1 |
+
import urllib
|
2 |
import requests
|
3 |
from bs4 import BeautifulSoup
|
4 |
from abc import ABC, abstractmethod
|
|
|
1193 |
self._url_params["sl"] = self._source
|
1194 |
|
1195 |
if self.payload_key:
|
1196 |
+
self._url_params[self.payload_key] = urllib.parse.quote(text,encoding="utf8")
|
1197 |
|
1198 |
response = requests.get(
|
1199 |
self._base_url, params=self._url_params, proxies=self.proxies
|
|
|
1279 |
|
1280 |
log(f'CALL handle_generate')
|
1281 |
|
1282 |
+
pos_artist = re.sub(r"([ \t]){1,}", " ", artist).upper().strip()
|
1283 |
+
pos_song = re.sub(r"([ \t]){1,}", " ", song).lower().strip()
|
1284 |
pos_song = ' '.join(word[0].upper() + word[1:] for word in pos_song.split())
|
1285 |
|
1286 |
+
lyrics_lines = re.split(r"([\n]){1,}", lyrics)
|
1287 |
+
|
1288 |
+
for line_index in range(len(lyrics_lines)):
|
1289 |
+
if re.sub(f'[{punctuation}]$', '', lyrics_lines[line_index]) == lyrics_lines[line_index]):
|
1290 |
+
lyrics_lines[line_index] = lyrics_lines[line_index] + "."
|
1291 |
+
lyrics = " ".join(lyrics_lines)
|
1292 |
+
|
1293 |
+
pos_genre = re.sub(f'[{punctuation}]', '', re.sub(r"([ \t]){1,}", " ", genre)).lower().strip()
|
1294 |
pos_genre = ' '.join(word[0].upper() + word[1:] for word in pos_genre.split())
|
1295 |
|
1296 |
+
pos_lyrics = re.sub(f'[{punctuation}]', '', re.sub(r"([ \t]){1,}", " ", lyrics)).lower().strip()
|
1297 |
pos_lyrics_sum = pos_lyrics if pos_lyrics == "" else summarize(translate(pos_lyrics))
|
1298 |
|
1299 |
neg = f"Sexuality, Humanity, Textual, Labeled, Distorted, Discontinuous, Blurry, Doll-Like, Overly Plastic, Low-Quality, Painted, Smoothed, Artificial, Phony, Gaudy, Digital Effects."
|
|
|
1352 |
placeholder="Lyrics",
|
1353 |
value="",
|
1354 |
container=False,
|
1355 |
+
max_lines=200
|
1356 |
)
|
1357 |
|
1358 |
with gr.Column():
|