Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -8,6 +8,14 @@ from io import StringIO
|
|
8 |
import os
|
9 |
import uuid
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
from pandasai import SmartDataframe
|
12 |
import pandas as pd
|
13 |
from pandasai.llm import OpenAI
|
@@ -28,6 +36,11 @@ import base64
|
|
28 |
from PIL import Image
|
29 |
from io import BytesIO
|
30 |
|
|
|
|
|
|
|
|
|
|
|
31 |
def convert_image_to_base64(image_path):
|
32 |
with Image.open(image_path) as image:
|
33 |
buffered = BytesIO()
|
|
|
8 |
import os
|
9 |
import uuid
|
10 |
|
11 |
+
import googletrans
|
12 |
+
from googletrans import Translator
|
13 |
+
translator = Translator()
|
14 |
+
lan = googletrans.LANGUAGES
|
15 |
+
#print(lan)
|
16 |
+
keys = list(lan.keys())
|
17 |
+
vals = list(lan.values())
|
18 |
+
|
19 |
from pandasai import SmartDataframe
|
20 |
import pandas as pd
|
21 |
from pandasai.llm import OpenAI
|
|
|
36 |
from PIL import Image
|
37 |
from io import BytesIO
|
38 |
|
39 |
+
@app.post("/translator")
|
40 |
+
async def tra(sentence,lang):
|
41 |
+
lang = lang.lower()
|
42 |
+
return translator.translate(sentence,dest=keys[vals.index(lang)]).text
|
43 |
+
|
44 |
def convert_image_to_base64(image_path):
|
45 |
with Image.open(image_path) as image:
|
46 |
buffered = BytesIO()
|