Spaces:
Sleeping
Sleeping
File size: 427 Bytes
aa0ae99 09d6fef aa0ae99 0ac87a5 aa0ae99 ef9f146 09d6fef |
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")
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]}
|