Spaces:
Runtime error
Runtime error
from fastapi import FastAPI | |
from transformers import pipeline | |
from pydantic import BaseModel | |
app = FastAPI() | |
class TransliterationRequest(BaseModel): | |
text: str | |
# Load model | |
model_name = "your-username/banglish-bengali-transliteration" | |
transliterator = pipeline("text2text-generation", model=model_name) | |
async def transliterate(request: TransliterationRequest): | |
result = transliterator(request.text, max_length=128, num_beams=5) | |
return {"bengali_text": result[0]["generated_text"]} | |