Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
import pandas as pd
|
4 |
import comtradeapicall
|
5 |
from huggingface_hub import InferenceClient
|
6 |
-
from
|
7 |
|
8 |
# کلید COMTRADE
|
9 |
subscription_key = os.getenv("COMTRADE_API_KEY", "")
|
@@ -11,7 +11,7 @@ subscription_key = os.getenv("COMTRADE_API_KEY", "")
|
|
11 |
hf_token = os.getenv("HF_API_TOKEN")
|
12 |
|
13 |
client = InferenceClient(token=hf_token)
|
14 |
-
translator =
|
15 |
|
16 |
def get_importers(hs_code: str, year: str, month: str):
|
17 |
period = f"{year}{int(month):02d}"
|
@@ -56,7 +56,7 @@ def provide_advice(table_data: pd.DataFrame, hs_code: str, year: str, month: str
|
|
56 |
print(outputs)
|
57 |
|
58 |
# ترجمه خروجی به فارسی
|
59 |
-
translated_outputs = translator.translate(outputs
|
60 |
print("خروجی ترجمهشده به فارسی:")
|
61 |
print(translated_outputs)
|
62 |
return translated_outputs
|
|
|
3 |
import pandas as pd
|
4 |
import comtradeapicall
|
5 |
from huggingface_hub import InferenceClient
|
6 |
+
from deep_translator import GoogleTranslator # جایگزین googletrans
|
7 |
|
8 |
# کلید COMTRADE
|
9 |
subscription_key = os.getenv("COMTRADE_API_KEY", "")
|
|
|
11 |
hf_token = os.getenv("HF_API_TOKEN")
|
12 |
|
13 |
client = InferenceClient(token=hf_token)
|
14 |
+
translator = GoogleTranslator(source='en', target='fa') # مترجم انگلیسی به فارسی
|
15 |
|
16 |
def get_importers(hs_code: str, year: str, month: str):
|
17 |
period = f"{year}{int(month):02d}"
|
|
|
56 |
print(outputs)
|
57 |
|
58 |
# ترجمه خروجی به فارسی
|
59 |
+
translated_outputs = translator.translate(outputs)
|
60 |
print("خروجی ترجمهشده به فارسی:")
|
61 |
print(translated_outputs)
|
62 |
return translated_outputs
|