Spaces:
Sleeping
Sleeping
| 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") | |
| def home(): | |
| return {"message": "Welcome to English–Switzerland Translator!"} | |
| def translate(text: str = Query(...)): | |
| result = translator_en_fa(text) | |
| return {"input": text, "translation": result[0]["translation_text"]} | |