from fastapi import FastAPI from pydantic import BaseModel from GE2PE import GE2PE import uvicorn app = FastAPI() ge2pe = GE2PE(model_path='./homo-ge2pe', GPU=False) class PhonemizeRequest(BaseModel): text: str # Route @app.get("/") async def root(): return {"message": "Welcome to the Persian Phonemizer API. Use the /phonemize endpoint to process text."} @app.post('/api/phonemize') async def phonemize(req: PhonemizeRequest): result = ge2pe.generate_with_punctuation(req.text, use_rules=True) return {"phonemes": result}