Spaces:
Running
Running
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -49,7 +49,12 @@ def translate(text,lang):
|
|
49 |
content = resp.content
|
50 |
html = fromstring(content)
|
51 |
rslt = html.xpath('//pre[@aria-label="Translated text"]/span')
|
52 |
-
translated =
|
|
|
|
|
|
|
|
|
|
|
53 |
ret = re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
54 |
print(ret)
|
55 |
return ret
|
@@ -58,12 +63,12 @@ def generate_random_string(length):
|
|
58 |
characters = string.ascii_letters + string.digits
|
59 |
return ''.join(random.choice(characters) for _ in range(length))
|
60 |
|
61 |
-
@spaces.GPU(120)
|
62 |
def Piper(_do, _dont):
|
63 |
return pipe(
|
64 |
_do,
|
65 |
-
height=
|
66 |
-
width=
|
67 |
negative_prompt=_dont,
|
68 |
num_inference_steps=400,
|
69 |
guidance_scale=10
|
|
|
49 |
content = resp.content
|
50 |
html = fromstring(content)
|
51 |
rslt = html.xpath('//pre[@aria-label="Translated text"]/span')
|
52 |
+
translated = text
|
53 |
+
try:
|
54 |
+
t = rslt[0].text.strip()
|
55 |
+
translated = t
|
56 |
+
except:
|
57 |
+
print(f'"{text}" is already in {lang}!')
|
58 |
ret = re.sub(f'[{string.punctuation}]', '', re.sub('[\s+]', ' ', translated)).lower().strip()
|
59 |
print(ret)
|
60 |
return ret
|
|
|
63 |
characters = string.ascii_letters + string.digits
|
64 |
return ''.join(random.choice(characters) for _ in range(length))
|
65 |
|
66 |
+
@spaces.GPU(duration=120)
|
67 |
def Piper(_do, _dont):
|
68 |
return pipe(
|
69 |
_do,
|
70 |
+
height=480,
|
71 |
+
width=480,
|
72 |
negative_prompt=_dont,
|
73 |
num_inference_steps=400,
|
74 |
guidance_scale=10
|