Spaces:
Runtime error
Runtime error
File size: 525 Bytes
9f772ef |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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)
@app.post("/transliterate")
async def transliterate(request: TransliterationRequest):
result = transliterator(request.text, max_length=128, num_beams=5)
return {"bengali_text": result[0]["generated_text"]}
|