Spaces:
Sleeping
Sleeping
File size: 468 Bytes
aa0ae99 6e0fb57 aa0ae99 0ac87a5 aa0ae99 ef9f146 aa0ae99 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
from fastapi import FastAPI, Query
from transformers import pipeline
app = FastAPI(title="English–Persian Translator")
translator_en_fa = pipeline("translation_en_to_fa", model="opus-mt-en-zh")
@app.get("/")
def home():
return {"message": "Welcome to English–Switzerland Translator!"}
@app.get("/translate")
def translate(text: str = Query(...)):
result = translator_en_fa(text)
return {"input": text, "translation": result[0]["translation_text"]}
|