moslem commited on
Commit
09d6fef
·
verified ·
1 Parent(s): b173d06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -3,7 +3,7 @@ from transformers import pipeline
3
 
4
  app = FastAPI(title="English–Persian Translator")
5
 
6
- translator_en_fa = pipeline("translation_en_to_fa", model="opus-mt-en-zh")
7
 
8
  @app.get("/")
9
  def home():
@@ -11,5 +11,5 @@ def home():
11
 
12
  @app.get("/translate")
13
  def translate(text: str = Query(...)):
14
- result = translator_en_fa(text)
15
- return {"input": text, "translation": result[0]["translation_text"]}
 
3
 
4
  app = FastAPI(title="English–Persian Translator")
5
 
6
+ pipe = pipeline("translation", model="sarvamai/sarvam-translate")
7
 
8
  @app.get("/")
9
  def home():
 
11
 
12
  @app.get("/translate")
13
  def translate(text: str = Query(...)):
14
+ result = pipe(text)
15
+ return {"input": text, "translation": result[0]}