another-avro / app.py
torr20's picture
Create app.py
9f772ef verified
raw
history blame
525 Bytes
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"]}