Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,8 +5,9 @@ from gradio import routes
|
|
5 |
from typing import List, Type
|
6 |
from aiogoogletrans import Translator
|
7 |
|
8 |
-
import requests, os, re
|
9 |
|
|
|
10 |
gradio_client = GrClient(os.environ.get('GrClient_url'))
|
11 |
translator = Translator()
|
12 |
# Monkey patch
|
@@ -30,8 +31,8 @@ routes.get_types = get_types
|
|
30 |
|
31 |
# App code
|
32 |
def mbti(x):
|
33 |
-
t = translator.translate(x, src='ko', dest='en')
|
34 |
-
str_trans = re.sub('[-=+,#/\?:^.@*\"β»~γ!γβ|\(\)\[\]`\'β¦γ\β\β\βΒ·]', '', t)
|
35 |
result = gradio_client.predict(
|
36 |
str_trans, # str representing input in 'User input' Textbox component
|
37 |
fn_index=2
|
|
|
5 |
from typing import List, Type
|
6 |
from aiogoogletrans import Translator
|
7 |
|
8 |
+
import requests, os, re, asyncio
|
9 |
|
10 |
+
loop = asyncio.get_event_loop()
|
11 |
gradio_client = GrClient(os.environ.get('GrClient_url'))
|
12 |
translator = Translator()
|
13 |
# Monkey patch
|
|
|
31 |
|
32 |
# App code
|
33 |
def mbti(x):
|
34 |
+
t = loop.run_until_complete(translator.translate(x, src='ko', dest='en'))
|
35 |
+
str_trans = re.sub('[-=+,#/\?:^.@*\"β»~γ!γβ|\(\)\[\]`\'β¦γ\β\β\βΒ·]', '', t.text)
|
36 |
result = gradio_client.predict(
|
37 |
str_trans, # str representing input in 'User input' Textbox component
|
38 |
fn_index=2
|