MyTranslator / app.py
moslem's picture
Update app.py
09d6fef verified
raw
history blame contribute delete
427 Bytes
from fastapi import FastAPI, Query
from transformers import pipeline
app = FastAPI(title="English–Persian Translator")
pipe = pipeline("translation", model="sarvamai/sarvam-translate")
@app.get("/")
def home():
return {"message": "Welcome to English–Switzerland Translator!"}
@app.get("/translate")
def translate(text: str = Query(...)):
result = pipe(text)
return {"input": text, "translation": result[0]}