Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI, Query | |
| from transformers import pipeline | |
| app = FastAPI(title="English–Persian Translator") | |
| pipe = pipeline("translation", model="sarvamai/sarvam-translate") | |
| def home(): | |
| return {"message": "Welcome to English–Switzerland Translator!"} | |
| def translate(text: str = Query(...)): | |
| result = pipe(text) | |
| return {"input": text, "translation": result[0]} | |